eco-helpers 1.4.2 → 1.5.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +146 -3
  3. data/LICENSE +21 -0
  4. data/eco-helpers.gemspec +11 -10
  5. data/lib/eco/api.rb +3 -0
  6. data/lib/eco/api/common.rb +5 -1
  7. data/lib/eco/api/common/base_loader.rb +54 -0
  8. data/lib/eco/api/common/class_auto_loader.rb +109 -0
  9. data/lib/eco/api/common/class_helpers.rb +33 -0
  10. data/lib/eco/api/common/class_hierarchy.rb +1 -1
  11. data/lib/eco/api/common/class_meta_basics.rb +16 -0
  12. data/lib/eco/api/common/loaders.rb +13 -0
  13. data/lib/eco/api/common/loaders/error_handler.rb +41 -0
  14. data/lib/eco/api/common/loaders/parser.rb +127 -0
  15. data/lib/eco/api/common/loaders/policy.rb +25 -0
  16. data/lib/eco/api/common/loaders/use_case.rb +40 -0
  17. data/lib/eco/api/common/people/default_parsers.rb +5 -10
  18. data/lib/eco/api/common/people/default_parsers/boolean_parser.rb +13 -23
  19. data/lib/eco/api/common/people/default_parsers/csv_parser.rb +20 -35
  20. data/lib/eco/api/common/people/default_parsers/date_parser.rb +15 -26
  21. data/lib/eco/api/common/people/default_parsers/freemium_parser.rb +20 -0
  22. data/lib/eco/api/common/people/default_parsers/login_providers_parser.rb +26 -0
  23. data/lib/eco/api/common/people/default_parsers/multi_parser.rb +15 -27
  24. data/lib/eco/api/common/people/default_parsers/numeric_parser.rb +14 -19
  25. data/lib/eco/api/common/people/default_parsers/policy_groups_parser.rb +31 -0
  26. data/lib/eco/api/common/people/default_parsers/send_invites_parser.rb +15 -24
  27. data/lib/eco/api/common/people/entries.rb +54 -24
  28. data/lib/eco/api/common/people/entry_factory.rb +18 -15
  29. data/lib/eco/api/common/people/person_attribute_parser.rb +29 -12
  30. data/lib/eco/api/common/people/person_entry.rb +308 -216
  31. data/lib/eco/api/common/people/person_entry_attribute_mapper.rb +5 -2
  32. data/lib/eco/api/common/people/person_parser.rb +52 -19
  33. data/lib/eco/api/common/session/base_session.rb +3 -6
  34. data/lib/eco/api/common/session/environment.rb +2 -23
  35. data/lib/eco/api/common/session/logger.rb +4 -0
  36. data/lib/eco/api/common/version_patches/ecoportal_api/external_person.rb +2 -0
  37. data/lib/eco/api/common/version_patches/ecoportal_api/internal_person.rb +9 -1
  38. data/lib/eco/api/common/version_patches/exception.rb +22 -0
  39. data/lib/eco/api/custom.rb +13 -0
  40. data/lib/eco/api/custom/error_handler.rb +20 -0
  41. data/lib/eco/api/custom/namespace.rb +7 -0
  42. data/lib/eco/api/custom/parser.rb +50 -0
  43. data/lib/eco/api/custom/policy.rb +28 -0
  44. data/lib/eco/api/custom/use_case.rb +16 -0
  45. data/lib/eco/api/error.rb +1 -0
  46. data/lib/eco/api/error/handlers.rb +10 -3
  47. data/lib/eco/api/microcases.rb +35 -0
  48. data/lib/eco/api/microcases/account_excluded.rb +24 -0
  49. data/lib/eco/api/microcases/append_usergroups.rb +19 -0
  50. data/lib/eco/api/microcases/core_excluded.rb +20 -0
  51. data/lib/eco/api/microcases/fix_default_group.rb +34 -0
  52. data/lib/eco/api/microcases/fix_filter_tags.rb +42 -0
  53. data/lib/eco/api/microcases/people_cache.rb +17 -0
  54. data/lib/eco/api/microcases/people_load.rb +59 -0
  55. data/lib/eco/api/microcases/people_refresh.rb +31 -0
  56. data/lib/eco/api/microcases/people_search.rb +65 -0
  57. data/lib/eco/api/microcases/refresh_abilities.rb +19 -0
  58. data/lib/eco/api/microcases/refresh_default_tag.rb +27 -0
  59. data/lib/eco/api/microcases/s3upload_targets.rb +39 -0
  60. data/lib/eco/api/microcases/set_account.rb +20 -0
  61. data/lib/eco/api/microcases/set_core.rb +18 -0
  62. data/lib/eco/api/microcases/set_core_with_supervisor.rb +23 -0
  63. data/lib/eco/api/microcases/set_supervisor.rb +30 -0
  64. data/lib/eco/api/microcases/strict_search.rb +19 -0
  65. data/lib/eco/api/microcases/with_each.rb +27 -0
  66. data/lib/eco/api/microcases/with_each_leaver.rb +24 -0
  67. data/lib/eco/api/microcases/with_each_present.rb +30 -0
  68. data/lib/eco/api/microcases/with_each_starter.rb +30 -0
  69. data/lib/eco/api/microcases/with_each_subordinate.rb +34 -0
  70. data/lib/eco/api/microcases/with_supervisor.rb +36 -0
  71. data/lib/eco/api/organization/people.rb +72 -35
  72. data/lib/eco/api/organization/presets_factory.rb +13 -4
  73. data/lib/eco/api/organization/presets_reference.json +9 -1
  74. data/lib/eco/api/organization/presets_values.json +4 -1
  75. data/lib/eco/api/policies.rb +11 -7
  76. data/lib/eco/api/session.rb +62 -29
  77. data/lib/eco/api/session/batch.rb +2 -45
  78. data/lib/eco/api/session/batch/base_policy.rb +7 -6
  79. data/lib/eco/api/session/batch/errors.rb +28 -4
  80. data/lib/eco/api/session/batch/feedback.rb +7 -1
  81. data/lib/eco/api/session/batch/job.rb +40 -23
  82. data/lib/eco/api/session/batch/jobs.rb +9 -4
  83. data/lib/eco/api/session/batch/jobs_groups.rb +1 -1
  84. data/lib/eco/api/session/batch/request_stats.rb +95 -58
  85. data/lib/eco/api/session/batch/status.rb +35 -31
  86. data/lib/eco/api/session/config.rb +106 -44
  87. data/lib/eco/api/session/config/api.rb +132 -7
  88. data/lib/eco/api/session/config/apis.rb +24 -25
  89. data/lib/eco/api/session/config/logger.rb +2 -2
  90. data/lib/eco/api/session/config/post_launch.rb +1 -1
  91. data/lib/eco/api/session/config/workflow.rb +8 -7
  92. data/lib/eco/api/usecases.rb +47 -33
  93. data/lib/eco/api/usecases/backup/append_usergroups_case.rb +36 -0
  94. data/lib/eco/api/usecases/backup/create_case.rb +104 -0
  95. data/lib/eco/api/usecases/backup/create_details_case.rb +31 -0
  96. data/lib/eco/api/usecases/backup/create_details_with_supervisor_case.rb +48 -0
  97. data/lib/eco/api/usecases/backup/hris_case.rb +124 -0
  98. data/lib/eco/api/usecases/backup/set_default_tag_case.rb +49 -0
  99. data/lib/eco/api/usecases/backup/set_supervisor_case.rb +41 -0
  100. data/lib/eco/api/usecases/backup/transfer_account_case.rb +90 -0
  101. data/lib/eco/api/usecases/backup/update_case.rb +112 -0
  102. data/lib/eco/api/usecases/backup/update_details_case.rb +64 -0
  103. data/lib/eco/api/usecases/backup/upsert_case.rb +114 -0
  104. data/lib/eco/api/usecases/base_case.rb +2 -0
  105. data/lib/eco/api/usecases/base_io.rb +3 -3
  106. data/lib/eco/api/usecases/default_cases.rb +23 -53
  107. data/lib/eco/api/usecases/default_cases/append_usergroups_case.rb +10 -31
  108. data/lib/eco/api/usecases/default_cases/change_email_case.rb +23 -47
  109. data/lib/eco/api/usecases/default_cases/codes_to_tags_case.rb +56 -43
  110. data/lib/eco/api/usecases/default_cases/create_case.rb +15 -101
  111. data/lib/eco/api/usecases/default_cases/create_details_case.rb +11 -26
  112. data/lib/eco/api/usecases/default_cases/create_details_with_supervisor_case.rb +12 -43
  113. data/lib/eco/api/usecases/default_cases/delete_sync_case.rb +11 -0
  114. data/lib/eco/api/usecases/default_cases/delete_trans_case.rb +14 -0
  115. data/lib/eco/api/usecases/default_cases/email_as_id_case.rb +10 -21
  116. data/lib/eco/api/usecases/default_cases/hris_case.rb +23 -120
  117. data/lib/eco/api/usecases/default_cases/new_email_case.rb +10 -23
  118. data/lib/eco/api/usecases/default_cases/new_id_case.rb +11 -25
  119. data/lib/eco/api/usecases/default_cases/new_id_case0.rb +14 -0
  120. data/lib/eco/api/usecases/default_cases/org_data_convert_case.rb +83 -0
  121. data/lib/eco/api/usecases/default_cases/refresh_abilities_case.rb +30 -0
  122. data/lib/eco/api/usecases/default_cases/refresh_case.rb +7 -20
  123. data/lib/eco/api/usecases/default_cases/reinvite_sync_case.rb +11 -0
  124. data/lib/eco/api/usecases/default_cases/reinvite_trans_case.rb +17 -0
  125. data/lib/eco/api/usecases/default_cases/remove_account_sync_case.rb +11 -0
  126. data/lib/eco/api/usecases/default_cases/remove_account_trans_case.rb +17 -0
  127. data/lib/eco/api/usecases/default_cases/reset_landing_page_case.rb +9 -19
  128. data/lib/eco/api/usecases/default_cases/restore_db_case.rb +92 -0
  129. data/lib/eco/api/usecases/default_cases/set_default_tag_case.rb +32 -40
  130. data/lib/eco/api/usecases/default_cases/set_supervisor_case.rb +15 -33
  131. data/lib/eco/api/usecases/default_cases/switch_supervisor_case.rb +66 -57
  132. data/lib/eco/api/usecases/default_cases/to_csv_case.rb +36 -44
  133. data/lib/eco/api/usecases/default_cases/to_csv_detailed_case.rb +40 -55
  134. data/lib/eco/api/usecases/default_cases/transfer_account_case.rb +264 -84
  135. data/lib/eco/api/usecases/default_cases/update_case.rb +15 -109
  136. data/lib/eco/api/usecases/default_cases/update_details_case.rb +14 -61
  137. data/lib/eco/api/usecases/default_cases/upsert_case.rb +16 -111
  138. data/lib/eco/api/usecases/use_case_io.rb +9 -9
  139. data/lib/eco/cli/config.rb +10 -2
  140. data/lib/eco/cli/config/default.rb +2 -1
  141. data/lib/eco/cli/config/default/input_filters.rb +58 -0
  142. data/lib/eco/cli/config/default/options.rb +60 -25
  143. data/lib/eco/cli/config/default/people.rb +4 -4
  144. data/lib/eco/cli/config/default/people_filters.rb +108 -0
  145. data/lib/eco/cli/config/default/usecases.rb +69 -32
  146. data/lib/eco/cli/config/default/workflow.rb +37 -27
  147. data/lib/eco/cli/config/filters.rb +50 -0
  148. data/lib/eco/cli/config/filters/input_filters.rb +29 -0
  149. data/lib/eco/cli/config/filters/people_filters.rb +29 -0
  150. data/lib/eco/cli/config/help.rb +49 -0
  151. data/lib/eco/cli/config/options_set.rb +17 -1
  152. data/lib/eco/cli/config/use_cases.rb +79 -53
  153. data/lib/eco/cli/scripting.rb +10 -2
  154. data/lib/eco/cli/scripting/args_helpers.rb +25 -15
  155. data/lib/eco/cli/scripting/argument.rb +1 -0
  156. data/lib/eco/cli/scripting/arguments.rb +1 -1
  157. data/lib/eco/csv.rb +8 -3
  158. data/lib/eco/csv/table.rb +1 -1
  159. data/lib/eco/data/crypto/encryption.rb +3 -0
  160. data/lib/eco/data/files/helpers.rb +6 -1
  161. data/lib/eco/language/match.rb +19 -9
  162. data/lib/eco/language/match_modifier.rb +13 -5
  163. data/lib/eco/language/models/collection.rb +77 -56
  164. data/lib/eco/language/models/parser_serializer.rb +39 -15
  165. data/lib/eco/version.rb +1 -1
  166. metadata +149 -63
  167. data/lib/eco/api/session/task.rb +0 -175
  168. data/lib/eco/api/usecases/default_case.rb +0 -19
  169. data/lib/eco/api/usecases/default_cases/delete_case.rb +0 -32
  170. data/lib/eco/api/usecases/default_cases/recover_db_case.rb +0 -98
  171. data/lib/eco/api/usecases/default_cases/refresh_presets_case.rb +0 -26
  172. data/lib/eco/api/usecases/default_cases/reinvite_case.rb +0 -41
  173. data/lib/eco/api/usecases/default_cases/remove_account_case.rb +0 -38
  174. data/lib/eco/cli/config/default/filters.rb +0 -70
  175. data/lib/eco/cli/config/people_filters.rb +0 -38
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2248f088b428a4d94bc0a28fe735e680b179a64f138113206057c853e358e0f0
4
- data.tar.gz: 1284ede3bcbfc33df6281ab456247850d918cc98eb8318c7327c8047be8dcab0
3
+ metadata.gz: afd844b9beef06b6b7433f14dcd1138be3796e381c6f9fb9b339449cf324f5f0
4
+ data.tar.gz: 6376fa023304d0e3b0a0ce07a700359a3e5891d6f1a95b37f723318f6a4965df
5
5
  SHA512:
6
- metadata.gz: fcc3c790f2c4a6c044f11da966ac97149eb652e503c91bce108d58fa12348c1be0be1a056518798c4121110bf9146ce2271bcafa87bc938a8d35058449949838
7
- data.tar.gz: 3f6a6888a1907419fceaa3ad25f0c997e133715a467cd3c3704ef1f43ec24f09528460069b3e7ceefb9bf612ca2e6d034d6d3beef5fac0487b88e0ecf5952b66
6
+ metadata.gz: b458416828c6a84d17ac0ed83b68dd15b4fa154627365ab00928410008874305f3cd54210f10ee90cca1f8172587e44140470e43b00f2348e6b3eaf5fa6ec17c
7
+ data.tar.gz: 67a49053cb25f484639603c6a95c42de53d501b441a72aeb139bb18352f4820f36cb7a3a3ce3fbdf3138dc4a7c9ac62d927523c4cd2ce61bd2f45306c2fb4fa5
@@ -1,19 +1,162 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
- ## [1.4.3] - 2020-07-xx
4
+ ## [1.5.4] - 2020-12-02
5
5
 
6
6
  ### Added
7
+ - update `ecoportal-api` dependency
7
8
  ### Changed
8
9
  ### Fixed
10
+ - `Eco::API::MicroCases#people_refresh` typo
9
11
 
