eco-helpers 1.4.0 → 1.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +150 -2
- data/LICENSE +21 -0
- data/eco-helpers.gemspec +11 -10
- data/lib/eco/api.rb +3 -0
- data/lib/eco/api/common.rb +5 -1
- data/lib/eco/api/common/base_loader.rb +54 -0
- data/lib/eco/api/common/class_auto_loader.rb +109 -0
- data/lib/eco/api/common/class_helpers.rb +33 -0
- data/lib/eco/api/common/class_hierarchy.rb +1 -1
- data/lib/eco/api/common/class_meta_basics.rb +16 -0
- data/lib/eco/api/common/loaders.rb +13 -0
- data/lib/eco/api/common/loaders/error_handler.rb +41 -0
- data/lib/eco/api/common/loaders/parser.rb +127 -0
- data/lib/eco/api/common/loaders/policy.rb +25 -0
- data/lib/eco/api/common/loaders/use_case.rb +40 -0
- data/lib/eco/api/common/people/default_parsers.rb +5 -10
- data/lib/eco/api/common/people/default_parsers/boolean_parser.rb +13 -23
- data/lib/eco/api/common/people/default_parsers/csv_parser.rb +20 -35
- data/lib/eco/api/common/people/default_parsers/date_parser.rb +15 -26
- data/lib/eco/api/common/people/default_parsers/freemium_parser.rb +20 -0
- data/lib/eco/api/common/people/default_parsers/login_providers_parser.rb +26 -0
- data/lib/eco/api/common/people/default_parsers/multi_parser.rb +15 -27
- data/lib/eco/api/common/people/default_parsers/numeric_parser.rb +14 -19
- data/lib/eco/api/common/people/default_parsers/policy_groups_parser.rb +31 -0
- data/lib/eco/api/common/people/default_parsers/send_invites_parser.rb +15 -24
- data/lib/eco/api/common/people/entries.rb +54 -24
- data/lib/eco/api/common/people/entry_factory.rb +18 -15
- data/lib/eco/api/common/people/person_attribute_parser.rb +29 -12
- data/lib/eco/api/common/people/person_entry.rb +308 -216
- data/lib/eco/api/common/people/person_entry_attribute_mapper.rb +5 -2
- data/lib/eco/api/common/people/person_parser.rb +52 -19
- data/lib/eco/api/common/session/base_session.rb +3 -6
- data/lib/eco/api/common/session/environment.rb +2 -23
- data/lib/eco/api/common/session/logger.rb +4 -0
- data/lib/eco/api/common/version_patches/ecoportal_api/external_person.rb +2 -0
- data/lib/eco/api/common/version_patches/ecoportal_api/internal_person.rb +9 -1
- data/lib/eco/api/common/version_patches/exception.rb +24 -2
- data/lib/eco/api/custom.rb +13 -0
- data/lib/eco/api/custom/error_handler.rb +20 -0
- data/lib/eco/api/custom/namespace.rb +7 -0
- data/lib/eco/api/custom/parser.rb +50 -0
- data/lib/eco/api/custom/policy.rb +28 -0
- data/lib/eco/api/custom/use_case.rb +16 -0
- data/lib/eco/api/error.rb +1 -0
- data/lib/eco/api/error/handlers.rb +10 -3
- data/lib/eco/api/microcases.rb +35 -0
- data/lib/eco/api/microcases/account_excluded.rb +24 -0
- data/lib/eco/api/microcases/append_usergroups.rb +19 -0
- data/lib/eco/api/microcases/core_excluded.rb +20 -0
- data/lib/eco/api/microcases/fix_default_group.rb +34 -0
- data/lib/eco/api/microcases/fix_filter_tags.rb +42 -0
- data/lib/eco/api/microcases/people_cache.rb +17 -0
- data/lib/eco/api/microcases/people_load.rb +59 -0
- data/lib/eco/api/microcases/people_refresh.rb +31 -0
- data/lib/eco/api/microcases/people_search.rb +65 -0
- data/lib/eco/api/microcases/refresh_abilities.rb +19 -0
- data/lib/eco/api/microcases/refresh_default_tag.rb +27 -0
- data/lib/eco/api/microcases/s3upload_targets.rb +39 -0
- data/lib/eco/api/microcases/set_account.rb +20 -0
- data/lib/eco/api/microcases/set_core.rb +18 -0
- data/lib/eco/api/microcases/set_core_with_supervisor.rb +23 -0
- data/lib/eco/api/microcases/set_supervisor.rb +30 -0
- data/lib/eco/api/microcases/strict_search.rb +19 -0
- data/lib/eco/api/microcases/with_each.rb +27 -0
- data/lib/eco/api/microcases/with_each_leaver.rb +24 -0
- data/lib/eco/api/microcases/with_each_present.rb +30 -0
- data/lib/eco/api/microcases/with_each_starter.rb +30 -0
- data/lib/eco/api/microcases/with_each_subordinate.rb +34 -0
- data/lib/eco/api/microcases/with_supervisor.rb +36 -0
- data/lib/eco/api/organization/people.rb +72 -35
- data/lib/eco/api/organization/presets_factory.rb +13 -4
- data/lib/eco/api/organization/presets_reference.json +9 -1
- data/lib/eco/api/organization/presets_values.json +4 -1
- data/lib/eco/api/policies.rb +11 -7
- data/lib/eco/api/session.rb +62 -29
- data/lib/eco/api/session/batch.rb +2 -45
- data/lib/eco/api/session/batch/base_policy.rb +7 -6
- data/lib/eco/api/session/batch/errors.rb +28 -4
- data/lib/eco/api/session/batch/feedback.rb +7 -1
- data/lib/eco/api/session/batch/job.rb +40 -23
- data/lib/eco/api/session/batch/jobs.rb +9 -4
- data/lib/eco/api/session/batch/jobs_groups.rb +1 -1
- data/lib/eco/api/session/batch/request_stats.rb +91 -58
- data/lib/eco/api/session/batch/status.rb +35 -31
- data/lib/eco/api/session/config.rb +106 -44
- data/lib/eco/api/session/config/api.rb +132 -7
- data/lib/eco/api/session/config/apis.rb +24 -25
- data/lib/eco/api/session/config/logger.rb +2 -2
- data/lib/eco/api/session/config/post_launch.rb +1 -1
- data/lib/eco/api/session/config/workflow.rb +8 -7
- data/lib/eco/api/usecases.rb +47 -33
- data/lib/eco/api/usecases/backup/append_usergroups_case.rb +36 -0
- data/lib/eco/api/usecases/backup/create_case.rb +104 -0
- data/lib/eco/api/usecases/backup/create_details_case.rb +31 -0
- data/lib/eco/api/usecases/backup/create_details_with_supervisor_case.rb +48 -0
- data/lib/eco/api/usecases/backup/hris_case.rb +124 -0
- data/lib/eco/api/usecases/backup/set_default_tag_case.rb +49 -0
- data/lib/eco/api/usecases/backup/set_supervisor_case.rb +41 -0
- data/lib/eco/api/usecases/backup/transfer_account_case.rb +90 -0
- data/lib/eco/api/usecases/backup/update_case.rb +112 -0
- data/lib/eco/api/usecases/backup/update_details_case.rb +64 -0
- data/lib/eco/api/usecases/backup/upsert_case.rb +114 -0
- data/lib/eco/api/usecases/base_case.rb +2 -0
- data/lib/eco/api/usecases/base_io.rb +3 -3
- data/lib/eco/api/usecases/default_cases.rb +23 -53
- data/lib/eco/api/usecases/default_cases/append_usergroups_case.rb +10 -31
- data/lib/eco/api/usecases/default_cases/change_email_case.rb +23 -47
- data/lib/eco/api/usecases/default_cases/codes_to_tags_case.rb +56 -43
- data/lib/eco/api/usecases/default_cases/create_case.rb +15 -101
- data/lib/eco/api/usecases/default_cases/create_details_case.rb +11 -26
- data/lib/eco/api/usecases/default_cases/create_details_with_supervisor_case.rb +12 -43
- data/lib/eco/api/usecases/default_cases/delete_sync_case.rb +11 -0
- data/lib/eco/api/usecases/default_cases/delete_trans_case.rb +14 -0
- data/lib/eco/api/usecases/default_cases/email_as_id_case.rb +10 -21
- data/lib/eco/api/usecases/default_cases/hris_case.rb +23 -120
- data/lib/eco/api/usecases/default_cases/new_email_case.rb +10 -23
- data/lib/eco/api/usecases/default_cases/new_id_case.rb +11 -25
- data/lib/eco/api/usecases/default_cases/new_id_case0.rb +14 -0
- data/lib/eco/api/usecases/default_cases/org_data_convert_case.rb +83 -0
- data/lib/eco/api/usecases/default_cases/refresh_abilities_case.rb +30 -0
- data/lib/eco/api/usecases/default_cases/refresh_case.rb +7 -20
- data/lib/eco/api/usecases/default_cases/reinvite_sync_case.rb +11 -0
- data/lib/eco/api/usecases/default_cases/reinvite_trans_case.rb +17 -0
- data/lib/eco/api/usecases/default_cases/remove_account_sync_case.rb +11 -0
- data/lib/eco/api/usecases/default_cases/remove_account_trans_case.rb +17 -0
- data/lib/eco/api/usecases/default_cases/reset_landing_page_case.rb +9 -19
- data/lib/eco/api/usecases/default_cases/restore_db_case.rb +92 -0
- data/lib/eco/api/usecases/default_cases/set_default_tag_case.rb +32 -40
- data/lib/eco/api/usecases/default_cases/set_supervisor_case.rb +15 -33
- data/lib/eco/api/usecases/default_cases/switch_supervisor_case.rb +66 -57
- data/lib/eco/api/usecases/default_cases/to_csv_case.rb +36 -44
- data/lib/eco/api/usecases/default_cases/to_csv_detailed_case.rb +40 -55
- data/lib/eco/api/usecases/default_cases/transfer_account_case.rb +264 -84
- data/lib/eco/api/usecases/default_cases/update_case.rb +15 -109
- data/lib/eco/api/usecases/default_cases/update_details_case.rb +14 -61
- data/lib/eco/api/usecases/default_cases/upsert_case.rb +16 -111
- data/lib/eco/api/usecases/use_case_io.rb +9 -9
- data/lib/eco/cli/config.rb +10 -2
- data/lib/eco/cli/config/default.rb +2 -1
- data/lib/eco/cli/config/default/input_filters.rb +58 -0
- data/lib/eco/cli/config/default/options.rb +60 -25
- data/lib/eco/cli/config/default/people.rb +4 -4
- data/lib/eco/cli/config/default/people_filters.rb +108 -0
- data/lib/eco/cli/config/default/usecases.rb +69 -32
- data/lib/eco/cli/config/default/workflow.rb +37 -27
- data/lib/eco/cli/config/filters.rb +50 -0
- data/lib/eco/cli/config/filters/input_filters.rb +29 -0
- data/lib/eco/cli/config/filters/people_filters.rb +29 -0
- data/lib/eco/cli/config/help.rb +49 -0
- data/lib/eco/cli/config/options_set.rb +17 -1
- data/lib/eco/cli/config/use_cases.rb +79 -53
- data/lib/eco/cli/scripting.rb +10 -2
- data/lib/eco/cli/scripting/args_helpers.rb +25 -15
- data/lib/eco/cli/scripting/argument.rb +1 -0
- data/lib/eco/cli/scripting/arguments.rb +1 -1
- data/lib/eco/csv.rb +8 -3
- data/lib/eco/csv/table.rb +1 -1
- data/lib/eco/data/crypto/encryption.rb +3 -0
- data/lib/eco/data/files/helpers.rb +6 -1
- data/lib/eco/language/match.rb +19 -9
- data/lib/eco/language/match_modifier.rb +13 -5
- data/lib/eco/language/models/collection.rb +77 -56
- data/lib/eco/language/models/parser_serializer.rb +39 -15
- data/lib/eco/version.rb +1 -1
- metadata +149 -63
- data/lib/eco/api/session/task.rb +0 -175
- data/lib/eco/api/usecases/default_case.rb +0 -19
- data/lib/eco/api/usecases/default_cases/delete_case.rb +0 -32
- data/lib/eco/api/usecases/default_cases/recover_db_case.rb +0 -98
- data/lib/eco/api/usecases/default_cases/refresh_presets_case.rb +0 -26
- data/lib/eco/api/usecases/default_cases/reinvite_case.rb +0 -41
- data/lib/eco/api/usecases/default_cases/remove_account_case.rb +0 -38
- data/lib/eco/cli/config/default/filters.rb +0 -70
- 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: afef384678f171e737391056ca300ac9d9c813240d32422445ad1e256911be31
|
4
|
+
data.tar.gz: 82f7b611239cc9e5d58778d1db9ffaef7cef748360fd82abeba3df710c56ac60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6516df10c5fbf6d48f8fa5bfdb993320a15043fecdcbe84c2927c6c84ab9fd817d298f9ae0806a6e43476d2342e862fbecb55ed14fc532bc4cf007f32a9ff7e6
|
7
|
+
data.tar.gz: 13763cf62b5d0741d0d23837f66480fcf678ac317d6ac726cdea0fbd12cb4ce048b57e3278053536c214661f9aa591a90a22e06b5a24720bba087459c6536d72
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,148 @@
|
|
1
1
|
# Change Log
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
-
## [1.
|
4
|
+
## [1.5.2] - 2020-10-29
|
5
|
+
|
6
|
+
### Added
|
7
|
+
- **custom** usecases, policies and error handlers can now be **declared within its own class**
|
8
|
+
* helper classes to inherit from: `Eco::API::Custom::UseCase`, `Eco::API::Custom::Policy`, `Eco::API::Custom::ErrorHandler` and `Eco::API::Custom::Parser`
|
9
|
+
* please, notice that you should create new classes under the following namespaces
|
10
|
+
- `Custom::UseCase`: custom use cases
|
11
|
+
- `Custom::Policy`: custom policy
|
12
|
+
- `Custom::ErrorHandler`: custom error handler
|
13
|
+
- `Custom::Parser`: custom parser
|
14
|
+
* this also allows to inherit from existing defaults and models (models to come)
|
15
|
+
- implemented first **microcases** (evaluation stage): to be able to centralize common code between use cases
|
16
|
+
- see `Eco::API::MicroCases` class
|
17
|
+
- **command line** added `--help` to list all `usecases`, `options` and `filters`
|
18
|
+
* `--help -options` will print a documented overview of options
|
19
|
+
* `--help -filters` will print a documented overview of people filters
|
20
|
+
* `--help -input-filters` will print a documented overview of input data filters
|
21
|
+
* `--help -usecases` will print a documented overview of the usecases
|
22
|
+
- **command line** filters for `filter_tags` on:
|
23
|
+
* input data: `-input-filter-tags-all`, `input-filter-tags-any`, `input-filter-tags-tree`
|
24
|
+
* people data: `-filter-tags-all`, `-filter-tags-any`, `-filter-tags-tree`
|
25
|
+
- **batch stats** & **batch policy**
|
26
|
+
* `Eco::API::Session::Batch::RequestStats`: included additional guide on what has been **blanked**.
|
27
|
+
- now on you should see how many have been blanked, i.e.: `blanked_email`, `blanked_filter_tags`, `blanked_policy_group_ids`, `blanked_supervisor_id`
|
28
|
+
* 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**
|
29
|
+
- **csv** generation (`-people-to-csv` and `-people-to-csv -detailed`):
|
30
|
+
* now includes `"Has Account?"` new column
|
31
|
+
* removed the useless `send_invites` column
|
32
|
+
- **errors** improved error message when setting values to a `person` from an `entry`:
|
33
|
+
* it now shows the **row number**
|
34
|
+
* it now gives the specific value that failed in case of `Exception`
|
35
|
+
- `Eco::API::Common::DefaultPasers::LoginProvidersParser`: made native
|
36
|
+
- `Eco::API::UseCases::DefaultUsecases::TransferAccountCase`: added `-transer-account-from` usecase
|
37
|
+
* to allow actually transfer an account/user from one person to another in the org
|
38
|
+
- `Ecoportal::API::V1::Person#entry`: method to be able to have a reference to the update/creation input data entry.
|
39
|
+
- new filter methods for `Eco::API::Common::People::Entries` and `Eco::API::Organization::People`
|
40
|
+
* `#filter_tags_any` & `#filter_tags_all`: those that have any or all the target tags
|
41
|
+
* `#policy_group_ids_any` & `#policy_groups_all`: those that have any or all the target policy groups
|
42
|
+
|
43
|
+
### Changed
|
44
|
+
- updated dependency on `ecoportal-api` gem
|
45
|
+
- **command line** some changes:
|
46
|
+
- renamed `-refresh-presets` to `-refresh-abilities`
|
47
|
+
- renamed `-recover-db` to `restore-db`
|
48
|
+
- removed `Eco::API::Session::Tasks`: all the helpers have been moved and documented as part of `Eco::API::MicroCases` (some have been renamed)
|
49
|
+
- as a consequence, removed method `Eco::API::Session#do`
|
50
|
+
- `Eco::API::Common::People::PersonEntry#to_hash` has been removed
|
51
|
+
- now you should use the more explicit `Eco::API::Common::People::PersonEntry#external_entry`
|
52
|
+
- **internal refactor** of `Eco::API::UseCases::DefaultCases`:
|
53
|
+
* made so they inherit from `Eco::API::Common::Loaders::UseCase` and cases are autoloaded during run-time
|
54
|
+
- **internal refactor** of input entries processing:
|
55
|
+
* `Eco::API::Common::People::PersonEntry` internal refactor
|
56
|
+
- need to make the code clearer and make the `parsing` and `serializing` symmetrical
|
57
|
+
- the `serializers` were expecting an `Ecoportal::API::V1::Person`, which was at a different to that of when the `parsers` kicked in.
|
58
|
+
- now it has been introduced the possibility to launch the serializer in a different stage of the process
|
59
|
+
- 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...
|
60
|
+
* `Eco::Language::Models::ParserSerializer` offers `category` parameter so you can have multiple parsers and serializers per each parser/serializer (one per category).
|
61
|
+
* `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
|
62
|
+
- for `parser` valid **phases** are `:internal` (default) and `:final`
|
63
|
+
- for `serializer` valid **phases** are `:person` (default), `:final` and `:internal`
|
64
|
+
- 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
|
65
|
+
|
66
|
+
### Fixed
|
67
|
+
- **command line**
|
68
|
+
* `-search-soft` was being ignored in orgs with org config `session.config.people.strict_search = true`
|
69
|
+
* Log connection information (**enabled**): it was not printing where the connection was being made
|
70
|
+
* enabled chaining between usecases: they will be processed in the order they hold in the command line
|
71
|
+
- Removed error double backtrace (now it should only show one)
|
72
|
+
- `Eco::API::Common::People::EntryFactory#entries` was not using `encoding` parameter properly.
|
73
|
+
- `Eco::API::Common::People::DefaultParsers::CSVParser` does at `strip` (trim) of the header names.
|
74
|
+
- `Eco::API::Organization::PresetsFactory#merge` was including abilities that were not included in the custom presets
|
75
|
+
- 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`
|
76
|
+
- this new behavior will preserve account abilities that should be preserved; not targeted by the custom presets
|
77
|
+
- some use cases where giving incorrect row number, fixed so they do:
|
78
|
+
- `Eco::API::Common::People::EntryFactory#entries` adds `idx` key to each `entry`
|
79
|
+
- `Eco::API::Common::People::PersonEntry`: serialization process has been normalized (previously there were missing fields)
|
80
|
+
- this fix makes the `csv` with the complete set of fields that should be exported
|
81
|
+
- `Ecoportal::API::Internal::Person#account_added` fixed typo
|
82
|
+
- `Ecoportal::API::Session::Batch#get_people` should return `Array<Person>` invariably
|
83
|
+
|
84
|
+
## [1.5.1] - 2020-10-08
|
85
|
+
|
86
|
+
### Added
|
87
|
+
- `presets_values.json`: added the new ability `tasks` (eP release `1.5.3`)
|
88
|
+
- `Ecoportal::API::Internal::Person` patch helper methods:
|
89
|
+
* `new?`: to know if this person is new in the people manager as a result of the current launch
|
90
|
+
* `account_added?`: to know if this person did not have account but they will have it after the current launch
|
91
|
+
- `Eco::API::Session#new_job`: to shorten code
|
92
|
+
- `Eco::API::Common::DefaultPasers::PolicyGroupsParser`: made native, as it is a very common parser
|
93
|
+
- `Eco::API::Common::DefaultPasers::FreemiumParser` to parse/serialise boolean
|
94
|
+
- `Eco::API::Common::People::PersonParser`: added `freemium` as core attribute
|
95
|
+
- `Eco::API::UserCases::DefaultCases::RecoverDBCase`: recovers also `freemium`
|
96
|
+
- scoping **microcases** : to be able to centralize common code between use cases
|
97
|
+
- at its early stage (currently not available for usage)
|
98
|
+
- dependency on `ecoportal-api-oozes` gem
|
99
|
+
- added basic support for **api** `v2`
|
100
|
+
- you can use `session.api(:oozes)` to obtain an api `v2`
|
101
|
+
- you can manage your keys directly on the apis configuration
|
102
|
+
- added `external_key:`, `user_key:` and `apis.default_user_key`
|
103
|
+
|
104
|
+
```ruby
|
105
|
+
ASSETS.config do |config|
|
106
|
+
config.apis.default_user_key = 'your-user-key-here'
|
107
|
+
|
108
|
+
config.add_api("org-environment", {
|
109
|
+
host: 'pre.dev.ecoportal.com',
|
110
|
+
key: 'an-internal-org-api-key',
|
111
|
+
version: :internal,
|
112
|
+
external_key: 'an-external-org-api-key',
|
113
|
+
user_key: 'org-user-key-for-activity-stream',
|
114
|
+
mode: :local
|
115
|
+
})
|
116
|
+
end
|
117
|
+
```
|
118
|
+
### Changed
|
119
|
+
- internally: load `Eco::API::Common::Session` before `Eco::API::Common::People`
|
120
|
+
- `Eco::API::Common::People::EntryFactory`: made child of `Eco::API::Common::Session::BaseSession`
|
121
|
+
- refactored all the `api` connection creation for simplicity and to support multi api version
|
122
|
+
- delegated `Eco::API::Session::Batch#get` to `Ecoportal::API::V1::People#get_all`
|
123
|
+
|
124
|
+
### Fixed
|
125
|
+
- correct `.gemspec` dependency version restrictions
|
126
|
+
|
127
|
+
## [1.5.0] - 2020-09-11
|
128
|
+
|
129
|
+
### Added
|
130
|
+
- `Eco::Data::Files#file_empty?` to prevent error when checking encoding
|
131
|
+
### Changed
|
132
|
+
- change abilities to align with ecoPortal release `1.5.2`
|
133
|
+
### Fixed
|
134
|
+
- `Eco::CSV#parse` and `Eco::CSV#read` should use the proper `encoding` when it's `bom`
|
135
|
+
* apparently, this can only be achieved by passing an argument such as `rb:bom|utf-8`
|
136
|
+
* best reference found: https://stackoverflow.com/a/60794851/4352306
|
137
|
+
|
138
|
+
## [1.4.2] - 2020-07-23
|
139
|
+
|
140
|
+
### Added
|
141
|
+
### Changed
|
142
|
+
### Fixed
|
143
|
+
- preserve backtrace on logging
|
144
|
+
|
145
|
+
## [1.4.0] - 2020-07-14
|
5
146
|
|
6
147
|
### Added
|
7
148
|
### Changed
|
@@ -11,6 +152,13 @@ All notable changes to this project will be documented in this file.
|
|
11
152
|
### Fixed
|
12
153
|
- `Eco::CSV#parse` and `Eco::CSV#read` should use the proper `:encoding` when it's `bom`
|
13
154
|
|
155
|
+
## [1.3.19] - 2020-07-23
|
156
|
+
|
157
|
+
### Added
|
158
|
+
### Changed
|
159
|
+
### Fixed
|
160
|
+
- preserve backtrace on logging
|
161
|
+
|
14
162
|
## [1.3.18] - 2020-07-08
|
15
163
|
|
16
164
|
### Added
|
@@ -63,7 +211,7 @@ All notable changes to this project will be documented in this file.
|
|
63
211
|
- `Eco::API::Organization::TagTree#tag?` to accept `nil` by returning `false`
|
64
212
|
- `Eco::API::Common::People::DefaultParsers::DateParser` will parse to `Date` class
|
65
213
|
* 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))
|
66
|
-
## [1.3.
|
214
|
+
## [1.3.12] - 2020-05-19
|
67
215
|
|
68
216
|
### Added
|
69
217
|
### 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.
|
data/eco-helpers.gemspec
CHANGED
@@ -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", "
|
26
|
-
s.add_development_dependency "rspec", "
|
27
|
-
s.add_development_dependency "rake", "
|
28
|
-
s.add_development_dependency "yard", "
|
29
|
-
s.add_development_dependency "redcarpet", "
|
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', '
|
32
|
-
s.add_dependency '
|
33
|
-
s.add_dependency 'aws-sdk-
|
34
|
-
s.add_dependency '
|
35
|
-
s.add_dependency '
|
31
|
+
s.add_dependency 'ecoportal-api', '>= 0.7.2', '< 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
|
data/lib/eco/api.rb
CHANGED
@@ -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'
|
data/lib/eco/api/common.rb
CHANGED
@@ -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/
|
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
|