eco-helpers 2.6.3 → 2.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +95 -0
- data/CHANGELOG.md +135 -2
- data/Rakefile +13 -7
- data/eco-helpers.gemspec +3 -3
- data/lib/eco/api/common/loaders/base.rb +2 -2
- data/lib/eco/api/common/loaders/case_base.rb +1 -1
- data/lib/eco/api/common/loaders/config/workflow/mailer.rb +5 -5
- data/lib/eco/api/common/loaders/error_handler.rb +8 -5
- data/lib/eco/api/common/loaders/parser.rb +44 -22
- data/lib/eco/api/common/loaders/policy.rb +6 -4
- data/lib/eco/api/common/loaders/use_case.rb +13 -7
- data/lib/eco/api/common/people/base_parser.rb +0 -2
- data/lib/eco/api/common/people/default_parsers/boolean_parser.rb +0 -1
- data/lib/eco/api/common/people/default_parsers/csv_parser.rb +1 -1
- data/lib/eco/api/common/people/default_parsers/date_parser.rb +64 -12
- data/lib/eco/api/common/people/default_parsers/freemium_parser.rb +0 -1
- data/lib/eco/api/common/people/default_parsers/login_providers_parser.rb +13 -5
- data/lib/eco/api/common/people/default_parsers/multi_parser.rb +0 -1
- data/lib/eco/api/common/people/default_parsers/numeric_parser.rb +18 -5
- data/lib/eco/api/common/people/default_parsers/policy_groups_parser.rb +8 -8
- data/lib/eco/api/common/people/default_parsers/select_parser.rb +50 -26
- data/lib/eco/api/common/people/default_parsers/send_invites_parser.rb +6 -6
- data/lib/eco/api/common/people/default_parsers/xls_parser.rb +9 -12
- data/lib/eco/api/common/people/default_parsers.rb +1 -12
- data/lib/eco/api/common/people/entries.rb +13 -13
- data/lib/eco/api/common/people/entry_factory.rb +76 -45
- data/lib/eco/api/common/people/person_attribute_parser.rb +8 -12
- data/lib/eco/api/common/people/person_entry.rb +86 -75
- data/lib/eco/api/common/people/person_entry_attribute_mapper.rb +60 -44
- data/lib/eco/api/common/people/person_factory.rb +30 -22
- data/lib/eco/api/common/people/person_modifier.rb +11 -13
- data/lib/eco/api/common/people/person_parser.rb +101 -39
- data/lib/eco/api/common/people/supervisor_helpers.rb +25 -26
- data/lib/eco/api/common/session/base_session.rb +9 -9
- data/lib/eco/api/common/session/environment.rb +7 -5
- data/lib/eco/api/common/session/sftp.rb +59 -32
- data/lib/eco/api/common/version_patches/ecoportal_api/external_person.rb +10 -6
- data/lib/eco/api/common/version_patches/exception.rb +11 -13
- data/lib/eco/api/error.rb +32 -20
- data/lib/eco/api/microcases/set_supervisor.rb +0 -3
- data/lib/eco/api/organization/node_classifications.rb +82 -0
- data/lib/eco/api/organization/policy_groups.rb +4 -6
- data/lib/eco/api/organization/tag_tree.rb +169 -93
- data/lib/eco/api/organization.rb +1 -0
- data/lib/eco/api/session/batch/job.rb +1 -1
- data/lib/eco/api/session/config/tagtree.rb +41 -23
- data/lib/eco/api/session/config/workflow.rb +113 -88
- data/lib/eco/api/session/config.rb +6 -0
- data/lib/eco/api/session.rb +51 -29
- data/lib/eco/api/usecases/base_io.rb +28 -25
- data/lib/eco/api/usecases/default/locations/cli/tagtree_extract_cli.rb +7 -2
- data/lib/eco/api/usecases/default/locations/cli/tagtree_upload_cli.rb +21 -0
- data/lib/eco/api/usecases/default/locations/csv_to_tree_case.rb +3 -3
- data/lib/eco/api/usecases/default/locations/tagtree_extract_case.rb +54 -23
- data/lib/eco/api/usecases/default/locations/tagtree_upload_case.rb +87 -0
- data/lib/eco/api/usecases/default/locations.rb +1 -0
- data/lib/eco/api/usecases/default/people/analyse_people_case.rb +60 -56
- data/lib/eco/api/usecases/default/people/change_email_case.rb +8 -9
- data/lib/eco/api/usecases/default/people/clean_unknown_tags_case.rb +13 -11
- data/lib/eco/api/usecases/default/people/clear_abilities_case.rb +2 -2
- data/lib/eco/api/usecases/default/people/org_data_convert_case.rb +25 -27
- data/lib/eco/api/usecases/default/people/refresh_case.rb +2 -2
- data/lib/eco/api/usecases/default/people/reinvite_trans_case.rb +1 -1
- data/lib/eco/api/usecases/default/people/reinvite_trans_cli.rb +0 -1
- data/lib/eco/api/usecases/default/people/restore_db_case.rb +39 -34
- data/lib/eco/api/usecases/default/people/set_default_tag_case.rb +19 -15
- data/lib/eco/api/usecases/default/people/supers_cyclic_identify_case.rb +16 -12
- data/lib/eco/api/usecases/default_cases/hris_case.rb +17 -15
- data/lib/eco/api/usecases/default_cases/samples/sftp_case.rb +30 -16
- data/lib/eco/api/usecases/default_cases/to_csv_detailed_case.rb +0 -2
- data/lib/eco/api/usecases/graphql/base.rb +5 -3
- data/lib/eco/api/usecases/graphql/helpers/base/case_env.rb +4 -1
- data/lib/eco/api/usecases/graphql/helpers/base/graphql_env.rb +14 -0
- data/lib/eco/api/usecases/graphql/helpers/base.rb +5 -4
- data/lib/eco/api/usecases/graphql/helpers/location/base/classifications_parser.rb +60 -0
- data/lib/eco/api/usecases/graphql/helpers/location/base/tree_tracking.rb +72 -0
- data/lib/eco/api/usecases/graphql/helpers/location/base.rb +25 -59
- data/lib/eco/api/usecases/graphql/helpers/location/command/diff/as_update.rb +59 -0
- data/lib/eco/api/usecases/graphql/helpers/location/command/diff/compare.rb +49 -0
- data/lib/eco/api/usecases/graphql/helpers/location/command/diff.rb +11 -0
- data/lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb +46 -0
- data/lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/diff_sortable/for_archive.rb +23 -0
- data/lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/diff_sortable/for_unarchive.rb +65 -0
- data/lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/diff_sortable.rb +49 -0
- data/lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/sortable/relation_safe_sort.rb +119 -0
- data/lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/sortable.rb +59 -0
- data/lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages.rb +82 -0
- data/lib/eco/api/usecases/graphql/helpers/location/command/diffs.rb +20 -0
- data/lib/eco/api/usecases/graphql/helpers/location/command/optimizations.rb +84 -0
- data/lib/eco/api/usecases/graphql/helpers/location/command/result.rb +4 -4
- data/lib/eco/api/usecases/graphql/helpers/location/command/results.rb +24 -12
- data/lib/eco/api/usecases/graphql/helpers/location/command.rb +21 -24
- data/lib/eco/api/usecases/graphql/helpers/location/tags_remap/tags_map.rb +1 -1
- data/lib/eco/api/usecases/graphql/helpers/location/tags_remap/tags_set.rb +10 -11
- data/lib/eco/api/usecases/graphql/helpers/location/tags_remap.rb +8 -9
- data/lib/eco/api/usecases/graphql/samples/location/command/dsl.rb +41 -12
- data/lib/eco/api/usecases/graphql/samples/location/command/results.rb +11 -80
- data/lib/eco/api/usecases/graphql/samples/location/command/service/tree_update.rb +89 -0
- data/lib/eco/api/usecases/graphql/samples/location/command/service.rb +6 -0
- data/lib/eco/api/usecases/graphql/samples/location/command/track_changed_ids.rb +89 -0
- data/lib/eco/api/usecases/graphql/samples/location/command.rb +3 -0
- data/lib/eco/api/usecases/graphql/samples/location/service/base.rb +9 -0
- data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/heading.rb +18 -0
- data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/inputable.rb +53 -0
- data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing/classifications.rb +34 -0
- data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing/helpers.rb +28 -0
- data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing.rb +46 -0
- data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible.rb +38 -0
- data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff.rb +105 -0
- data/lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/discarded.rb +16 -0
- data/lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/input.rb +15 -0
- data/lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/node_attr_maps.rb +22 -0
- data/lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb +45 -0
- data/lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter.rb +36 -0
- data/lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/output.rb +56 -0
- data/lib/eco/api/usecases/graphql/samples/location/service/tree_to_list.rb +41 -0
- data/lib/eco/api/usecases/graphql/samples/location/service.rb +8 -0
- data/lib/eco/api/usecases/graphql/samples/location.rb +1 -0
- data/lib/eco/api/usecases/graphql/utils/sftp.rb +96 -36
- data/lib/eco/api/usecases/ooze_cases/export_register_case.rb +8 -6
- data/lib/eco/api/usecases/ooze_samples/helpers/creatable.rb +4 -3
- data/lib/eco/api/usecases/ooze_samples/helpers/exportable_ooze.rb +39 -25
- data/lib/eco/api/usecases/ooze_samples/helpers/exportable_register.rb +13 -15
- data/lib/eco/api/usecases/ooze_samples/helpers/filters.rb +50 -21
- data/lib/eco/api/usecases/ooze_samples/helpers/ooze_handlers.rb +21 -11
- data/lib/eco/api/usecases/ooze_samples/helpers/rescuable.rb +2 -0
- data/lib/eco/api/usecases/ooze_samples/helpers/shortcuts.rb +49 -43
- data/lib/eco/api/usecases/ooze_samples/ooze_base_case.rb +17 -19
- data/lib/eco/api/usecases/ooze_samples/register_export_case.rb +48 -43
- data/lib/eco/api/usecases/ooze_samples/register_update_case.rb +34 -34
- data/lib/eco/api/usecases/ooze_samples/target_oozes_update_case.rb +8 -10
- data/lib/eco/api/usecases.rb +0 -1
- data/lib/eco/cli/config/use_cases.rb +31 -29
- data/lib/eco/cli_default/input_filters.rb +0 -5
- data/lib/eco/cli_default/people_filters.rb +4 -4
- data/lib/eco/cli_default/workflow.rb +13 -14
- data/lib/eco/csv/table.rb +34 -25
- data/lib/eco/data/hashes/array_diff.rb +24 -35
- data/lib/eco/data/hashes/diff_result/meta.rb +131 -0
- data/lib/eco/data/hashes/diff_result.rb +65 -57
- data/lib/eco/data/hashes/sanke_camel_indifferent_access.rb +278 -0
- data/lib/eco/data/hashes.rb +1 -1
- data/lib/eco/data/locations/convert.rb +1 -1
- data/lib/eco/data/locations/node_base/csv_convert.rb +19 -9
- data/lib/eco/data/locations/node_base/parsing.rb +4 -2
- data/lib/eco/data/locations/node_base/treeify.rb +149 -132
- data/lib/eco/data/locations/node_base.rb +15 -4
- data/lib/eco/data/locations/node_diff/accessors.rb +13 -5
- data/lib/eco/data/locations/node_diff/nodes_diff/clustered_treeify.rb +101 -0
- data/lib/eco/data/locations/node_diff/nodes_diff/diffs_tree.rb +99 -0
- data/lib/eco/data/locations/node_diff/{selectors.rb → nodes_diff/selectors.rb} +1 -1
- data/lib/eco/data/locations/node_diff/nodes_diff.rb +50 -35
- data/lib/eco/data/locations/node_diff.rb +45 -17
- data/lib/eco/data/locations/node_level/parsing.rb +15 -21
- data/lib/eco/data/locations/node_level.rb +66 -22
- data/lib/eco/data/locations/node_plain/parsing.rb +1 -1
- data/lib/eco/data/locations/node_plain.rb +60 -7
- data/lib/eco/data/strings/camel_case.rb +35 -0
- data/lib/eco/data/strings/snake_case.rb +18 -0
- data/lib/eco/data/strings.rb +8 -0
- data/lib/eco/data.rb +1 -0
- data/lib/eco/language/methods/call_detector.rb +11 -0
- data/lib/eco/language/methods/dsl_able.rb +7 -1
- data/lib/eco/language/methods.rb +2 -1
- data/lib/eco/language/models/collection.rb +23 -25
- data/lib/eco/language/models/parser_serializer.rb +24 -5
- data/lib/eco/version.rb +1 -1
- data/lib/eco-helpers.rb +0 -1
- metadata +54 -9
- data/lib/eco/data/hashes/diff_meta.rb +0 -52
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8917d285e4be19210a8ff91693ba0d75219e9817e0d302f756eba5c4d844b29
|
4
|
+
data.tar.gz: 40de5a5f30c3c5fa6706930a96225be22a72b543b4eba68212b774f4dc4faec6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b66c156aec53e2a1d1076afe988959e740d8842166e4b808ae8e93ebe97e4fbfc394b50fa6147d3950d4d1ccee427d54785136b0bfe2db3c7da9231fbfe54cf3
|
7
|
+
data.tar.gz: abdf0f5b2188c3ca5f75403e019983133c80661d25b9176a2dcc373eea929d9a7193c073b358003010c7041ecf74df6bba130b558f0e0845c1689b0968eb309e
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.7.8
|
3
|
+
Exclude:
|
4
|
+
- 'config/routes.rb'
|
5
|
+
NewCops: enable
|
6
|
+
|
7
|
+
Metrics/ClassLength:
|
8
|
+
Max: 500
|
9
|
+
Metrics/ModuleLength:
|
10
|
+
Max: 300
|
11
|
+
Metrics/MethodLength:
|
12
|
+
Max: 50
|
13
|
+
Metrics/AbcSize:
|
14
|
+
Max: 30
|
15
|
+
Metrics/ParameterLists:
|
16
|
+
Max: 5
|
17
|
+
CountKeywordArgs: false
|
18
|
+
Metrics/BlockLength:
|
19
|
+
CountAsOne: ['array', 'heredoc', 'method_call']
|
20
|
+
Max: 50
|
21
|
+
Metrics/CyclomaticComplexity:
|
22
|
+
Max: 30
|
23
|
+
Metrics/PerceivedComplexity:
|
24
|
+
Max: 30
|
25
|
+
|
26
|
+
Style/AccessorGrouping:
|
27
|
+
Enabled: false
|
28
|
+
Style/ConditionalAssignment:
|
29
|
+
Enabled: false
|
30
|
+
Style/BlockDelimiters:
|
31
|
+
BracesRequiredMethods: ['log']
|
32
|
+
AllowedPatterns: ['proc', 'new']
|
33
|
+
Style/ClassAndModuleChildren:
|
34
|
+
Enabled: false
|
35
|
+
Style/FrozenStringLiteralComment:
|
36
|
+
Enabled: false
|
37
|
+
Style/StringLiterals:
|
38
|
+
Enabled: false
|
39
|
+
Style/StringLiteralsInInterpolation:
|
40
|
+
Enabled: false
|
41
|
+
Style/Documentation:
|
42
|
+
Enabled: false
|
43
|
+
Style/CommentedKeyword:
|
44
|
+
Enabled: false
|
45
|
+
Style/MultilineBlockChain:
|
46
|
+
Enabled: false
|
47
|
+
Style/AndOr:
|
48
|
+
Enabled: false
|
49
|
+
Style/Alias:
|
50
|
+
EnforcedStyle: prefer_alias_method
|
51
|
+
Style/FetchEnvVar:
|
52
|
+
Enabled: false
|
53
|
+
Style/RegexpLiteral:
|
54
|
+
EnforcedStyle: mixed
|
55
|
+
AllowInnerSlashes: true
|
56
|
+
|
57
|
+
Layout/HashAlignment:
|
58
|
+
EnforcedColonStyle: table
|
59
|
+
EnforcedHashRocketStyle: table
|
60
|
+
Layout/LeadingCommentSpace:
|
61
|
+
Enabled: false
|
62
|
+
AllowGemfileRubyComment: true
|
63
|
+
Layout/ParameterAlignment:
|
64
|
+
Enabled: false
|
65
|
+
Layout/MultilineMethodDefinitionBraceLayout:
|
66
|
+
EnforcedStyle: symmetrical
|
67
|
+
Layout/LineLength:
|
68
|
+
Enabled: true
|
69
|
+
Layout/SpaceInsideHashLiteralBraces:
|
70
|
+
Enabled: false
|
71
|
+
Layout/SpaceInsideBlockBraces:
|
72
|
+
Enabled: false
|
73
|
+
Layout/SpaceAroundOperators:
|
74
|
+
Enabled: false
|
75
|
+
Layout/ExtraSpacing:
|
76
|
+
AllowForAlignment: true
|
77
|
+
AllowBeforeTrailingComments: true
|
78
|
+
Layout/AccessModifierIndentation:
|
79
|
+
EnforcedStyle: indent
|
80
|
+
Layout/DotPosition:
|
81
|
+
EnforcedStyle: trailing
|
82
|
+
Layout/MultilineMethodCallIndentation:
|
83
|
+
EnforcedStyle: indented
|
84
|
+
Layout/FirstHashElementIndentation:
|
85
|
+
Enabled: false
|
86
|
+
Layout/EmptyLineAfterGuardClause:
|
87
|
+
Enabled: false
|
88
|
+
|
89
|
+
Naming/VariableNumber:
|
90
|
+
EnforcedStyle: snake_case
|
91
|
+
CheckSymbols: false
|
92
|
+
Naming/MethodParameterName:
|
93
|
+
AllowedNames: ['x', 'y', 'i', 'j', 'id', 'io', 'to']
|
94
|
+
Naming/RescuedExceptionsVariableName:
|
95
|
+
Enabled: false
|
data/CHANGELOG.md
CHANGED
@@ -1,11 +1,144 @@
|
|
1
1
|
# Change Log
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
-
## [2.
|
4
|
+
## [2.7.0] - 2024-04-xx
|
5
|
+
|
6
|
+
### Added
|
7
|
+
- **support** for node **classifications** on
|
8
|
+
- `Eco::Data::Locations::NodePlain`
|
9
|
+
- `Eco::API::Organization::TagTree`
|
10
|
+
- It `downcase` the classification values
|
11
|
+
- added class `Eco::API::Organization::NodeClassifications`
|
12
|
+
- `#node_classifications` method in `session`, `session.config` and in `config.tagtree`
|
13
|
+
- **validation** helpers via locations base case (`Eco::API::UseCases::GraphQL::Helpers::Location::Base::ClassificationsParser`)
|
14
|
+
- Use case (**made native**)
|
15
|
+
- `-tagtree-upload` => `Eco::API::UseCases::Default::Locations::TagtreeUpload`
|
16
|
+
- it can target specific tree via `-structure-id` cli argument
|
17
|
+
- it has some **optimizations** such as:
|
18
|
+
1. Only backing up the tree once (before)
|
19
|
+
2. Not graphql querying the tree as a response of each batch commands request
|
20
|
+
- Parameter `-file-as-source` for `-tagtree-extract` provided that the case can **convert** input tree csv files into a list of nodes (`Eco::API::UseCases::Default::Locations::TagtreeExtract`)
|
21
|
+
- **Tagtree UPDATE** case helpers. Added three service modules for quickly building **custom tagtree update cases**. See:
|
22
|
+
1. `Eco::API::UseCases::GraphQL::Samples::Location::Service::TreeToList`
|
23
|
+
2. `Eco::API::UseCases::GraphQL::Samples::Location::Service::TreeDiff`
|
24
|
+
3. `Eco::API::UseCases::GraphQL::Samples::Location::Command::Service::TreeUpdate`
|
25
|
+
- `snake_case` helper (at `Eco::Data::Strings::SnakeCase`)
|
26
|
+
- `camel_case` helper (at `Eco::Data::Strings::CamelCase`)
|
27
|
+
- `camel_case` helper (at `Eco::Data::Strings::CamelCase`)
|
28
|
+
- snake vs camel indifferent access helper (at `Eco::Data::Hashes::SnakeCamelIndifferentAccess`)
|
29
|
+
- **Optimization** helper classes to cluster node diffs:
|
30
|
+
- `Eco::Data::Locations::NodeDiff::NodesDiff::ClusteredTreeify`: key helper
|
31
|
+
- `Eco::Data::Locations::NodeDiff::NodesDiff::DiffsTree`: supporting class.
|
32
|
+
- **consistency** (snake vs camel case) on `parentd` for `Eco::Data::Locations::NodeLevel`
|
33
|
+
- `Eco::API::UseCases::GraphQL::Utils::Sftp`
|
34
|
+
- Configurable `remote_folder`
|
35
|
+
- Made **native** location diffs staged command builders
|
36
|
+
- These helpers target ONLY location nodes where the `id` are **codes**
|
37
|
+
- Please notice that composed `id` (i.e. `name - code`) is NOT supported (as there isn't a clean way to update => no batch remap location ids operation available)
|
38
|
+
- **Added** class and namespaces under `Eco::API::UseCases::GraphQL::Helpers::Location::Command`
|
39
|
+
- `Diff`
|
40
|
+
- `Diffs`
|
41
|
+
- **SFTP Helpers** review
|
42
|
+
- `Eco::API::Common::Session::SFTP#upload` added method
|
43
|
+
- `Eco::API::UseCases::GraphQL::Utils::SFTP`
|
44
|
+
- `#sftp_download_files` added method
|
45
|
+
- `#local_folder` for downloading the files
|
46
|
+
- added parameters to the existing methods
|
47
|
+
|
48
|
+
### Changed
|
49
|
+
- **Parsers**
|
50
|
+
- Native **date parser**, added _warning_ when date cannot be parsed
|
51
|
+
- Migrated **select parser** (`Eco::API::Common::People::DefaultParsers::SelectParser`). This change entailed to introduce several changes:
|
52
|
+
- Added _warning_ when select option is unknown.
|
53
|
+
- `Eco::API::Common::People::PersonParser`:
|
54
|
+
1. methods `#parse` and `#serialize` call to the parser/serializer method by using a block to resolve `Proc` call dependencies.
|
55
|
+
2. **added** method `#select_tables` (this has been moved from the _default parsers_ class to the _person parser_ itself)
|
56
|
+
- `Eco::Language::Models::ParserSerializer`
|
57
|
+
- methods `#parse` and `#serialize` can be called with a `block` to resolve dependencies.
|
58
|
+
- `Eco::CSV::Table` the internal method `to_rows_array` was not spliting `Array` values with pipe operator `|`. Made so it does so.
|
59
|
+
- **Note** that `to_array_of_hashes` (the opposite method) does NOT convert them back to `Array` (but it wasn't converting back the array string to its Array version anyway)
|
60
|
+
- **renamed** use case `-export-tree` to `-tagtree-extract`
|
61
|
+
- `Eco::API::UseCases::Default::Locations::TagtreeExtract`
|
62
|
+
- **Improved** `Eco::Data::Locations::NodeLevel` by adding support for `classifications` and `classification_names`
|
63
|
+
- It just catches the **original header** names, and uses them
|
64
|
+
- **Note** that these headers may NOT be actual classifications, but just conventional header names. For this reason, it is **required** that there is a **parse** function that **validates** that they are **actual classifications**
|
65
|
+
- `Eco::API::Organization::TagTree`
|
66
|
+
- **changed** `as_json` serialization on **classifications** (it serializes to a `dup` of the `Array` now) - ceased to ~~`join('|')`~~
|
67
|
+
- **changed** `as_json`. It now includes `level` (`depth + 1`)
|
68
|
+
- **Optimized** life cycle of applying commands to _locations structures_
|
69
|
+
- This optimization is based on **NOT retrieving** the full locations structure on each request (_apply commands payload block_ on **graphql**). This also entails that the number of **backups** per run is drastically minimized.
|
70
|
+
- `Eco::API::UseCases::GraphQL::Helpers::Location::Command::DSL`
|
71
|
+
- **Added** `#batch_tree_track_mode` to define what tracking mode would be used at each commands stage.
|
72
|
+
- The only stage that tracks/backes-up the tree on each request is now `:id` (or `:id_name`) -> remap location ids _integrity check_ purposes (which is actually somehow redundant; just an additional measure in place).
|
73
|
+
- `Eco::API::UseCases::GraphQL::Helpers::Location::Command`
|
74
|
+
- `#sliced_batches`
|
75
|
+
- **added** parameter `track_tree_mode:`
|
76
|
+
- **before** final call to `apply_commands`, it scopes the payload `block` of the request (using the new custom method `scope_commands_block`, see below)
|
77
|
+
- Decoupled re-configurable (**overridable**) methods into `Optimizations` sub-space: `Eco::API::UseCases::GraphQL::Helpers::Location::Command::Optimizations`
|
78
|
+
- `#default_tree_tracking_mode` the fallback tracking mode (besides `#batch_tree_track_mode` on `DLS`)
|
79
|
+
- `#scope_commands_block` based on the current tree tracking mode, it scopes what the block for the apply commands payload will be
|
80
|
+
- `#commands_payload_without_structure_block`: sample graphql payload block that does NOT retrieve the locations structure (**optimization lies here**)
|
81
|
+
- `Eco::API::UseCases::GraphQL::Samples::Location::Command::Results`
|
82
|
+
- **Decoupled** tracking of changed ids into `Eco::API::UseCases::GraphQL::Samples::Location::Command::TrackChangedIds`
|
83
|
+
- `#update_tags_remap_table` -> remove `:move` stage tracking
|
84
|
+
- As content only has the lowest level location node, moving does **NOT** entail remapping locations any longer (there isn't full path on content at this stage; after `RS P3` release)
|
85
|
+
- `Eco::Data::Locations::NodeDiff`
|
86
|
+
- `archived?` added parameter for **validation** (default `true`)
|
87
|
+
- `attr_expose`
|
88
|
+
- It adds `_prev` as a postfix (**removed** as a prefix ~~`prev_`~~)
|
89
|
+
- It uses the question mark `?` alone (**removed** ~~`diff_`~~ prefix)
|
90
|
+
- **added** all these methods support now `snake_case`
|
91
|
+
- **BREAKING** change to move onto **RS P3 post-release**
|
92
|
+
- A change of `name?` **WON'T** trigger a change of `id` (`nodeId`) any more
|
93
|
+
- For this reason, identification on changes on the `id` will be besides changes of the `name`
|
94
|
+
- `Eco::Data::Locations::NodeDiff::NodesDiff`- **Important change** on `#diffs` (core property)
|
95
|
+
- It now discards diffs that `insert?` and `archive?` as well, provided that they do not generate updates
|
96
|
+
- **Note** that this limiation may be a drawback when we aim to import historical location nodes that should be in the org (for import purposes) but that are not active locations. The way **around it** is to just use an input where the `archived` property is `false` (later on launch those again with `archived` true, but lets do a good input data integrity check here)
|
97
|
+
- `Eco::Data::Hashes::DiffResult`
|
98
|
+
- moved `Meta` under its namespace
|
99
|
+
- created _private_ unique points to access source hashes. This will allows to extend the behaviour from child classes
|
100
|
+
- **Moved** hash accessors (**DSL**) to `Eco::Data::Hashes::DiffResult::Meta`
|
101
|
+
- also **added** method `key_present?`
|
102
|
+
- **improved** `slice_attrs` to return `nil` if `src` isn't present.
|
103
|
+
- **added** `Array` comparizon via `eq?` method.
|
104
|
+
- (Class) **Added** named arg `when_present` to `compare` class method.
|
105
|
+
- (Instance) **Removed** unused method `compared_attrs`
|
106
|
+
- **Replaced by** `all_compared_attrs`
|
107
|
+
- (Class) **Added** `compared_attrs_when_present`
|
108
|
+
- (Instance) **Added** `comparable_attr?`, which based on `all_compared_attrs` (instance method) checks if `attr` is required for presence on both source hashes (`src_1` and `src_2`)
|
109
|
+
- This is supported by the **new** method `key_present_in_both?`
|
110
|
+
- (Instance) **Modified** behaviour on `diff_attrs` provided that takes into consideration if an `attr` is **comparable** (`comparable_attr?`)
|
111
|
+
- upgrade **gems** `ecoportal-api-v2` and `ecoportal-api-graphql`
|
112
|
+
- this brings some optimizations when treeifying locations structures
|
113
|
+
- `Eco::Data::Hashes::ArrayDiff`
|
114
|
+
- **Removed** unused method `compared_attrs`
|
115
|
+
|
116
|
+
### Fixed
|
117
|
+
- upgrade `ecoportal-api-v2` **gem**
|
118
|
+
- A bunch of small things on the `Eco::Data::Locations` namespace
|
119
|
+
- `Eco::API::Session::Config#live_trees` to choose a tree when only one
|
120
|
+
- `Eco::API::UseCases::GraphQL::Helpers::Location::Base`
|
121
|
+
- `tagtree_id` method should `map` values rather than `select` keys on `options`
|
122
|
+
- `Eco::Data::Locations::NodeDiff::NodesDiff`
|
123
|
+
- fix `diffs_summary` lining
|
124
|
+
- `Eco::Language::Methods::DslAble`
|
125
|
+
- explicit behaviour for `respond_to_missing?` (dsl doesn't need to allow method capturing via `method` call)
|
126
|
+
- add `__FILE__` and `__LINE__` to error backtrace on `eval`
|
127
|
+
- Parsing `archived` value in
|
128
|
+
- `Eco::API::Organization::TagTree`
|
129
|
+
- `Eco::Data::Locations::NodePlain`
|
130
|
+
|
131
|
+
## [2.6.4] - 2024-03-06
|
5
132
|
|
6
|
-
### Added
|
7
133
|
### Changed
|
134
|
+
- updated core **gem** `ecoportal-api`
|
135
|
+
- The `subordinates` core people property has been removed from the back-end
|
136
|
+
- This was due to some performance issues with org hierarchy model.
|
137
|
+
- As a consequence a temporary patch has been added temporarily in the current gem.
|
138
|
+
|
8
139
|
### Fixed
|
140
|
+
- `Eco::API::UseCases::OozeSamples::RegisterUpdateCase`
|
141
|
+
- initialize `@total_search_results`
|
9
142
|
|
10
143
|
## [2.6.3] - 2024-02-29
|
11
144
|
|
data/Rakefile
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
require 'rubocop/rake_task'
|
4
|
+
require 'yard'
|
5
|
+
require 'redcarpet'
|
5
6
|
|
6
7
|
desc "run the specs"
|
7
8
|
RSpec::Core::RakeTask.new(:spec)
|
@@ -10,11 +11,13 @@ desc "run rspec showing backtrace"
|
|
10
11
|
RSpec::Core::RakeTask.new(:spec_trace) do |task|
|
11
12
|
task.rspec_opts = ['--backtrace']
|
12
13
|
end
|
14
|
+
task(rspec_trace: :spec_trace)
|
13
15
|
|
14
16
|
desc "run rspec stopping on first fail, and show backtrace"
|
15
17
|
RSpec::Core::RakeTask.new(:spec_fast) do |task|
|
16
18
|
task.rspec_opts = ['--fail-fast', '--backtrace']
|
17
19
|
end
|
20
|
+
task(rspec_fast: :spec_fast)
|
18
21
|
|
19
22
|
# default task name is yard
|
20
23
|
desc "Yard: generate all the documentation"
|
@@ -22,6 +25,9 @@ YARD::Rake::YardocTask.new(:doc) do |t|
|
|
22
25
|
#t.files = ['lib/**/*.rb']
|
23
26
|
end
|
24
27
|
|
25
|
-
|
26
|
-
task :
|
27
|
-
|
28
|
+
desc "default task: runs rubocop and rspec"
|
29
|
+
task :default do
|
30
|
+
Rake::Task[:rubocop].invoke
|
31
|
+
ensure
|
32
|
+
Rake::Task[:spec].invoke
|
33
|
+
end
|
data/eco-helpers.gemspec
CHANGED
@@ -30,9 +30,9 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.add_development_dependency "yard", ">= 0.9.34", "< 1"
|
31
31
|
spec.add_development_dependency "redcarpet", ">= 3.6.0", "< 4"
|
32
32
|
|
33
|
-
spec.add_dependency 'ecoportal-api', '>= 0.9.
|
34
|
-
spec.add_dependency 'ecoportal-api-v2', '>= 1.1.
|
35
|
-
spec.add_dependency 'ecoportal-api-graphql', '>= 0.3.
|
33
|
+
spec.add_dependency 'ecoportal-api', '>= 0.9.7', '< 0.10'
|
34
|
+
spec.add_dependency 'ecoportal-api-v2', '>= 1.1.8', '< 1.2'
|
35
|
+
spec.add_dependency 'ecoportal-api-graphql', '>= 0.3.15', '< 0.4'
|
36
36
|
spec.add_dependency 'aws-sdk-s3', '>= 1.142.0', '< 2'
|
37
37
|
spec.add_dependency 'aws-sdk-ses', '>= 1.58.0', '< 2'
|
38
38
|
spec.add_dependency 'dotenv', '>= 2.8.1', '< 3'
|
@@ -14,7 +14,7 @@ module Eco
|
|
14
14
|
|
15
15
|
# If still not set, it sets the `created_at` class timestamp.
|
16
16
|
def set_created_at!
|
17
|
-
@created_at
|
17
|
+
@created_at ||= Time.now unless @created_at # rubocop:disable Naming/MemoizedInstanceVariableName
|
18
18
|
end
|
19
19
|
|
20
20
|
# Class creation timestamp, to be able to load them in the order they were declared.
|
@@ -33,7 +33,7 @@ module Eco
|
|
33
33
|
private
|
34
34
|
|
35
35
|
def simulate?
|
36
|
-
options
|
36
|
+
options[:simulate] || options[:dry_run]
|
37
37
|
end
|
38
38
|
alias_method :dry_run?, :simulate?
|
39
39
|
|
@@ -5,7 +5,7 @@ class Eco::API::Common::Loaders::Workflow::Mailer < Eco::API::Common::Loaders::W
|
|
5
5
|
inheritable_class_vars :config_block
|
6
6
|
|
7
7
|
config_block do
|
8
|
-
puts "running from class #{self}"
|
8
|
+
#puts "running from class #{self}"
|
9
9
|
exception do |err, io|
|
10
10
|
self.error = err
|
11
11
|
log(:debug) { err.patch_full_message }
|
@@ -13,9 +13,9 @@ class Eco::API::Common::Loaders::Workflow::Mailer < Eco::API::Common::Loaders::W
|
|
13
13
|
end
|
14
14
|
|
15
15
|
after(:close) do |_wf, io|
|
16
|
-
next if
|
16
|
+
next if options.dig(:workflow, :no_email)
|
17
17
|
next unless session.mailer?
|
18
|
-
next if
|
18
|
+
next if session.config.dry_run?
|
19
19
|
next unless session.config.run_mode_remote?
|
20
20
|
next unless some_update?(io) || error?
|
21
21
|
|
@@ -49,7 +49,7 @@ class Eco::API::Common::Loaders::Workflow::Mailer < Eco::API::Common::Loaders::W
|
|
49
49
|
|
50
50
|
def some_update?(io)
|
51
51
|
cli.config.usecases.active(io: io).any? do |usecase, data|
|
52
|
-
[
|
52
|
+
%i[transform sync].any? { |type| usecase.type == type }
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
@@ -62,7 +62,7 @@ class Eco::API::Common::Loaders::Workflow::Mailer < Eco::API::Common::Loaders::W
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def log_err_n_warn(io)
|
65
|
-
warn_errors = io.logger.cache.logs(level: [
|
65
|
+
warn_errors = io.logger.cache.logs(level: %i[error warn])
|
66
66
|
return if warn_errors.empty?
|
67
67
|
"WARNINGS & ERRORS:\n#{warn_errors.join('')}\n"
|
68
68
|
end
|
@@ -9,7 +9,8 @@ module Eco
|
|
9
9
|
# @return [Eco::API::Error] the error class, child of `Eco::API::Error`.
|
10
10
|
def error(value = nil)
|
11
11
|
unless value
|
12
|
-
|
12
|
+
msg = "You should specify an error type for #{self.class}"
|
13
|
+
return @error || (raise msg)
|
13
14
|
end
|
14
15
|
@error = value
|
15
16
|
end
|
@@ -17,9 +18,11 @@ module Eco
|
|
17
18
|
|
18
19
|
inheritable_class_vars :error
|
19
20
|
|
20
|
-
def initialize(handlers)
|
21
|
-
|
22
|
-
handlers.
|
21
|
+
def initialize(handlers) # rubocop:disable Lint/MissingSuper
|
22
|
+
msg = "Expected Eco::API::Policies. Given #{handlers.class}"
|
23
|
+
raise msg unless handlers.is_a?(Eco::API::Error::Handlers)
|
24
|
+
|
25
|
+
handlers.on(error, &method(:main))
|
23
26
|
end
|
24
27
|
|
25
28
|
# @param people [Eco::API::Organization::People] the people in the queue of the current `job`
|
@@ -27,7 +30,7 @@ module Eco
|
|
27
30
|
# @param options [Hash] the options that modify the case behaviour or bring some dependencies.
|
28
31
|
# @param handler [Eco::API::Error::Hanlder] the `error handler` instance object.
|
29
32
|
# @param job [Eco::API::Session::Batch::Job] the `Batch::Job` made on purpose for this handler.
|
30
|
-
def main(people, session, options, handler, job)
|
33
|
+
def main(people, session, options, handler, job) # rubocop:disable Lint/UnusedMethodArgument
|
31
34
|
raise "You should implement this method"
|
32
35
|
end
|
33
36
|
|
@@ -4,7 +4,7 @@ module Eco
|
|
4
4
|
module Loaders
|
5
5
|
class Parser < Eco::API::Common::Loaders::CaseBase
|
6
6
|
# Helper class to scope what required attributes it depends on
|
7
|
-
|
7
|
+
RequiredAttrs = Struct.new(:attr, :type, :attrs) do
|
8
8
|
def active?(*input_attrs)
|
9
9
|
missing(*input_attrs).empty?
|
10
10
|
end
|
@@ -33,7 +33,9 @@ module Eco
|
|
33
33
|
# @return [String] the `type` of usecase (i.e. `:sync`, `:transform`, `:import`, `:other`)
|
34
34
|
def attribute(value = nil)
|
35
35
|
unless value
|
36
|
-
|
36
|
+
msg = "You should specify the 'attribute' this parser/serializer, "
|
37
|
+
msg << "#{self.class}, is linked to"
|
38
|
+
return @attribute || (raise msg)
|
37
39
|
end
|
38
40
|
name value
|
39
41
|
@attribute = value
|
@@ -42,9 +44,13 @@ module Eco
|
|
42
44
|
# Some parsers require dependencies to do their job.
|
43
45
|
def dependencies(**value)
|
44
46
|
@dependencies ||= {}
|
45
|
-
|
46
|
-
|
47
|
-
|
47
|
+
|
48
|
+
if value.empty?
|
49
|
+
return @dependencies.merge({
|
50
|
+
required_attrs: @active_when_attrs
|
51
|
+
})
|
52
|
+
end
|
53
|
+
|
48
54
|
raise "Expected Hash. Given: '#{value.class}'" unless value.is_a?(Hash)
|
49
55
|
@dependencies.merge!(value)
|
50
56
|
end
|
@@ -70,7 +76,7 @@ module Eco
|
|
70
76
|
# Helper to build the `active_when` condition.
|
71
77
|
def active_when_any(*attrs)
|
72
78
|
@active_when_attrs = RequiredAttrs.new(attribute, :any, attrs)
|
73
|
-
@active_when =
|
79
|
+
@active_when = proc do |source_data|
|
74
80
|
keys = data_keys(source_data)
|
75
81
|
attrs.any? {|key| keys.include?(key)}
|
76
82
|
end
|
@@ -79,7 +85,7 @@ module Eco
|
|
79
85
|
# Helper to build the `active_when` condition.
|
80
86
|
def active_when_all(*attrs)
|
81
87
|
@active_when_attrs = RequiredAttrs.new(attribute, :all, attrs)
|
82
|
-
@active_when =
|
88
|
+
@active_when = proc do |source_data|
|
83
89
|
keys = data_keys(source_data)
|
84
90
|
attrs.all? {|key| keys.include?(key)}
|
85
91
|
end
|
@@ -88,40 +94,46 @@ module Eco
|
|
88
94
|
private
|
89
95
|
|
90
96
|
# Helper to obtain the current internal named attributes of the data
|
91
|
-
# @param source_data [Array<String>, Hash] if `Array` those
|
97
|
+
# @param source_data [Array<String>, Hash] if `Array` those
|
98
|
+
# are already the `keys`, if `Hash` it gets the `keys`
|
92
99
|
# @return [Array<String>] `keys` of `source_data`
|
93
100
|
def data_keys(source_data)
|
94
101
|
case source_data
|
95
102
|
when Array
|
96
|
-
|
103
|
+
source_data
|
97
104
|
when Hash
|
98
|
-
|
105
|
+
source_data.keys
|
99
106
|
else
|
100
|
-
|
107
|
+
[]
|
101
108
|
end
|
102
109
|
end
|
103
110
|
end
|
104
111
|
|
105
112
|
inheritable_class_vars :attribute, :parsing_phase, :serializing_phase
|
106
113
|
|
107
|
-
def initialize(person_parser)
|
108
|
-
|
109
|
-
person_parser.
|
114
|
+
def initialize(person_parser) # rubocop:disable Lint/MissingSuper
|
115
|
+
msg = "Expected Eco::API::Common::People::PersonParser. Given #{person_parser.class}"
|
116
|
+
raise msg unless person_parser.is_a?(Eco::API::Common::People::PersonParser)
|
117
|
+
|
118
|
+
person_parser.define_attribute(attribute, dependencies: self.class.dependencies) do |attr_parser|
|
110
119
|
_define_parser(attr_parser)
|
111
120
|
_define_serializer(attr_parser)
|
112
121
|
end
|
113
122
|
end
|
114
123
|
|
115
124
|
# @param data [Hash] all the person data at the specified `parsing_phase`:
|
116
|
-
# - when `:internal`: the parser will receive external types
|
117
|
-
#
|
125
|
+
# - when `:internal`: the parser will receive external types
|
126
|
+
# (i.e. String with '|' delimiters instead of an Array).
|
127
|
+
# - when `:final`: the parser will receive the typed values
|
128
|
+
# (i.e. Array instread of String with '|' delimiters).
|
118
129
|
# @param deps [Hash] the merged dependencies (default to the class object and when calling the parser).
|
119
|
-
def parser(
|
130
|
+
def parser(_data, _deps)
|
120
131
|
raise "You should implement this method"
|
121
132
|
end
|
122
133
|
|
123
134
|
# @param data [Hash, Ecoportal::API::V1::Person] all the person data at the specified `serializing_phase`:
|
124
|
-
# - when `:internal`: it will receive a `Hash` with the **internal values** but the types already serialized
|
135
|
+
# - when `:internal`: it will receive a `Hash` with the **internal values** but the types already serialized
|
136
|
+
# to `String`.
|
125
137
|
# - when `:final`: it will receive a `Hash` with the **internal values** and **types**.
|
126
138
|
# - when `:person`: it will receive the `person` object.
|
127
139
|
# @param deps [Hash] the merged dependencies (default to the class object and when calling the parser).
|
@@ -137,16 +149,26 @@ module Eco
|
|
137
149
|
private
|
138
150
|
|
139
151
|
def _define_parser(attr_parser)
|
140
|
-
if active_when = self.class.active_when
|
141
|
-
attr_parser.def_parser(
|
152
|
+
if (active_when = self.class.active_when)
|
153
|
+
attr_parser.def_parser(
|
154
|
+
self.class.parsing_phase,
|
155
|
+
active_when: active_when,
|
156
|
+
&method(:parser)
|
157
|
+
)
|
142
158
|
else
|
143
|
-
attr_parser.def_parser(
|
159
|
+
attr_parser.def_parser(
|
160
|
+
self.class.parsing_phase,
|
161
|
+
&method(:parser)
|
162
|
+
)
|
144
163
|
end
|
145
164
|
end
|
146
165
|
|
147
166
|
def _define_serializer(attr_parser)
|
148
167
|
return unless respond_to?(:serializer, true)
|
149
|
-
attr_parser.def_serializer(
|
168
|
+
attr_parser.def_serializer(
|
169
|
+
self.class.serializing_phase,
|
170
|
+
&method(:serializer)
|
171
|
+
)
|
150
172
|
end
|
151
173
|
end
|
152
174
|
end
|
@@ -3,9 +3,11 @@ module Eco
|
|
3
3
|
module Common
|
4
4
|
module Loaders
|
5
5
|
class Policy < Eco::API::Common::Loaders::CaseBase
|
6
|
-
def initialize(policies)
|
7
|
-
|
8
|
-
policies.
|
6
|
+
def initialize(policies) # rubocop:disable Lint/MissingSuper
|
7
|
+
msg = "Expected Eco::API::Policies. Given #{policies.class}"
|
8
|
+
raise msg unless policies.is_a?(Eco::API::Policies)
|
9
|
+
|
10
|
+
policies.define(name, &method(:main))
|
9
11
|
end
|
10
12
|
|
11
13
|
# @param people [Eco::API::Organization::People] the people in the queue of the current `job`
|
@@ -13,7 +15,7 @@ module Eco
|
|
13
15
|
# @param options [Hash] the options that modify the case behaviour or bring some dependencies.
|
14
16
|
# @param policy [Eco::API::Policies::Policy] the `policy` instance object.
|
15
17
|
# @param job [Eco::API::Session::Batch::Job] the `Batch::Job` that these `people` belong to the queue thereof.
|
16
|
-
def main(people, session, options, policy, job)
|
18
|
+
def main(people, session, options, policy, job) # rubocop:disable Lint/UnusedMethodArgument
|
17
19
|
raise "You should implement this method"
|
18
20
|
end
|
19
21
|
end
|
@@ -7,7 +7,9 @@ module Eco
|
|
7
7
|
# @return [Symbol] the `type` of usecase (i.e. `:sync`, `:transform`, `:import`, `:other`)
|
8
8
|
def type(value = nil)
|
9
9
|
unless value
|
10
|
-
|
10
|
+
msg = "You should specify a type of case "
|
11
|
+
msg << "[:sync, :transform, :import, :other] for #{self}"
|
12
|
+
return @type || (raise msg)
|
11
13
|
end
|
12
14
|
@type = value
|
13
15
|
end
|
@@ -18,13 +20,15 @@ module Eco
|
|
18
20
|
|
19
21
|
def cli(cli_class = nil)
|
20
22
|
if cli_class.is_a?(Class)
|
21
|
-
|
23
|
+
msg = "cli_class should inherit from Eco::API::UseCases::Cli"
|
24
|
+
raise ArgumentError, msg unless cli_class < Eco::API::UseCases::Cli
|
25
|
+
|
22
26
|
@cli = cli_class
|
23
27
|
elsif cli_class.nil?
|
24
28
|
return @cli if instance_variable_defined?(:@cli) && !@cli.nil?
|
25
29
|
# try to see if it's namespaced after the use case it provisions cli integration
|
26
30
|
begin
|
27
|
-
try_class = [
|
31
|
+
try_class = [to_s, 'Cli'].join('::')
|
28
32
|
@cli = Kernel.const_get(try_class)
|
29
33
|
rescue NameError
|
30
34
|
nil
|
@@ -37,9 +41,11 @@ module Eco
|
|
37
41
|
|
38
42
|
inheritable_class_vars :type, :cli
|
39
43
|
|
40
|
-
def initialize(usecases)
|
41
|
-
|
42
|
-
|
44
|
+
def initialize(usecases) # rubocop:disable Lint/MissingSuper
|
45
|
+
msg = "Expected Eco::API::UseCases. Given #{usecases.class}"
|
46
|
+
raise msg unless usecases.is_a?(Eco::API::UseCases)
|
47
|
+
|
48
|
+
usecases.define(name, type: type, &method(:main))
|
43
49
|
end
|
44
50
|
|
45
51
|
# The parameters of this method will depend on the `type` of usecase.
|
@@ -48,7 +54,7 @@ module Eco
|
|
48
54
|
# @param session [Eco::API::Session] the current session where the usecase kicks in.
|
49
55
|
# @param options [Hash] the options that modify the case behaviour or bring some dependencies.
|
50
56
|
# @param usecase [Eco::API::Policies::Policy] the `usecase` instance object.
|
51
|
-
def main(entries, people, session, options, usecase)
|
57
|
+
def main(entries, people, session, options, usecase) # rubocop:disable Lint/UnusedMethodArgument
|
52
58
|
raise "You should implement this method"
|
53
59
|
end
|
54
60
|
|
@@ -2,7 +2,6 @@ module Eco
|
|
2
2
|
module API
|
3
3
|
module Common
|
4
4
|
module People
|
5
|
-
|
6
5
|
# @example Example of usage:
|
7
6
|
# class ExampleParser < Eco::API::Common::People::BaseParser
|
8
7
|
# def process
|
@@ -26,7 +25,6 @@ module Eco
|
|
26
25
|
# Helper class to inherit from to ease the definition of attribute parsers in a `PersonParser` object,
|
27
26
|
# mostly used in for configuration loading.
|
28
27
|
class BaseParser
|
29
|
-
|
30
28
|
# @param parsers [Eco::API::Common::People::PersonParser] set of attribute parsers/serialisers.
|
31
29
|
# @param options [Hash] keyword arguments to be used in the `process` method of the child class.
|
32
30
|
def initialize(parsers, **options)
|