Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ Legend
+ : added
- : removed

v2.??,
------------------
+ added info method, listing the files and some meta information (#56)

v2.4.0, 2025-07-06
------------------
+ [MAJOR] New text file format for the resulting artifact (as an diffable alternative to zip) - see more in https://github.com/sbcgua/mockup-compiler-js/blob/master/doc/text-bundle-format.md
Expand Down
12 changes: 12 additions & 0 deletions docs/REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,18 @@ Checks id the mockup loader instance is redirected by `ZMOCKUP_LOADER_SWSRC` tra
endif.
```

### INFO

Returns useful meta infomration about the archive: list of files, format of mock, current path and type of the mock.

```abap
exporting
e_src_type type ty_src_type " source type - FILE or MIME
e_src_path type string " source path (to the file or MIME object name)
e_src_format type string " source format: zip or text
e_files type string_table. " list of files in the archive
```

## ZCL_MOCKUP_LOADER_STORE

### GET_INSTANCE (static)
Expand Down
29 changes: 19 additions & 10 deletions src/core/zcl_mockup_loader.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ class ZCL_MOCKUP_LOADER definition
data mv_dir type string.
data mr_ref_to_container type ref to data.
data ms_next_load_params type ty_load_params.
data mv_src_type type zif_mockup_loader=>ty_src_type.
data mv_src_path type string.

class-methods read_zip_blob
importing
Expand Down Expand Up @@ -282,17 +284,14 @@ CLASS ZCL_MOCKUP_LOADER IMPLEMENTATION.
i_skip_lines_starting_with = i_skip_lines_starting_with
it_ignore_conv_exits = it_ignore_conv_exits ).

data l_src_type type zif_mockup_loader=>ty_src_type.
data l_src_path type string.

l_src_type = i_type.
l_src_path = i_path.
ro_instance->mv_src_type = i_type.
ro_instance->mv_src_path = i_path.

redirect_source(
changing
c_is_redirected = ro_instance->mv_is_redirected
c_src_type = l_src_type
c_src_path = l_src_path ).
c_src_type = ro_instance->mv_src_type
c_src_path = ro_instance->mv_src_path ).

data lv_xdata type xstring.
data lv_zip_cache_key type string.
Expand All @@ -303,7 +302,7 @@ CLASS ZCL_MOCKUP_LOADER IMPLEMENTATION.
field-symbols <zip_cache> like line of gt_zip_cache.

if i_cache_timeout > 0. " Caching active
lv_zip_cache_key = l_src_type && ':' && l_src_path.
lv_zip_cache_key = ro_instance->mv_src_type && ':' && ro_instance->mv_src_path.

import
ts = lv_cache_timestamp
Expand Down Expand Up @@ -349,8 +348,8 @@ CLASS ZCL_MOCKUP_LOADER IMPLEMENTATION.
if <zip_cache> is not assigned. " Cache not found
read_zip_blob(
exporting
i_type = l_src_type
i_path = l_src_path
i_type = ro_instance->mv_src_type
i_path = ro_instance->mv_src_path
importing
e_xdata = lv_xdata
e_is_txt = lv_is_txt_format ).
Expand Down Expand Up @@ -678,6 +677,16 @@ CLASS ZCL_MOCKUP_LOADER IMPLEMENTATION.
endmethod.


method zif_mockup_loader~info.
e_src_type = mv_src_type.
e_src_path = mv_src_path.
e_src_format = mi_archive->type( ).
if e_files is supplied.
e_files = mi_archive->files.
endif.
endmethod.


method zif_mockup_loader~into.

load_data(
Expand Down
3 changes: 3 additions & 0 deletions src/core/zcl_mockup_loader.clas.locals_def.abap
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
interface lif_archive.
data files type string_table.
methods type
returning
value(r_type) type string.
methods get
importing
name type string
Expand Down
8 changes: 8 additions & 0 deletions src/core/zcl_mockup_loader.clas.locals_imp.abap
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ class lcl_zip_archive implementation.

endmethod.

method lif_archive~type.
r_type = 'zip'.
endmethod.

endclass.

**********************************************************************
Expand Down Expand Up @@ -398,4 +402,8 @@ class lcl_text_archive implementation.

endmethod.

method lif_archive~type.
r_type = 'text'.
endmethod.

endclass.
32 changes: 32 additions & 0 deletions src/core/zcl_mockup_loader.clas.testclasses.abap
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ class ltcl_test_mockup_loader definition for testing
methods source_redirect_test for testing.
methods utf16_encoding for testing.

methods info for testing.
methods parse_data for testing.
methods load_blob for testing raising zcx_mockup_loader_error.
methods load_data_to_ref for testing.
Expand Down Expand Up @@ -1509,4 +1510,35 @@ class ltcl_test_mockup_loader implementation.

endmethod.

method info.

data li type ref to zif_mockup_loader.
data lv_type type zif_mockup_loader=>ty_src_type.
data lv_path type string.
data lv_format type string.
data lt_list type string_table.

li = o.

li->info(
importing
e_src_type = lv_type
e_src_path = lv_path
e_src_format = lv_format
e_files = lt_list ).

cl_abap_unit_assert=>assert_equals(
act = lv_type
exp = 'MIME' ).

cl_abap_unit_assert=>assert_equals(
act = lv_format
exp = 'zip' ).

cl_abap_unit_assert=>assert_not_initial( lt_list ).
read table lt_list with key table_line = `.meta/src_files` transporting no fields.
cl_abap_unit_assert=>assert_subrc( ).

endmethod.

endclass.
2 changes: 2 additions & 0 deletions src/core/zcl_mockup_loader_deep_providr.clas.testclasses.abap
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class ltcl_mockup_loader_mock implementation.
endmethod.
method zif_mockup_loader~into.
endmethod.
method zif_mockup_loader~info.
endmethod.

method zif_mockup_loader~load_data.
data ls_data type ty_data.
Expand Down
21 changes: 13 additions & 8 deletions src/core/zif_mockup_loader.intf.abap
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,16 @@ interface zif_mockup_loader
valref type ref to data,
type type ty_filter_type,
operation type ty_filter_operation, " Internal usage for the moment
end of ty_filter .
end of ty_filter.
types:
tt_filter type standard table of ty_filter with key name .
tt_filter type standard table of ty_filter with key name.
types:
begin of ty_where,
name type string,
range type ref to data,
end of ty_where .
end of ty_where.
types:
tt_where type standard table of ty_where with key name .
tt_where type standard table of ty_where with key name.

types:
tty_conv_exits type standard table of abap_editmask with default key.
Expand Down Expand Up @@ -132,13 +132,20 @@ interface zif_mockup_loader
* METHODS
**********************************************************************

methods info
exporting
e_src_type type ty_src_type
e_src_path type string
e_src_format type string
e_files type string_table.

methods load_blob
importing
!i_obj_path type string
returning
value(r_content) type xstring
raising
zcx_mockup_loader_error .
zcx_mockup_loader_error.

methods load_data
importing
Expand All @@ -151,7 +158,7 @@ interface zif_mockup_loader
exporting
!e_container type any
raising
zcx_mockup_loader_error .
zcx_mockup_loader_error.

methods to
importing
Expand Down Expand Up @@ -180,8 +187,6 @@ interface zif_mockup_loader
returning
value(ri_ml) type ref to zif_mockup_loader.

*** EXPERIMENTAL ***

methods load
importing
!i_obj type string
Expand Down
Loading