12
+ ## [1.5.3] - 2020-11-30
13
+
14
+ ### Added
15
+ ### Changed
16
+ ### Fixed
17
+ - `Eco::API::Session::Batch::RequestStats#blanked_value?` better blank detection
18
+ - `Eco::API::MicroCases#with_each_starter` rectified typo
19
+
20
+ ## [1.5.2] - 2020-11-26
21
+
22
+ ### Added
23
+ - **custom** usecases, policies and error handlers can now be **declared within its own class**
24
+ * helper classes to inherit from: `Eco::API::Custom::UseCase`, `Eco::API::Custom::Policy`, `Eco::API::Custom::ErrorHandler` and `Eco::API::Custom::Parser`
25
+ * please, notice that you should create new classes under the following namespaces
26
+ - `Custom::UseCase`: custom use cases
27
+ - `Custom::Policy`: custom policy
28
+ - `Custom::ErrorHandler`: custom error handler
29
+ - `Custom::Parser`: custom parser
30
+ * this also allows to inherit from existing defaults and models (models to come)
31
+ - implemented first **microcases** (evaluation stage): to be able to centralize common code between use cases
32
+ - see `Eco::API::MicroCases` class
33
+ - **command line** added `--help` to list all `usecases`, `options` and `filters`
34
+ * `--help -options` will print a documented overview of options
35
+ * `--help -filters` will print a documented overview of people filters
36
+ * `--help -input-filters` will print a documented overview of input data filters
37
+ * `--help -usecases` will print a documented overview of the usecases
38
+ - **command line** filters for `filter_tags` on:
39
+ * input data: `-input-filter-tags-all`, `input-filter-tags-any`, `input-filter-tags-tree`
40
+ * people data: `-filter-tags-all`, `-filter-tags-any`, `-filter-tags-tree`
41
+ - **batch stats** & **batch policy**
42
+ * `Eco::API::Session::Batch::RequestStats`: included additional guide on what has been **blanked**.
43
+ - now on you should see how many have been blanked, i.e.: `blanked_email`, `blanked_filter_tags`, `blanked_policy_group_ids`, `blanked_supervisor_id`
44
+ * Moreover, the new `blanked_*` properties are available for `config.batch_policies` provided that you can limit the `max` and/or `min` expected on each batch **type**
45
+ - **csv** generation (`-people-to-csv` and `-people-to-csv -detailed`):
46
+ * now includes `"Has Account?"` new column
47
+ * removed the useless `send_invites` column
48
+ - **errors** improved error message when setting values to a `person` from an `entry`:
49
+ * it now shows the **row number**
50
+ * it now gives the specific value that failed in case of `Exception`
51
+ - `Eco::API::Common::DefaultPasers::LoginProvidersParser`: made native
52
+ - `Eco::API::UseCases::DefaultUsecases::TransferAccountCase`: added `-transer-account-from` usecase
53
+ * to allow actually transfer an account/user from one person to another in the org
54
+ - `Ecoportal::API::V1::Person#entry`: method to be able to have a reference to the update/creation input data entry.
55
+ - new filter methods for `Eco::API::Common::People::Entries` and `Eco::API::Organization::People`
56
+ * `#filter_tags_any` & `#filter_tags_all`: those that have any or all the target tags
57
+ * `#policy_group_ids_any` & `#policy_groups_all`: those that have any or all the target policy groups
58
+
59
+ ### Changed
60
+ - updated dependency on `ecoportal-api` gem
61
+ - **command line** some changes:
62
+ - renamed `-refresh-presets` to `-refresh-abilities`
63
+ - renamed `-recover-db` to `restore-db`
64
+ - removed `Eco::API::Session::Tasks`: all the helpers have been moved and documented as part of `Eco::API::MicroCases` (some have been renamed)
65
+ - as a consequence, removed method `Eco::API::Session#do`
66
+ - `Eco::API::Common::People::PersonEntry#to_hash` has been removed
67
+ - now you should use the more explicit `Eco::API::Common::People::PersonEntry#external_entry`
68
+ - **internal refactor** of `Eco::API::UseCases::DefaultCases`:
69
+ * made so they inherit from `Eco::API::Common::Loaders::UseCase` and cases are autoloaded during run-time
70
+ - **internal refactor** of input entries processing:
71
+ * `Eco::API::Common::People::PersonEntry` internal refactor
72
+ - need to make the code clearer and make the `parsing` and `serializing` symmetrical
73
+ - the `serializers` were expecting an `Ecoportal::API::V1::Person`, which was at a different to that of when the `parsers` kicked in.
74
+ - now it has been introduced the possibility to launch the serializer in a different stage of the process
75
+ - to keep backwards compatibility, now it is possible to define at which `phase` of the parsing/serializing each parser and each serializer should kick in, which entailed changes in other classes and a new parameter in some methods thereof...
76
+ * `Eco::Language::Models::ParserSerializer` offers `category` parameter so you can have multiple parsers and serializers per each parser/serializer (one per category).
77
+ * `Eco::API::Common::People::PersonParser` uses `category` to define a `phase` when the `parser` or the `serializer` should be active => the expected object in the parser `callback` will be different depending on at which phase it is active and therefore called
78
+ - for `parser` valid **phases** are `:internal` (default) and `:final`
79
+ - for `serializer` valid **phases** are `:person` (default), `:final` and `:internal`
80
+ - the expected output of such **callbacks** is the same as before: either the single `value` to return or a `Hash` with pair key/values of virtually-generated or existing-modified attributes of the source/input data passed to the parser
81
+
82
+ ### Fixed
83
+ - **command line**
84
+ * `-search-soft` was being ignored in orgs with org config `session.config.people.strict_search = true`
85
+ * Log connection information (**enabled**): it was not printing where the connection was being made
86
+ * enabled chaining between usecases: they will be processed in the order they hold in the command line
87
+ - Removed error double backtrace (now it should only show one)
88
+ - `Eco::API::Common::People::EntryFactory#entries` was not using `encoding` parameter properly.
89
+ - `Eco::API::Common::People::DefaultParsers::CSVParser` does at `strip` (trim) of the header names.
90
+ - `Eco::API::Organization::PresetsFactory#merge` was including abilities that were not included in the custom presets
91
+ - fix: it will include only those that are defined, provided that using it will not override account abilities that should not be targeted, such as `tasks`
92
+ - this new behavior will preserve account abilities that should be preserved; not targeted by the custom presets
93
+ - some use cases where giving incorrect row number, fixed so they do:
94
+ - `Eco::API::Common::People::EntryFactory#entries` adds `idx` key to each `entry`
95
+ - `Eco::API::Common::People::PersonEntry`: serialization process has been normalized (previously there were missing fields)
96
+ - this fix makes the `csv` with the complete set of fields that should be exported
97
+ - `Ecoportal::API::Internal::Person#account_added` fixed typo
98
+ - `Ecoportal::API::Session::Batch#get_people` should return `Array<Person>` invariably
99
+
100
+ ## [1.5.1] - 2020-10-08
101
+
102
+ ### Added
103
+ - `presets_values.json`: added the new ability `tasks` (eP release `1.5.3`)
104
+ - `Ecoportal::API::Internal::Person` patch helper methods:
105
+ * `new?`: to know if this person is new in the people manager as a result of the current launch
106
+ * `account_added?`: to know if this person did not have account but they will have it after the current launch
107
+ - `Eco::API::Session#new_job`: to shorten code
108
+ - `Eco::API::Common::DefaultPasers::PolicyGroupsParser`: made native, as it is a very common parser
109
+ - `Eco::API::Common::DefaultPasers::FreemiumParser` to parse/serialise boolean
110
+ - `Eco::API::Common::People::PersonParser`: added `freemium` as core attribute
111
+ - `Eco::API::UserCases::DefaultCases::RecoverDBCase`: recovers also `freemium`
112
+ - scoping **microcases** : to be able to centralize common code between use cases
113
+ - at its early stage (currently not available for usage)
114
+ - dependency on `ecoportal-api-oozes` gem
115
+ - added basic support for **api** `v2`
116
+ - you can use `session.api(:oozes)` to obtain an api `v2`
117
+ - you can manage your keys directly on the apis configuration
118
+ - added `external_key:`, `user_key:` and `apis.default_user_key`
119
+
120
+ ```ruby
121
+ ASSETS.config do |config|
122
+ config.apis.default_user_key = 'your-user-key-here'
123
+
124
+ config.add_api("org-environment", {
125
+ host: 'pre.dev.ecoportal.com',
126
+ key: 'an-internal-org-api-key',
127
+ version: :internal,
128
+ external_key: 'an-external-org-api-key',
129
+ user_key: 'org-user-key-for-activity-stream',
130
+ mode: :local
131
+ })
132
+ end
133
+ ```
134
+ ### Changed
135
+ - internally: load `Eco::API::Common::Session` before `Eco::API::Common::People`
136
+ - `Eco::API::Common::People::EntryFactory`: made child of `Eco::API::Common::Session::BaseSession`
137
+ - refactored all the `api` connection creation for simplicity and to support multi api version
138
+ - delegated `Eco::API::Session::Batch#get` to `Ecoportal::API::V1::People#get_all`
139
+
140
+ ### Fixed
141
+ - correct `.gemspec` dependency version restrictions
142
+
143
+ ## [1.5.0] - 2020-09-11
144
+
145
+ ### Added
146
+ - `Eco::Data::Files#file_empty?` to prevent error when checking encoding
147
+ ### Changed
148
+ - change abilities to align with ecoPortal release `1.5.2`
149
+ ### Fixed
150
+ - `Eco::CSV#parse` and `Eco::CSV#read` should use the proper `encoding` when it's `bom`
151
+ * apparently, this can only be achieved by passing an argument such as `rb:bom|utf-8`
152
+ * best reference found: https://stackoverflow.com/a/60794851/4352306
10
153
 
