eco-helpers 2.5.10 → 2.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -2
  3. data/CHANGELOG.md +132 -4
  4. data/README.md +5 -0
  5. data/eco-helpers.gemspec +20 -16
  6. data/lib/eco/api/common/class_helpers.rb +1 -1
  7. data/lib/eco/api/common/loaders/base.rb +2 -9
  8. data/lib/eco/api/common/loaders/case_base.rb +0 -2
  9. data/lib/eco/api/common/loaders/config/workflow/mailer.rb +78 -0
  10. data/lib/eco/api/common/loaders/config/workflow.rb +11 -0
  11. data/lib/eco/api/common/loaders/config.rb +29 -0
  12. data/lib/eco/api/common/loaders/error_handler.rb +0 -2
  13. data/lib/eco/api/common/loaders/parser.rb +0 -1
  14. data/lib/eco/api/common/loaders/policy.rb +0 -2
  15. data/lib/eco/api/common/loaders/use_case.rb +27 -1
  16. data/lib/eco/api/common/loaders.rb +1 -0
  17. data/lib/eco/api/common/people/default_parsers.rb +2 -2
  18. data/lib/eco/api/common/people/person_entry.rb +3 -0
  19. data/lib/eco/api/common/people/person_entry_attribute_mapper.rb +111 -16
  20. data/lib/eco/api/common/session/base_session.rb +4 -0
  21. data/lib/eco/api/common/session/environment.rb +4 -0
  22. data/lib/eco/api/common/session/mailer.rb +3 -1
  23. data/lib/eco/api/common/session/sftp.rb +1 -1
  24. data/lib/eco/api/common/version_patches/exception.rb +2 -2
  25. data/lib/eco/api/common/version_patches/ruby3/object.rb +18 -0
  26. data/lib/eco/api/common/version_patches/ruby3.rb +1 -0
  27. data/lib/eco/api/common/version_patches.rb +3 -0
  28. data/lib/eco/api/custom/config.rb +10 -0
  29. data/lib/eco/api/custom/mailer.rb +9 -0
  30. data/lib/eco/api/custom/namespace.rb +2 -0
  31. data/lib/eco/api/custom/workflow.rb +9 -0
  32. data/lib/eco/api/custom.rb +3 -0
  33. data/lib/eco/api/organization/tag_tree.rb +20 -23
  34. data/lib/eco/api/session/batch/base_policy.rb +13 -5
  35. data/lib/eco/api/session/batch/job.rb +14 -11
  36. data/lib/eco/api/session/batch/jobs.rb +2 -2
  37. data/lib/eco/api/session/batch/jobs_groups.rb +2 -2
  38. data/lib/eco/api/session/config/files.rb +2 -2
  39. data/lib/eco/api/session/config/people.rb +2 -2
  40. data/lib/eco/api/session/config/sftp.rb +4 -0
  41. data/lib/eco/api/session/config/tagtree.rb +9 -8
  42. data/lib/eco/api/session/config/workflow.rb +95 -58
  43. data/lib/eco/api/session/config.rb +9 -2
  44. data/lib/eco/api/session.rb +17 -2
  45. data/lib/eco/api/usecases/base_io.rb +50 -4
  46. data/lib/eco/api/usecases/cli/dsl.rb +94 -0
  47. data/lib/eco/api/usecases/cli/option.rb +19 -0
  48. data/lib/eco/api/usecases/cli.rb +13 -0
  49. data/lib/eco/api/usecases/default/locations/cli/tagtree_extract_cli.rb +29 -0
  50. data/lib/eco/api/usecases/{default_cases → default/locations}/codes_to_tags_case.rb +1 -1
  51. data/lib/eco/api/usecases/{default_cases → default/locations}/create_tag_paths_case.rb +1 -1
  52. data/lib/eco/api/usecases/{default_cases → default/locations}/csv_to_tree_case.rb +1 -1
  53. data/lib/eco/api/usecases/default/locations/tagtree_extract_case.rb +181 -0
  54. data/lib/eco/api/usecases/default/locations.rb +15 -0
  55. data/lib/eco/api/usecases/{default_cases → default/people}/analyse_people_case.rb +1 -1
  56. data/lib/eco/api/usecases/{default_cases → default/people}/change_email_case.rb +1 -1
  57. data/lib/eco/api/usecases/default/people/clean_unknown_tags_case.rb +66 -0
  58. data/lib/eco/api/usecases/{default_cases → default/people}/clear_abilities_case.rb +1 -1
  59. data/lib/eco/api/usecases/{default_cases → default/people}/org_data_convert_case.rb +1 -1
  60. data/lib/eco/api/usecases/{default_cases → default/people}/refresh_case.rb +1 -1
  61. data/lib/eco/api/usecases/{default_cases → default/people}/reinvite_sync_case.rb +1 -1
  62. data/lib/eco/api/usecases/{default_cases → default/people}/reinvite_trans_case.rb +1 -1
  63. data/lib/eco/api/usecases/default/people/reinvite_trans_cli.rb +5 -0
  64. data/lib/eco/api/usecases/{default_cases → default/people}/restore_db_case.rb +1 -1
  65. data/lib/eco/api/usecases/{default_cases → default/people}/set_default_tag_case.rb +1 -1
  66. data/lib/eco/api/usecases/{default_cases → default/people}/supers_cyclic_identify_case.rb +1 -1
  67. data/lib/eco/api/usecases/{default_cases → default/people}/supers_hierarchy_case.rb +1 -1
  68. data/lib/eco/api/usecases/{default_cases → default/people}/switch_supervisor_case.rb +1 -1
  69. data/lib/eco/api/usecases/{default_cases → default/people}/transfer_account_case.rb +1 -1
  70. data/lib/eco/api/usecases/default/people.rb +25 -0
  71. data/lib/eco/api/usecases/default.rb +16 -0
  72. data/lib/eco/api/usecases/default_cases/samples/cli/sftp_cli.rb +46 -0
  73. data/lib/eco/api/usecases/default_cases/samples/sftp_case.rb +21 -9
  74. data/lib/eco/api/usecases/default_cases.rb +2 -30
  75. data/lib/eco/api/usecases/graphql/helpers/location/base.rb +1 -2
  76. data/lib/eco/api/usecases/graphql/utils/sftp.rb +1 -1
  77. data/lib/eco/api/usecases/ooze_samples/register_update_case.rb +3 -3
  78. data/lib/eco/api/usecases/use_case.rb +31 -7
  79. data/lib/eco/api/usecases/use_case_chain.rb +2 -2
  80. data/lib/eco/api/usecases.rb +4 -1
  81. data/lib/eco/assets.rb +3 -5
  82. data/lib/eco/cli/config/filters/people_filters.rb +0 -1
  83. data/lib/eco/cli/config/filters.rb +2 -6
  84. data/lib/eco/cli/config/help.rb +0 -1
  85. data/lib/eco/cli/config/input.rb +0 -1
  86. data/lib/eco/cli/config/options_set.rb +3 -4
  87. data/lib/eco/cli/config/use_cases.rb +13 -6
  88. data/lib/eco/cli/config.rb +4 -5
  89. data/lib/eco/cli/scripting/args_helpers.rb +1 -1
  90. data/lib/eco/cli/scripting/argument.rb +0 -1
  91. data/lib/eco/cli/scripting/arguments.rb +0 -2
  92. data/lib/eco/cli.rb +0 -1
  93. data/lib/eco/{cli/config/default → cli_default}/input_filters.rb +0 -1
  94. data/lib/eco/{cli/config/default → cli_default}/people_filters.rb +0 -1
  95. data/lib/eco/{cli/config/default → cli_default}/usecases.rb +2 -52
  96. data/lib/eco/cli_default/workflow.rb +171 -0
  97. data/lib/eco/cli_default.rb +13 -0
  98. data/lib/eco/csv/table.rb +0 -1
  99. data/lib/eco/data/files/encoding.rb +1 -1
  100. data/lib/eco/data/files/helpers.rb +1 -1
  101. data/lib/eco/data/locations/convert.rb +8 -4
  102. data/lib/eco/data/locations/node_base/csv_convert.rb +4 -4
  103. data/lib/eco/data/locations/node_base/tag_validations.rb +19 -9
  104. data/lib/eco/data/locations/node_base/treeify.rb +193 -18
  105. data/lib/eco/data/locations/node_level.rb +1 -1
  106. data/lib/eco/data/locations/node_plain/parsing.rb +1 -1
  107. data/lib/eco/data/locations/node_plain/serial.rb +1 -1
  108. data/lib/eco/data/locations/node_plain.rb +4 -3
  109. data/lib/eco/data/mapper.rb +6 -1
  110. data/lib/eco/language/klass/when_inherited.rb +17 -0
  111. data/lib/eco/language/klass.rb +8 -0
  112. data/lib/eco/language/methods/delegate_missing.rb +28 -0
  113. data/lib/eco/language/methods/dsl_able.rb +25 -0
  114. data/lib/eco/language/methods.rb +9 -0
  115. data/lib/eco/language.rb +2 -0
  116. data/lib/eco/version.rb +1 -1
  117. metadata +169 -79
  118. data/lib/eco/api/usecases/default_cases/abstract_policygroup_abilities_case.rb +0 -160
  119. data/lib/eco/api/usecases/default_cases/append_usergroups_case.rb +0 -14
  120. data/lib/eco/api/usecases/default_cases/clean_unknown_tags_case.rb +0 -74
  121. data/lib/eco/api/usecases/default_cases/create_details_case.rb +0 -20
  122. data/lib/eco/api/usecases/default_cases/create_details_with_supervisor_case.rb +0 -21
  123. data/lib/eco/api/usecases/default_cases/email_as_id_case.rb +0 -12
  124. data/lib/eco/api/usecases/default_cases/new_email_case.rb +0 -13
  125. data/lib/eco/api/usecases/default_cases/new_id_case.rb +0 -12
  126. data/lib/eco/api/usecases/default_cases/remove_account_sync_case.rb +0 -10
  127. data/lib/eco/api/usecases/default_cases/remove_account_trans_case.rb +0 -16
  128. data/lib/eco/api/usecases/default_cases/reset_landing_page_case.rb +0 -18
  129. data/lib/eco/api/usecases/default_cases/set_supervisor_case.rb +0 -16
  130. data/lib/eco/api/usecases/default_cases/tagtree_case.rb +0 -42
  131. data/lib/eco/api/usecases/default_cases/update_details_case.rb +0 -15
  132. data/lib/eco/cli/config/default/workflow.rb +0 -188
  133. data/lib/eco/cli/config/default.rb +0 -16
  134. /data/lib/eco/{cli/config/default → cli_default}/input.rb +0 -0
  135. /data/lib/eco/{cli/config/default → cli_default}/options.rb +0 -0
  136. /data/lib/eco/{cli/config/default → cli_default}/people.rb +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8e5eed9a7b386a3461b4fad2d842d183ccec984eae4149104a2943bda6b84885
4
- data.tar.gz: c19b0aa7ba31b41069f4afba73edcd1354e80ecc60aa668aba124ea4960eca1c
3
+ metadata.gz: c5b781e23d7538417c84762d636b8e10281adce9e5228cef561edf199aba5334
4
+ data.tar.gz: ab7284a1124a8bece11d8d72e8bdc2f532d746e1da3cfdc264270885d6f867d9
5
5
  SHA512:
6
- metadata.gz: c83534044499d6a1561cbf5f21f038ec2f03e3a458178555c3b14c87e50e6c9f6d938f960586bae7f04e1ee152aab7c83b34f8f2752eca8d8ca94b9e97faf46f
7
- data.tar.gz: 401d2226b3f02ab5b5d67ebddf75498b918bec22ea85bc405c48aee4ea50c32dad56abb230a91a88eabc0a7fa6d448683ef09a3dedd788e8ec61a11d36a258c3
6
+ metadata.gz: eb069c529b1f318f700672676178c52921b06dcaf2600c1b0f6c3ab5b388f781c17630a0ae4d0b815f206bc74cff8a528ab3f6df53ce5ea9068416b40174b3f2
7
+ data.tar.gz: 0fe617fa64e3bf666438ac6a8b6bf35eac83c9552280d16f9070443fe7e7b5e7e4c0e28185b5bcf853e6eac40fc465bb29d55c3112621b9d3d979dcac81436bc
data/.gitignore CHANGED
@@ -3,7 +3,7 @@ Gemfile.lock
3
3
 