11
154
  ## [1.4.2] - 2020-07-23
12
155
 
13
156
  ### Added
14
157
  ### Changed
15
158
  ### Fixed
16
- - preserve backtrace on logging
159
+ - preserve backtrace on logging
17
160
 
18
161
  ## [1.4.0] - 2020-07-14
19
162
 
@@ -84,7 +227,7 @@ All notable changes to this project will be documented in this file.
84
227
  - `Eco::API::Organization::TagTree#tag?` to accept `nil` by returning `false`
85
228
  - `Eco::API::Common::People::DefaultParsers::DateParser` will parse to `Date` class
86
229
  * it was parsing to `Time` class, while the native gem `ecoportal-api` parses as `Date` ([reference](https://gitlab.com/ecoPortal/ecoportal-api/-/blob/master/lib/ecoportal/api/v1/schema_field.rb))
87
- ## [1.3.11] - 2020-05-19
230
+ ## [1.3.12] - 2020-05-19
88
231
 
89
232
  ### Added
90
233
  ### Changed
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 ecoPortal
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -22,16 +22,17 @@ Gem::Specification.new do |s|
22
22
  #s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
23
23
  s.require_paths = ["lib"]
24
24
 
25
- s.add_development_dependency "bundler", "~> 2.1", ">= 2.1.3"
26
- s.add_development_dependency "rspec", "~> 3", ">= 3.9"
27
- s.add_development_dependency "rake", "~> 12.3.0"
28
- s.add_development_dependency "yard", "~> 0.9", ">= 0.9.18"
29
- s.add_development_dependency "redcarpet", "~> 3.5", ">= 3.5.0"
25
+ s.add_development_dependency "bundler", ">= 2.1.3", "< 2.2"
26
+ s.add_development_dependency "rspec", ">= 3.9", "< 4"
27
+ s.add_development_dependency "rake", ">= 12.3.0", "< 13"
28
+ s.add_development_dependency "yard", ">= 0.9.18", "< 0.10"
29
+ s.add_development_dependency "redcarpet", ">= 3.5.0", "< 3.6"
30
30
 
31
- s.add_dependency 'ecoportal-api', '~> 0.5', '>= 0.5.9'
32
- s.add_dependency 'aws-sdk-s3', '~> 1', '>= 1.64.0'
33
- s.add_dependency 'aws-sdk-ses', '~> 1', '>= 1.29.0'
34
- s.add_dependency 'dotenv', '~> 2.7', '>= 2.7.0'
35
- s.add_dependency 'net-sftp', '~> 2.1', '>= 2.1.2'
31
+ s.add_dependency 'ecoportal-api', '>= 0.7.3', '< 0.8'
32
+ s.add_dependency 'ecoportal-api-oozes', '>= 0.7.2', '< 0.8'
33
+ s.add_dependency 'aws-sdk-s3', '>= 1.64.0', '< 2'
34
+ s.add_dependency 'aws-sdk-ses', '>= 1.29.0', '< 2'
35
+ s.add_dependency 'dotenv', '>= 2.7.0', '< 2.8'
36
+ s.add_dependency 'net-sftp', '>= 2.1.2', '< 2.2'
36
37
 
37
38
  end
@@ -1,4 +1,5 @@
1
1
  require 'ecoportal/api'
2
+ require 'ecoportal/api-oozes'
2
3
 
3
4
  module Eco
4
5
  module API
@@ -6,7 +7,9 @@ module Eco
6
7
  end
7
8
 
8
9
  require_relative 'api/common'
10
+ require_relative 'api/custom'
9
11
  require_relative 'api/usecases'
12
+ require_relative 'api/microcases'
10
13
  require_relative 'api/policies'
11
14
  require_relative 'api/error'
12
15
  require_relative 'api/organization'
@@ -7,6 +7,10 @@ end
7
7
 
8
8
  require_relative 'common/version_patches'
9
9
  require_relative 'common/class_helpers'
10
+ require_relative 'common/class_auto_loader'
10
11
  require_relative 'common/class_hierarchy'
11
- require_relative 'common/people'
12
+ require_relative 'common/class_meta_basics'
13
+ require_relative 'common/base_loader'
14
+ require_relative 'common/loaders'
12
15
  require_relative 'common/session'
16
+ require_relative 'common/people'
@@ -0,0 +1,54 @@
1
+ module Eco
2
+ module API
3
+ module Common
4
+ class BaseLoader
5
+ extend Eco::API::Common::ClassHelpers
6
+
7
+ class << self
8
+ attr_writer :name, :type
9
+
10
+ # The name that this case, policy or error handler will have.
11
+ def name(value = nil)
12
+ name_only_once! if value
13
+ set_created_at!
14
+ return @name ||= self.to_s unless value
15
+ @name = value
16
+ end
17
+
18
+ # Sort order
19
+ def <=>(other)
20
+ created_at <=> other.created_at
21
+ end
22
+
23
+ # If still not set, it sets the `created_at` class timestamp.
24
+ def set_created_at!
25
+ @created_at = Time.now unless @created_at
26
+ end
27
+
28
+ # Class creation timestamp, to be able to load them in the order they were declared.
29
+ def created_at
30
+ @created_at ||= Time.now
31
+ end
32
+
33
+ # Prevent the same class to be re-opened/re-named
34
+ def name_only_once!
35
+ raise "You have already declared #{self} or you are trying to give it a name twice" if @name
36
+ end
37
+
38
+ end
39
+
40
+ # This method will be called when the BaseLoader is created
41
+ # @note
42
+ # - this method should implement the loading logics for the given `Children` class.
43
+ def initialize
44
+ raise "You should implement this method"
45
+ end
46
+
47
+ def name
48
+ self.class.name
49
+ end
50
+
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,109 @@
1
+ module Eco
2
+ module API
3
+ module Common
4
+ # Helpers for dynamic object loading based on class declaration
5
+ # @note
6
+ # - this helpers aim to boost the usage of the ruby language in complex api configurations.
7
+ module ClassAutoLoader
8
+ include Eco::API::Common::ClassHelpers
9
+
10
+ # To enable the class autoloader, you should use this method
11
+ def autoloads_children_of(klass)
12
+ class_resolver :autoloader_class, klass
13
+ @autoloaded_class = klass
14
+ end
15
+
16
+ # Resolves the class `autoloader_class` if it has been defined via `autoloads_children_of`
17
+ def autoloaded_class
18
+ return nil unless @autoloaded_class
19
+ autoloader_class
20
+ end
21
+
22
+ # To which restricted namespaces this class autoloads from
23
+ def autoloaded_namespaces(type = :include)
24
+ @autoloaded_namespaces ||= {}
25
+ @autoloaded_namespaces[type] ||= []
26
+ end
27
+
28
+ # To restrict which namespaces it is allowed to load from
29
+ def autoload_namespace(*namespaces)
30
+ _autoload_namespace(:include, *namespaces)
31
+ end
32
+
33
+ # To ignore certain namespaces this class should not autoload from
34
+ def autoload_namespace_ignore(*namespaces)
35
+ _autoload_namespace(:ignore, *namespaces)
36
+ end
37
+
38
+ def _autoload_namespace(type, *namespaces)
39
+ autoloaded_namespaces(type).concat(namespaces) unless namespaces.empty?
40
+ end
41
+
42
+ # @param constant [Class, String] a class or namespace we want to check auto-load entitlement thereof.
43
+ # @return [Boolean] determines if a given namespace is entitled for autoloading
44
+ def autoload_class?(constant)
45
+ constants = "#{constant}".split("::").compact
46
+ autoload = true
47
+ unless autoloaded_namespaces(:include).empty?
48
+ autoload = autoloaded_namespaces(:include).any? do |ns|
49
+ "#{ns}".split("::").compact.zip(constants).all? {|(r, c)| r == c}
50
+ end
51
+ end
52
+ unless autoloaded_namespaces(:ignore).empty?
53
+ autoload &&= autoloaded_namespaces(:ignore).none? do |ns|
54
+ "#{ns}".split("::").compact.zip(constants).all? {|(r, c)| r == c}
55
+ end
56
+ end
57
+ autoload
58
+ end
59
+
60
+ # As children are loaded as they are declared, we should not load twice same children.
61
+ def autoloaded_children
62
+ @auto_loaded_children ||= []
63
+ end
64
+
65
+ # Children classes of `autoloader_class` that have not been created an instance of.
66
+ def unloaded_children
67
+ return [] unless autoloaded_class
68
+ new_detected = new_classes
69
+ known_class!(*new_detected)
70
+ descendants(parent_class: autoloaded_class, scope: new_detected).select do |child_class|
71
+ !autoloaded_children.include?(child_class) && autoload_class?(child_class)
72
+ end.sort
73
+ end
74
+
75
+ # It loads/creates a new instance of children classes pending to be loaded.
76
+ # @return [Boolean] `true` if there were children loaded, `false` otherwise.
77
+ def autoload_children(object)
78
+ return false if !autoloaded_class || @loading_children
79
+ pending_children = unloaded_children
80
+ return false if pending_children.empty?
81
+ @loading_children = true
82
+ pending_children.each do |klass|
83
+ @child = klass.new(object)
84
+ autoloaded_children.push(klass)
85
+ end
86
+ @loading_children = false
87
+ true
88
+ end
89
+
90
+ # Known namespaces serves the purpose to discover recently added namespaces
91
+ # provided that the namespace discovery is optimized
92
+ def known_classes
93
+ @known_classes ||= []
94
+ end
95
+
96
+ # Add to known namespaces
97
+ def known_class!(*classes)
98
+ known_classes.concat(classes)
99
+ end
100
+
101
+ # List all new namespaces
102
+ def new_classes
103
+ ObjectSpace.each_object(::Class).to_a - known_classes
104
+ end
105
+
106
+ end
107
+ end
108
+ end
109
+ end
@@ -3,11 +3,14 @@ module Eco
3
3
  module Common
4
4
  module ClassHelpers
5
5
 
6
+ # Creates an class and instance object methods with name `name` to resolve `klass` name
6
7
  def class_resolver(name, klass)
7
8
  define_singleton_method(name) { resolve_class(klass) }
8
9
  define_method(name) { self.class.resolve_class(klass) }
9
10
  end
10
11
 
12
+ # With given a `klass` name it resolves to an actual `Class`
13
+ # @return [Class] the class that was being searched by name `klass`.
11
14
  def resolve_class(klass, exception: true)
12
15
  @resolved ||= {}
13
16
  @resolved[klass] ||=
@@ -59,6 +62,36 @@ module Eco
59
62
  end
60
63
  end
61
64
 
65
+ # Finds all child classes of the current class.
66
+ # @param parent_class [Class] the parent class we want to find children of.
67
+ # @param direct [Boolean] it will only include direct child classes.
68
+ # @param scope [nil, Array] to only look for descendants among the ones in `scope`.
69
+ # @return [Arrary<Class>] the child classes in hierarchy order.
70
+ def descendants(parent_class: self, direct: false, scope: nil)
71
+ scope ||= ObjectSpace.each_object(::Class)
72
+ return [] if scope.empty?
73
+ scope.select do |klass|
74
+ klass < parent_class
75
+ end.sort do |k1, k2|
76
+ next -1 if k2 < k1
77
+ next 1 if k1 < k2
78
+ 0
79
+ end.tap do |siblings|
80
+ if direct
81
+ siblings.reject! do |si|
82
+ siblings.any? {|s| si < s}
83
+ end
84
+ end
85
+ end
86
+ end
87
+
88
+ # @param parent_class [Class] the parent class we want to find children of.
89
+ # @param direct [Boolean] it will only include direct child classes.
90
+ # @return [Boolean] `true` if the current class has child classes, and `false` otherwise.
91
+ def descendants?(parent_class: self, direct: false)
92
+ descendants(parent_class: parent_class, direct: direct).length > 0
93
+ end
94
+
62
95
  end
63
96
  end
64
97
  end