4
4
  # build artifacts
5
5
  *.gem
6
- /.bundle/
6
+ /.bundle
7
7
  /vendor/bundle
8
8
  /spec/reports/
9
9
  /tmp/
@@ -18,4 +18,4 @@ Gemfile.lock
18
18
  # rspec failure tracking
19
19
  .rspec_status
20
20
  scratch.rb
21
- .byebug_history
21
+ .byebug_history
data/CHANGELOG.md CHANGED
@@ -1,12 +1,140 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
- ## [2.5.10] - 2023-09-xx
4
+ ## [2.6.1] - 2024-02-11
5
+
6
+ ### Added
7
+ - For use case `Eco::API::UseCases::Default::Locations::TagtreeExtract`
8
+ - New `-indent` option
9
+ - `Eco::API::UseCases::UseCase`
10
+ - Defines on loader object attr reader methods `people`, `input` and `usecase` unless they already exist.
11
+ - Some class / method helpers
12
+ - `Eco::Language::Methods::DelegateMissing` to redirect missing methods to one object
13
+ - `Eco::Language::Methods::DslAble` to allow direct method calls on blocks
14
+ - `Eco::Language::Klass:WhenInherited` to allow to defined a block that gets called when the class is inherited
15
+ - **DSL** capabilities (for block calls) for
16
+ - `Eco::API::Session::Batch::BasePolicy`
17
+ - `Eco::API::Session::Batch::Job`
18
+ - `api_excluded` block to be called in the Job's context
19
+ - `Eco::API::UseCases::BaseIO`
20
+ - This shortens code lines in workflow blocks
21
+ - `Eco::API::Session::Config::Workflow#run` has been adapted to boost the evalution of the workflow blocks within the context of the `BaseIO` that is carried throughout all the run process.
22
+ - **NEW** Loaders
23
+ - `Eco::API::Custom::Config` (**DSL** alike) allows to open up configuration via class
24
+ - Redirects to `Eco::API::Common::Loaders::Config`
25
+ - Re-usable sample child classes can created with the use of `config_block`, which in combination with `when_inherited` will load the basic config to custom config classes.
26
+ - `Eco::API::Custom::Workflow` (**DSL** alike) allows to open up workflow configurations via class
27
+ - Redirects to `Eco::API::Common::Loaders::Config::Workflow`
28
+ - `Eco::API::Custom::Mailer` (first **sample**) allows to just define some constants to modify the generic behaviour of this sample class you will want to inherit to enable mailing workflow.
29
+ - Redirects to `Eco::API::Common::Loaders::Config::Workflow::Mailer`
30
+ - `Eco::Assets#cli` able to yield the `cli` to a block
31
+ - `Eco::API::UseCases::BaseIO#process_case`
32
+ - **added method** `process_case`, which allows to pass the `io` itself as a paramter.
33
+ - When this is used, the `output` swap as `input` / `people` is performed (before and after).
34
+
35
+ ### Changed
36
+ - **IMPORTANT** overriden `Object#inspect` to `to_s` to prevent recursive deep introspection of object internals on `MethodError`
37
+ - `Eco::API::Common::Loaders::CaseBase`
38
+ - **removed** attr `usecase`
39
+ - `Eco::API::UseCases::BaseIO`
40
+ - `output` can be set on initialization
41
+ - `#new` carries the `output` as well.
42
+ - `Eco::API::Session::Config::Workflow`
43
+ - `#run`
44
+ - workflow blocks don't require to explicitly return the `BaseIO` when there isn't any to return. It will just keep the `io` as it was before the call.
45
+ - also made it so the returned io is **always** an **instance of** `Eco::API::UseCases::BaseIO` (so it won't return an instance of a child class). This change can be considered a fix. **Aside note:** only possible now that `output` is carried on through objects of type (so there's there's no data loss in the calls chain) `Eco::API::UseCases::BaseIO` (i.e. `io.new`)
46
+ - `#for`
47
+ - **now** it only requires a `block` if no `key` is provided
48
+ - `Eco::Data::Locations::NodeBase::TagValidations`
49
+ - made module re-usable, by removing dependency on `clean_id` method.
50
+ - Improved the **patch** on exception that adds method `#patch_full_message`
51
+ - Parameter `trace_count` added (`default: -1` for full trace)
52
+
53
+ ### Fixed
54
+ - `Eco::Data::Locations::NodeBase::Treeify`
55
+ - **bug** on strings and interpolation when building the warning/error messages
56
+ - **added** detection and _warnings_ for **unlinked parents**: as `get_children` is called from the top via `nil` (those that are top level nodes), and all the call chain to collect children goes through their `parent_id` relationship.
57
+ - If the input nodes had some where there's no direct link between `nil` and a node `id` that is a `parent_id`, `parents[node.id]` would never be called. Meaning that in an input with a list of nodes, there could be clusters of subtrees that do not add/link to the top level (`nil`).
58
+ - It now gathers those separated subtrees in an `Array` parameter called `unlinked_trees`
59
+ - `Eco::API::Session::Config::Workflow`
60
+ - Returning an `Eco::API::UseCases::BaseIO` from callbacks `before`, `after` and `run` would raise an `ArgumentError`.
61
+ - **Now** the original `io` is returned otherwise the returned value is a `BaseIO`
62
+ - `Eco::API::Session::Config::Workflow`
63
+ - **changed** `open` to alias method for `with` (open was clashing)
64
+ - `Eco::API::UseCases::GraphQL::Helpers::Location::Base`
65
+ - **removed** `enviro` param for org tagtree built
66
+ - `Eco::API::UseCases::Cli::DSL`
67
+ - `::callback` was not acting like a DSL method, which would just return `nil` always (lost `block`)
68
+ - CLI arguments are unique. If a Cli class has already been run, no need to re-run it. Cli class re-usability is still not in the pipeline, and therefore, it must be run only once.
69
+ - `Eco::Data::Locations::NodePlain`
70
+ - `serializer` referred to an non existing constant.
71
+ - **IMPORTANT** `parent_id` should be `cleaned` as well. Otherwise parents with an id cleanage don't match their children's `parent_id`
72
+ - `Eco::API::Common::ClassHelpers`
73
+ - `::inerited` method must call `super` to be able to chain other calls
74
+ - `Eco::API::Common::Session::Mailer`
75
+ - The logging message was not printing who the email was sent to.
76
+
77
+ ## [2.6.0] - 2024-02-03
78
+
79
+ ### Added
80
+ - New use case to `-export-tree` (**tagtree extract**)
81
+ - `Eco::API::UseCases::Default::Locations::TagtreeExtract`
82
+ - `Eco::API::UseCases::UseCase`
83
+ - added `#classed_definition` to expose the original class definition
84
+ - injected further parameter as instance variables to the original class definition on run-time.
85
+ - Expose `live_trees` retrieval:
86
+ - `Eco::API::Session#live_trees`
87
+ - `Eco::API::Session::Config#live_trees`
88
+ - Ability to CLI-integrate use cases and their options via class
89
+ - `Eco::API::UseCases::Cli`
90
+ - Added use case to extract live locations structure (`-export-tree`)
91
+ - `Eco::API::UseCases::GraphQL::Cases::TagtreeExtract`
92
+ - `#api?` method to check if an API version is available
93
+ - `Eco::API::Common::Session::Environment#api?`
94
+ - `Eco::API::Common::Session::BaseSession#api?`
95
+ - `Eco::API::Organization::TagTree#merge` the merge method for tagtrees
96
+ - It allows to have all structure nodes available to check if a tag belongs to them
97
+ - `Eco::API::Session::Config::Workflow`
98
+ - **added** `open` alias method for `for`
99
+ - `Eco::Data::Mapper#self_mapped?` to check if a value maps to itself
100
+
101
+ ### Changed
102
+ - upgrade `ecoportal-api-graphql`, `ecoportal-api-v2` and `ecoportal-api`
103
+ - `Eco::API::Session#tagtree`: added parameters to be able to obtain:
104
+ - `:live` live trees if graphql api is available on the enviro
105
+ - `:merge` to merge all live trees if there isn't just one
106
+ - Tagtree retrieval: remove `enviro` param where there's no caching
107
+ - Removed also from `Eco::API::Organization::TagTree::new`
108
+ - Removed some use cases:
109
+ - `Eco::API::UseCases::DefaultCases::AbstractPolicyGroupAbilities`
110
+ - `Eco::API::UseCases::DefaultCases::AppendUsergroupsCase`
111
+ - `Eco::API::UseCases::DefaultCases::CreateDetailsCase`
112
+ - `Eco::API::UseCases::DefaultCases::CreateDetailsWithSupervisorCase`
113
+ - `Eco::API::UseCases::DefaultCases::EmailAsIdCase`
114
+ - `Eco::API::UseCases::DefaultCases::NewIdCase`
115
+ - `Eco::API::UseCases::DefaultCases::RemoveAccountSyncCase`
116
+ - `Eco::API::UseCases::DefaultCases::RemoveAccountTransCase`
117
+ - `Eco::API::UseCases::DefaultCases::NewEmailCase`
118
+ - `Eco::API::UseCases::DefaultCases::SetSupervisorCase`
119
+ - `Eco::API::UseCases::DefaultCases::TagTree`
120
+ - `Eco::API::UseCases::DefaultCases::UpdateDetailsCase`
121
+ - `Eco::API::UseCases::DefaultCases::ResetLandingPageCase`
122
+ - Moved some default use cases to new namespace `Eco::API::UseCases::Default`
123
+
124
+ ### Fixed
125
+ - Compatibility with `ruby 3`
126
+ - replaced `Proc.new` (with no block) by `block` in methods
127
+ - replaced `File#exists?` by `File#exist?`
128
+ - call to method's `super` not specifying args, no longer passes keyed/named args via simple splat `*` (but only double splat `**`)
129
+ - limit `nokogiri` gem to prev `1.16` (as it requires ruby 3 from thereon)
130
+ - `Eco::API::Common::People::PersonEntryAttributeMapper`
131
+ - `#aliased_attrs` was missing internal attrs that have been mapped directly as external attrs (same ext attr name as int attr name)
132
+
133
+ ## [2.5.10] - 2023-11-22
5
134
 
6
- ### Added
7
- ### Changed
8
135
  ### Fixed
9
- - `Eco::API::UseCases::DefaultCases::ReinviteSyncCase` remove unnecessary additional parameters on call.
136
+ - `Eco::API::UseCases::DefaultCases::ReinviteSyncCase` remove unnecessary additional parameters on call.
137
+ - `Eco::API::Session::Config::SFTP#enviro_subpaths` provided that a current workaround can be skipped
10
138
 
11
139
  ## [2.5.9] - 2023-09-05
12
140
 
data/README.md CHANGED
@@ -17,3 +17,8 @@ And then execute:
17
17
  Or install it yourself as:
18
18
 
19
19
  $ gem install eco-helpers
20
+
21
+
22
+ ## Changelog
23
+
24
+ See {file:CHANGELOG.md} for a list of changes.
data/eco-helpers.gemspec CHANGED
@@ -24,24 +24,28 @@ Gem::Specification.new do |spec|
24
24
  #spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
25
25
  spec.require_paths = ["lib"]
26
26
 
27
- spec.add_development_dependency "bundler", ">= 2.4.8", "< 3"
28
- spec.add_development_dependency "rspec", ">= 3.10.0", "< 4"
27
+ spec.add_development_dependency "bundler", ">= 2.4.12", "< 3"
28
+ spec.add_development_dependency "rspec", ">= 3.12.0", "< 4"
29
29
  spec.add_development_dependency "rake", ">= 13.0.3", "< 14"
30
- spec.add_development_dependency "yard", ">= 0.9.26", "< 1"
31
- spec.add_development_dependency "redcarpet", ">= 3.5.1", "< 4"
30
+ spec.add_development_dependency "yard", ">= 0.9.34", "< 1"
31
+ spec.add_development_dependency "redcarpet", ">= 3.6.0", "< 4"
32
32
 
33
- spec.add_dependency 'ecoportal-api', '>= 0.9.5', '< 0.10'
34
- spec.add_dependency 'ecoportal-api-v2', '>= 1.1.3', '< 1.2'
35
- spec.add_dependency 'ecoportal-api-graphql', '>= 0.3.11', '< 0.4'
36
- spec.add_dependency 'aws-sdk-s3', '>= 1.83.0', '< 2'
37
- spec.add_dependency 'aws-sdk-ses', '>= 1.36.0', '< 2'
38
- spec.add_dependency 'dotenv', '>= 2.7.6', '< 3'
39
- spec.add_dependency 'net-sftp', '>= 3.0.0', '< 4'
40
- spec.add_dependency 'hashdiff', '>= 1.0.1', '< 1.1'
33
+ spec.add_dependency 'ecoportal-api', '>= 0.9.6', '< 0.10'
34
+ spec.add_dependency 'ecoportal-api-v2', '>= 1.1.5', '< 1.2'
35
+ spec.add_dependency 'ecoportal-api-graphql', '>= 0.3.13', '< 0.4'
36
+ spec.add_dependency 'aws-sdk-s3', '>= 1.142.0', '< 2'
37
+ spec.add_dependency 'aws-sdk-ses', '>= 1.58.0', '< 2'
38
+ spec.add_dependency 'dotenv', '>= 2.8.1', '< 3'
39
+ spec.add_dependency 'net-ssh', '>= 7.2.1', '< 8'
40
+ spec.add_dependency 'net-sftp', '>= 4.0.0', '< 5'
41
+ spec.add_dependency 'hashdiff', '>= 1.1.0', '< 1.2'
41
42
  spec.add_dependency 'fuzzy_match', '>= 2.1.0', '< 2.2'
42
- spec.add_dependency 'amatch', '>= 0.4.0', '< 0.5'
43
- spec.add_dependency 'jaro_winkler', '>= 1.5.4', '< 1.6'
44
- spec.add_dependency 'roo', '>= 2.8.3', '< 2.9'
43
+ spec.add_dependency 'amatch', '>= 0.4.1', '< 0.5'
44
+ spec.add_dependency 'jaro_winkler', '>= 1.5.6', '< 1.6'
45
+ spec.add_dependency 'nokogiri', '>= 1.13', '< 1.17'
46
+ spec.add_dependency 'roo', '>= 2.10.1', '< 2.11'
45
47
  spec.add_dependency 'roo-xls', '>= 1.2.0', '< 1.3'
46
- spec.add_dependency 'docx', '>= 0.6.2', '< 0.7'
48
+ spec.add_dependency 'fast_excel', '>= 0.5.0', '< 0.6'
49
+ spec.add_dependency 'docx', '>= 0.8.0', '< 0.9'
50
+ spec.add_dependency 'rubyzip', '>= 2.3.2', '< 2.4'
47
51
  end
@@ -129,13 +129,13 @@ module Eco
129
129
  # - mutating methods would reflect the changes on other classes as well
130
130
  # - therefore, `freeze` will be called on the values that are inherited.
131
131
  def inherited(subclass)
132
+ super
132
133
  inheritable_class_vars.each do |var|
133
134
  instance_var = instance_variable_name(var)
134
135
  value = instance_variable_get(instance_var)
135
136
  subclass.instance_variable_set(instance_var, value.freeze)
136
137
  end
137
138
  end
138
-
139
139
  end
140
140
  end
141
141
  end
@@ -30,10 +30,6 @@ module Eco
30
30
  raise "You should implement this method"
31
31
  end
32
32
 
33
- def name
34
- self.class.name
35
- end
36
-
37
33
  private
38
34
 
39
35
  def session
@@ -54,11 +50,8 @@ module Eco
54
50
 
55
51
  def abort(msg, raising: true)
56
52
  logger.error(msg)
57
- if raising
58
- raise msg
59
- else
60
- exit(1)
61
- end
53
+ raise msg if raising
54
+ exit 1
62
55
  end
63
56
  end
64
57
  end
@@ -20,8 +20,6 @@ module Eco
20
20
  end
21
21
  end
22
22
 
23
- attr_reader :usecase
24
-
25
23
  def name
26
24
  self.class.name
27
25
  end
@@ -0,0 +1,78 @@
1
+ class Eco::API::Common::Loaders::Workflow::Mailer < Eco::API::Common::Loaders::Workflow
2
+ ORG = 'your organization'.freeze
3
+ TRACE_COUNT = 3
4
+
5
+ inheritable_class_vars :config_block
6
+
7
+ config_block do
8
+ puts "running from class #{self}"
9
+ exception do |err, io|
10
+ self.error = err
11
+ log(:debug) { err.patch_full_message }
12
+ workflow.run(:close, io: io)
13
+ end
14
+
15
+ after(:close) do |_wf, io|
16
+ next if options.dig(:workflow, :no_email)
17
+ next unless session.mailer?
18
+ next if session.config.dry_run?
19
+ next unless session.config.run_mode_remote?
20
+ next unless some_update?(io) || error?
21
+
22
+ subject = base_subject
23
+
24
+ if session.job_groups.empty? && error?
25
+ subject = "#{subject} - Exception!"
26
+ session.mail(subject: subject, body: errors_n_warnings(io))
27
+ else
28
+ subject = "#{subject} & Errors" if session.job_groups.errors?
29
+ subject = "#{subject} - Exception!" if error?
30
+
31
+ msg = "#{session.summary}\n"
32
+ msg += errors_n_warnings(io)
33
+
34
+ session.mail(subject: subject, body: msg) unless msg.strip.empty?
35
+ end
36
+ end
37
+ end
38
+
39
+ class << self
40
+ attr_accessor :error
41
+
42
+ def org_name
43
+ self::ORG
44
+ end
45
+
46
+ def base_subject
47
+ "#{org_name} (#{active_enviro}) at #{Time.now.iso8601}"
48
+ end
49
+
50
+ def some_update?(io)
51
+ cli.config.usecases.active(io: io).any? do |usecase, data|
52
+ [:transform, :sync].any? { |type| usecase.type == type }
53
+ end
54
+ end
55
+
56
+ def error?
57
+ !!error
58
+ end
59
+
60
+ def errors_n_warnings(io)
61
+ [error_message, log_err_n_warn(io)].join("\n")
62
+ end
63
+
64
+ def log_err_n_warn(io)
65
+ warn_errors = io.logger.cache.logs(level: [:error, :warn])
66
+ return if warn_errors.empty?
67
+ "WARNINGS & ERRORS:\n#{warn_errors.join('')}\n"
68
+ end
69
+
70
+ def error_message
71
+ error&.patch_full_message(trace_count: 3)
72
+ end
73
+
74
+ def trace_count
75
+ self::TRACE_COUNT
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,11 @@
1
+ class Eco::API::Common::Loaders::Workflow < Eco::API::Common::Loaders::Config
2
+ class << self
3
+ def workflow
4
+ config.workflow
5
+ end
6
+ end
7
+
8
+ delegate_missing_to :workflow
9
+ end
10
+
11
+ require_relative 'workflow/mailer'
@@ -0,0 +1,29 @@
1
+ class Eco::API::Common::Loaders::Config
2
+ extend Eco::API::Common::ClassHelpers
3
+ extend Eco::Language::Methods::DelegateMissing
4
+ inheritable_class_vars :delegate_missing_to
5
+
6
+ class << self
7
+ # To create samples of configurations
8
+ def config_block(&block)
9
+ return @config_block unless block_given?
10
+ @config_block = block
11
+ end
12
+
13
+ def config
14
+ ASSETS.config
15
+ end
16
+
17
+ def cli
18
+ ASSETS.cli
19
+ end
20
+
21
+ def active_enviro
22
+ config.active_enviro
23
+ end
24
+ end
25
+
26
+ delegate_missing_to :config
27
+ end
28
+
29
+ require_relative 'config/workflow'
@@ -3,7 +3,6 @@ module Eco
3
3
  module Common
4
4
  module Loaders
5
5
  class ErrorHandler < Eco::API::Common::Loaders::CaseBase
6
-
7
6
  class << self
8
7
  attr_writer :error
9
8
 
@@ -35,7 +34,6 @@ module Eco
35
34
  def error
36
35
  self.class.error
37
36
  end
38
-
39
37
  end
40
38
  end
41
39
  end
@@ -3,7 +3,6 @@ module Eco
3
3
  module Common
4
4
  module Loaders
5
5
  class Parser < Eco::API::Common::Loaders::CaseBase
6
-
7
6
  # Helper class to scope what required attributes it depends on
8
7
  class RequiredAttrs < Struct.new(:attr, :type, :attrs)
9
8
  def active?(*input_attrs)
@@ -3,7 +3,6 @@ module Eco
3
3
  module Common
4
4
  module Loaders
5
5
  class Policy < Eco::API::Common::Loaders::CaseBase
6
-
7
6
  def initialize(policies)
8
7
  raise "Expected Eco::API::Policies. Given #{policies.class}" unless policies.is_a?(Eco::API::Policies)
9
8
  policies.define(self.name, &self.method(:main))
@@ -17,7 +16,6 @@ module Eco
17
16
  def main(people, session, options, policy, job)
18
17
  raise "You should implement this method"
19
18
  end
20
-
21
19
  end
22
20
  end
23
21
  end
@@ -11,9 +11,31 @@ module Eco
11
11
  end
12
12
  @type = value
13
13
  end
14
+
15
+ def cli!
16
+ cli&.apply!
17
+ end
18
+
19
+ def cli(cli_class = nil)
20
+ if cli_class.is_a?(Class)
21
+ raise ArgumentError, "cli_class should inherit from Eco::API::UseCases::Cli" unless cli_class < Eco::API::UseCases::Cli
22
+ @cli = cli_class
23
+ elsif cli_class.nil?
24
+ return @cli if instance_variable_defined?(:@cli) && !@cli.nil?
25
+ # try to see if it's namespaced after the use case it provisions cli integration
26
+ begin
27
+ try_class = [self.to_s, 'Cli'].join('::')
28
+ @cli = Kernel.const_get(try_class)
29
+ rescue NameError
30
+ nil
31
+ end
32
+ else
33
+ raise ArgumentError, "Expecting a class. Given: #{cli_class.class} object"
34
+ end
35
+ end
14
36
  end
15
37
 
16
- inheritable_class_vars :type
38
+ inheritable_class_vars :type, :cli
17
39
 
18
40
  def initialize(usecases)
19
41
  raise "Expected Eco::API::UseCases. Given #{usecases.class}" unless usecases.is_a?(Eco::API::UseCases)
@@ -33,6 +55,10 @@ module Eco
33
55
  def type
34
56
  self.class.type
35
57
  end
58
+
59
+ def cli_apply!
60
+ self.class.cli!
61
+ end
36
62
  end
37
63
  end
38
64
  end
@@ -9,6 +9,7 @@ end
9
9
 
10
10
  require_relative 'loaders/base'
11
11
  require_relative 'loaders/case_base'
12
+ require_relative 'loaders/config'
12
13
  require_relative 'loaders/use_case'
13
14
  require_relative 'loaders/policy'
14
15
  require_relative 'loaders/error_handler'
@@ -8,8 +8,8 @@ module Eco
8
8
  autoloads_children_of "Eco::API::Common::Loaders::Parser"
9
9
  autoload_namespace "Eco::API::Common::People::DefaultParsers"
10
10
 
11
- def initialize(*args)
12
- super(*args)
11
+ def initialize(**kargs)
12
+ super(**kargs)
13
13
  define_defaults
14
14
  end
15
15
 
@@ -3,6 +3,7 @@ module Eco
3
3
  module Common
4
4
  module People
5
5
  class PersonEntry
6
+ DEBUG = false
6
7
 
7
8
  # This class is meant to provide a common interface to access entries of source data that come in different formats.
8
9
  # @note
@@ -37,6 +38,8 @@ module Eco
37
38
  @mapped_entry = __mapped_entry(@internal_entry)
38
39
  @external_entry = __external_entry(@mapped_entry)
39
40
  end
41
+
42
+ (print_models; exit(1)) if DEBUG
40
43
  end
41
44
 
42
45
  # Generates a new entry