eco-helpers 3.0.26 → 3.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +76 -5
- data/eco-helpers.gemspec +2 -1
- data/lib/eco/api/common/class_helpers.rb +1 -136
- data/lib/eco/api/common/loaders/base.rb +1 -1
- data/lib/eco/api/common/loaders/case_base.rb +1 -1
- data/lib/eco/api/common/loaders/config/cli.rb +1 -1
- data/lib/eco/api/common/loaders/config/session.rb +1 -1
- data/lib/eco/api/common/loaders/config/workflow.rb +1 -1
- data/lib/eco/api/common/loaders/config.rb +2 -5
- data/lib/eco/api/common/loaders/error_handler.rb +1 -1
- data/lib/eco/api/common/loaders/parser.rb +2 -2
- data/lib/eco/api/common/loaders/policy.rb +1 -1
- data/lib/eco/api/common/loaders/use_case/target_model.rb +1 -1
- data/lib/eco/api/common/loaders/use_case/type.rb +1 -1
- data/lib/eco/api/common/loaders/use_case.rb +1 -1
- data/lib/eco/api/common/people/default_parsers/archived_parser.rb +19 -0
- data/lib/eco/api/common/people/default_parsers/boolean_parser.rb +4 -4
- data/lib/eco/api/common/people/default_parsers/date_parser.rb +3 -3
- data/lib/eco/api/common/people/default_parsers/freemium_parser.rb +6 -6
- data/lib/eco/api/common/people/default_parsers/login_providers_parser.rb +3 -3
- data/lib/eco/api/common/people/default_parsers/multi_parser.rb +4 -4
- data/lib/eco/api/common/people/default_parsers/policy_groups_parser.rb +9 -6
- data/lib/eco/api/common/people/default_parsers/send_invites_parser.rb +6 -5
- data/lib/eco/api/common/people/default_parsers/xls_parser.rb +2 -2
- data/lib/eco/api/common/people/default_parsers.rb +1 -0
- data/lib/eco/api/common/people/entries.rb +16 -15
- data/lib/eco/api/common/people/person_entry.rb +53 -37
- data/lib/eco/api/common/people/person_parser.rb +8 -6
- data/lib/eco/api/common/people/supervisor_helpers.rb +3 -1
- data/lib/eco/api/common/session/logger/channels.rb +2 -1
- data/lib/eco/api/common/session/logger.rb +2 -2
- data/lib/eco/api/common/session/mailer/aws_provider.rb +3 -2
- data/lib/eco/api/common/session/mailer/provider_base.rb +2 -1
- data/lib/eco/api/common/session/mailer/sendgrid_provider.rb +9 -9
- data/lib/eco/api/common/session/mailer.rb +5 -3
- data/lib/eco/api/common/session/sftp.rb +11 -4
- data/lib/eco/api/common/version_patches/object.rb +2 -1
- data/lib/eco/api/custom/mailer.rb +1 -1
- data/lib/eco/api/error/handlers.rb +3 -3
- data/lib/eco/api/error.rb +17 -17
- data/lib/eco/api/microcases/people/apply_changes/set_account/account_excluded.rb +3 -11
- data/lib/eco/api/microcases/people/apply_changes/set_core/core_excluded.rb +4 -1
- data/lib/eco/api/microcases/people/manage/search.rb +3 -1
- data/lib/eco/api/organization/people.rb +1 -0
- data/lib/eco/api/policies.rb +2 -2
- data/lib/eco/api/session/batch/job/sets.rb +1 -0
- data/lib/eco/api/session/batch/job/type.rb +1 -0
- data/lib/eco/api/session/batch/job.rb +2 -2
- data/lib/eco/api/session/batch/launcher/valid_methods.rb +3 -2
- data/lib/eco/api/session/batch/launcher.rb +4 -5
- data/lib/eco/api/session/batch/searcher.rb +4 -4
- data/lib/eco/api/session/config/api.rb +2 -2
- data/lib/eco/api/session/config/apis/enviro_spaces.rb +2 -2
- data/lib/eco/api/session/config/post_launch.rb +7 -4
- data/lib/eco/api/session/config/sftp.rb +1 -1
- data/lib/eco/api/session/config/tagtree.rb +1 -1
- data/lib/eco/api/session/config/workflow.rb +4 -4
- data/lib/eco/api/session/config.rb +25 -24
- data/lib/eco/api/session.rb +4 -4
- data/lib/eco/api/usecases/base_case/model.rb +2 -1
- data/lib/eco/api/usecases/base_case/type.rb +2 -1
- data/lib/eco/api/usecases/base_io/validations.rb +6 -4
- data/lib/eco/api/usecases/cli/option.rb +5 -2
- data/lib/eco/api/usecases/default/people/amend/clear_abilities_case.rb +2 -2
- data/lib/eco/api/usecases/default/people/amend/restore_db_case.rb +16 -9
- data/lib/eco/api/usecases/default/people/treat/analyse_people_case.rb +20 -20
- data/lib/eco/api/usecases/default.rb +5 -5
- data/lib/eco/api/usecases/default_cases/to_csv_case.rb +8 -8
- data/lib/eco/api/usecases/default_cases/upsert_case.rb +4 -4
- data/lib/eco/api/usecases/graphql/helpers/base.rb +1 -1
- data/lib/eco/api/usecases/graphql/helpers/location/base/tree_tracking.rb +5 -1
- data/lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb +5 -3
- data/lib/eco/api/usecases/graphql/helpers/location/command/result.rb +3 -3
- data/lib/eco/api/usecases/graphql/helpers/location/command.rb +3 -0
- data/lib/eco/api/usecases/graphql/samples/location/command/dsl.rb +2 -2
- data/lib/eco/api/usecases/graphql/samples/location/command/service/tree_update.rb +9 -3
- data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/inputable.rb +5 -4
- data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing.rb +5 -2
- data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff.rb +3 -3
- data/lib/eco/api/usecases/graphql/utils/sftp.rb +1 -1
- data/lib/eco/api/usecases/lib/{file_pattern.rb → files/file_pattern.rb} +1 -1
- data/lib/eco/api/usecases/lib/{sftp.rb → files/sftp.rb} +19 -7
- data/lib/eco/api/usecases/lib/files.rb +7 -0
- data/lib/eco/api/usecases/lib.rb +1 -2
- data/lib/eco/api/usecases/ooze_cases/export_register_case.rb +5 -5
- data/lib/eco/api/usecases/ooze_samples/helpers/exportable_ooze.rb +14 -11
- data/lib/eco/api/usecases/ooze_samples/helpers_migration/copying.rb +14 -23
- data/lib/eco/api/usecases/ooze_samples/helpers_migration/typed_fields_pairing.rb +49 -27
- data/lib/eco/api/usecases/ooze_samples/ooze_base_case.rb +9 -9
- data/lib/eco/api/usecases/ooze_samples/ooze_run_base_case.rb +1 -1
- data/lib/eco/api/usecases/ooze_samples/register_export_case.rb +25 -17
- data/lib/eco/api/usecases/ooze_samples/register_migration_case.rb +41 -24
- data/lib/eco/api/usecases/ooze_samples/register_update_case.rb +16 -15
- data/lib/eco/api/usecases/samples/drivers/cli/sftp_cli.rb +15 -15
- data/lib/eco/api/usecases/samples/drivers/cli/url_pull_cli.rb +5 -5
- data/lib/eco/api/usecases/samples/drivers/sftp_sample.rb +5 -3
- data/lib/eco/api/usecases/use_case.rb +6 -6
- data/lib/eco/api/usecases/use_case_chain/chaining.rb +6 -6
- data/lib/eco/api/usecases/use_case_chain.rb +4 -4
- data/lib/eco/api/usecases/use_case_io.rb +2 -1
- data/lib/eco/api/usecases.rb +9 -9
- data/lib/eco/cli/config/options_set.rb +4 -4
- data/lib/eco/cli/config/use_cases.rb +3 -3
- data/lib/eco/cli/scripting/argument.rb +1 -1
- data/lib/eco/cli_default/input.rb +9 -9
- data/lib/eco/cli_default/options.rb +125 -100
- data/lib/eco/cli_default/people.rb +3 -3
- data/lib/eco/cli_default/usecases.rb +83 -83
- data/lib/eco/cli_default/workflow.rb +7 -7
- data/lib/eco/data/files/helpers.rb +7 -5
- data/lib/eco/data/fuzzy_match/result.rb +69 -26
- data/lib/eco/data/fuzzy_match/results.rb +10 -10
- data/lib/eco/data/fuzzy_match/score.rb +13 -8
- data/lib/eco/data/fuzzy_match.rb +69 -50
- data/lib/eco/data/hashes/diff_result/meta.rb +2 -1
- data/lib/eco/data/locations/node_base/treeify.rb +13 -11
- data/lib/eco/data/locations/node_diff/accessors.rb +2 -1
- data/lib/eco/data/mapper.rb +4 -4
- data/lib/eco/language/auxiliar_logger.rb +4 -4
- data/lib/eco/language/delegation/chainable_delegator.rb +18 -0
- data/lib/eco/language/delegation/delegating_missing.rb +104 -0
- data/lib/eco/language/delegation/delegating_missing_const.rb +53 -0
- data/lib/eco/language/delegation/delegating_missing_on_class.rb +53 -0
- data/lib/eco/language/delegation/for_delegator/const_delegator.rb +66 -0
- data/lib/eco/language/delegation/for_delegator/const_lookup_hooks.rb +99 -0
- data/lib/eco/language/delegation/for_delegator/delegated_class.rb +71 -0
- data/lib/eco/language/delegation/for_delegator.rb +11 -0
- data/lib/eco/language/delegation.rb +10 -0
- data/lib/eco/language/klass/builder.rb +29 -0
- data/lib/eco/language/klass/helpers_built.rb +9 -0
- data/lib/eco/language/klass/hierarchy.rb +34 -0
- data/lib/eco/language/klass/inheritable_class_vars.rb +45 -0
- data/lib/eco/language/klass/naming.rb +21 -0
- data/lib/eco/language/klass/resolver.rb +30 -0
- data/lib/eco/language/klass/when_inherited.rb +11 -13
- data/lib/eco/language/klass.rb +6 -0
- data/lib/eco/language/methods.rb +0 -1
- data/lib/eco/language/models/class_helpers.rb +25 -23
- data/lib/eco/language/models/collection.rb +12 -2
- data/lib/eco/language/strings/underscore.rb +17 -0
- data/lib/eco/language/strings.rb +8 -0
- data/lib/eco/language.rb +2 -0
- data/lib/eco/version.rb +1 -1
- metadata +39 -7
- data/lib/eco/language/methods/delegate_missing.rb +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f36ef48b8d70b2ac8b50e32a823d99d8bec5e32a76975357cf2298a6247a694
|
4
|
+
data.tar.gz: 60c6b240668df642d9bba41bc67011a02f7602e143aaabc2e4a25d2f9aa5d5dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70393a40919bf80751385734885c88914a80acc47a80d5a068be431b4abd2e9677d8e1707dbeaf8510de49dc519d00441df3ffe2bed4ee8f50663895caf2e778
|
7
|
+
data.tar.gz: 44cc94d912bdcee5ec8140ce8d78a0b2a10feb8c609944147446e4337641ca53394ee3e798b17d970cae887b07313ed511a4840e47af7fa903595311a5923eba
|
data/CHANGELOG.md
CHANGED
@@ -2,19 +2,90 @@
|
|
2
2
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
|
5
|
-
## [3.0.
|
5
|
+
## [3.0.29] - 2025-03-xx
|
6
6
|
|
7
7
|
### Added
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
### Changed
|
10
|
+
|
11
|
+
### Fixed
|
12
|
+
|
13
|
+
## [3.0.28] - 2025-03-31
|
14
|
+
|
15
|
+
### Added
|
16
|
+
|
17
|
+
- `Language::Delegation::DelegatingMissing` (rails alike, but ending with `ing`).
|
18
|
+
- `Language::Delegation::DelegatingMissingConst`.
|
19
|
+
- `Language::Delegation::ChainableDelegator`
|
20
|
+
- `Language::Strings::Underscore`
|
21
|
+
- `Eco::API::UseCases::Lib::Files::Sftp`
|
22
|
+
- **Added** named argument `only_latest` to fetch only latest file (**newest**).
|
13
23
|
|
14
24
|
### Changed
|
15
25
|
|
26
|
+
- `Eco::API::UseCases::Lib::Files::Sftp#local_folder`
|
27
|
+
- **Remove** default to `.` (current/root directory).
|
28
|
+
- **Moved** `Language::Methods::DelegateMissing` to `Language::Delegation::DelegatingMissingOnClass`
|
29
|
+
- **Renamed** `::delegate_missing_to` to `::delegating_missing_on_class_to`
|
30
|
+
- **Moved** `DelegatedClass`, `ConstDelegator` and `ConstLookupHooks` from `Language::Delegation` to `Language::Delegation::ForDelegator`
|
31
|
+
- `DelegatedClass`
|
32
|
+
- **Moved** `#initialize` to the **new** `ChainableDelegator` sample
|
33
|
+
- **Moved** requirement for base to be a `Delegator` or subclass thereof.
|
34
|
+
- The requirement is now part of `ConstLookupHooks`, as this particular concern only makes sense on `Delegator` subclasses.
|
35
|
+
- **Moved** (by keeping backwards compatibility) `Eco::API::Common::ClassHelpers` to decoupled helpers in `Eco::Language::Klass`
|
36
|
+
- **Manage Exception** on `Eco::API::Common::Session::SFTP#upload`
|
37
|
+
- **Added** remote `dest_file` feedback
|
38
|
+
|
16
39
|
### Fixed
|
17
40
|
|
41
|
+
- **Remove** recursive call on `Lib::Files::FilePattern#file_pattern_const`
|
42
|
+
|
43
|
+
## [3.0.27] - 2025-03-29
|
44
|
+
|
45
|
+
### Added
|
46
|
+
|
47
|
+
- For `Ecoportal::API::V1::Person#archived` (**archived** flag)
|
48
|
+
- `PersonParser::CORE_ATTRS`: **exposed** `archived`
|
49
|
+
- Added `DefaultParsers::ArchivedParser`
|
50
|
+
- **Options** to **exclude** `archived`
|
51
|
+
- `PersonEntry`
|
52
|
+
- added methods `#archived` and `archived_key?`
|
53
|
+
- **enforced** `boolan` parsing and serializing
|
54
|
+
- For `Ecoportal::API::V1::Person#contractor_organization_id`
|
55
|
+
- Added **option** to `exclude-contractor-organization` from people updates.
|
56
|
+
- `PersonEntry`
|
57
|
+
- added methods `#contractor_organization_id` and `contractor_organization_id?`
|
58
|
+
- Updated `restore-db` case with the new exclusions
|
59
|
+
- Included copying of `contractor_organization_id` and `archived`
|
60
|
+
- `Eco::Language::Delegation`
|
61
|
+
- See usage at <https://stackoverflow.com/a/79537526/4352306> for usage.
|
62
|
+
|
63
|
+
### Changed
|
64
|
+
|
65
|
+
- Moved `Lib::Sftp` and `Lib::FilePattern` to `Lib::Files`
|
66
|
+
- `Lib::Files::Sftp`: some configurable parameters could already exist via **method**
|
67
|
+
- Check if `super` exists
|
68
|
+
- This gives precedence to existing methods (over i.e. **const**, over **options** cli modifiers; ... may need review at a later stage)
|
69
|
+
- `Eco::API::Common::People::DefaultParsers::BooleanParser`
|
70
|
+
- Renamed method from `truthy` to `truthy?`
|
71
|
+
- upgraded `ecoportal-api` gem
|
72
|
+
|
73
|
+
### Fixed
|
74
|
+
|
75
|
+
- align `respond_to` with `send` (should check private methods too).
|
76
|
+
- `Lib::Files::FilePattern`
|
77
|
+
- should allow `file_pattern` method to be **private**.
|
78
|
+
- `ClassHelpers`... `inherited` should call **super**.
|
79
|
+
|
80
|
+
## [3.0.26] - 2025-03-23
|
81
|
+
|
82
|
+
### Added
|
83
|
+
|
84
|
+
- default constant for `FILE_PATTERN`
|
85
|
+
- `Loaders::Base` **added**:
|
86
|
+
- `#api_space` and `#api_space_default?`
|
87
|
+
- `GROUP_ID` constant to also spot the sftp **gid**
|
88
|
+
|
18
89
|
## [3.0.25] - 2025-03-23
|
19
90
|
|
20
91
|
### Added
|
data/eco-helpers.gemspec
CHANGED
@@ -27,6 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
#spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
28
28
|
spec.require_paths = ['lib']
|
29
29
|
|
30
|
+
spec.add_development_dependency 'byebug'
|
30
31
|
spec.add_development_dependency 'rake', '>= 13.0.3', '< 14'
|
31
32
|
spec.add_development_dependency 'redcarpet', '>= 3.6.0', '< 4'
|
32
33
|
spec.add_development_dependency 'rspec', '>= 3.12.0', '< 4'
|
@@ -40,7 +41,7 @@ Gem::Specification.new do |spec|
|
|
40
41
|
spec.add_dependency 'bcrypt_pbkdf', '~> 1.0'
|
41
42
|
spec.add_dependency 'docx', '>= 0.8.0', '< 0.9'
|
42
43
|
spec.add_dependency 'dotenv', '~> 3'
|
43
|
-
spec.add_dependency 'ecoportal-api', '~> 0.10', '>= 0.10.
|
44
|
+
spec.add_dependency 'ecoportal-api', '~> 0.10', '>= 0.10.9'
|
44
45
|
spec.add_dependency 'ecoportal-api-graphql', '~> 0.4', '>= 0.4.5'
|
45
46
|
spec.add_dependency 'ecoportal-api-v2', '~> 2.0', '>= 2.0.16'
|
46
47
|
spec.add_dependency 'ed25519', '~> 1.2'
|
@@ -2,142 +2,7 @@ module Eco
|
|
2
2
|
module API
|
3
3
|
module Common
|
4
4
|
module ClassHelpers
|
5
|
-
|
6
|
-
def class_resolver(name, klass)
|
7
|
-
define_singleton_method(name) { resolve_class(klass) }
|
8
|
-
define_method(name) { self.class.resolve_class(klass) }
|
9
|
-
end
|
10
|
-
|
11
|
-
# With given a `klass` name it resolves to an actual `Class`
|
12
|
-
# @return [Class] the class that was being searched by name `klass`.
|
13
|
-
def resolve_class(klass, exception: true)
|
14
|
-
@resolved ||= {}
|
15
|
-
@resolved[klass] ||=
|
16
|
-
case klass
|
17
|
-
when Class
|
18
|
-
klass
|
19
|
-
when String
|
20
|
-
begin
|
21
|
-
Kernel.const_get(klass)
|
22
|
-
rescue NameError
|
23
|
-
raise if exception
|
24
|
-
end
|
25
|
-
when Symbol
|
26
|
-
resolve_class(send(klass))
|
27
|
-
else
|
28
|
-
raise "Unknown class: #{klass}" if exception
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
# Helper to normalize `key` into a correct `ruby` **constant name**
|
33
|
-
# @param key [String, Symbol] to be normalized
|
34
|
-
# @return [String] a correct constant name
|
35
|
-
def to_constant(key)
|
36
|
-
key.to_s.strip.split(/[\-\_ ]/i).compact.map do |str|
|
37
|
-
str.slice(0).upcase + str.slice(1..-1).downcase
|
38
|
-
end.join
|
39
|
-
end
|
40
|
-
|
41
|
-
# Helper to create an instance variable `name`
|
42
|
-
# @param [String, Symbol] the name of the variable
|
43
|
-
# @reutrn [String] the name of the created instance variable
|
44
|
-
def instance_variable_name(name)
|
45
|
-
str = name.to_s
|
46
|
-
str = "@#{str}" unless str.start_with?("@")
|
47
|
-
str
|
48
|
-
end
|
49
|
-
|
50
|
-
# If the class for `name` exists, it returns it. Otherwise it generates it.
|
51
|
-
# @param name [String, Symbol] the name of the new class
|
52
|
-
# @param inherits [Class] the parent class to _inherit_ from
|
53
|
-
# @param parent_space [String] parent namespace of the generated class, if not given: `self`
|
54
|
-
# @yield [child_class] configure the new class
|
55
|
-
# @yieldparam child_class [Class] the new class
|
56
|
-
# @return [Class] the new generated class
|
57
|
-
def new_class(name, inherits:, parent_space: nil)
|
58
|
-
name = name.to_sym.freeze
|
59
|
-
class_name = to_constant(name)
|
60
|
-
parent_space = parent_space ? resolve_class(parent_space) : self
|
61
|
-
full_class_name = "#{parent_space}::#{class_name}"
|
62
|
-
|
63
|
-
unless (target_class = resolve_class(full_class_name, exception: false))
|
64
|
-
target_class = Class.new(inherits)
|
65
|
-
parent_space.const_set class_name, target_class
|
66
|
-
end
|
67
|
-
|
68
|
-
target_class.tap do |klass|
|
69
|
-
yield(klass) if block_given?
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
# Finds all child classes of the current class.
|
74
|
-
# @param parent_class [Class] the parent class we want to find children of.
|
75
|
-
# @param direct [Boolean] it will only include direct child classes.
|
76
|
-
# @param scope [nil, Array] to only look for descendants among the ones in `scope`.
|
77
|
-
# @return [Arrary<Class>] the child classes in hierarchy order.
|
78
|
-
def descendants(parent_class: self, direct: false, scope: nil)
|
79
|
-
scope ||= ObjectSpace.each_object(::Class)
|
80
|
-
return [] if scope.empty?
|
81
|
-
scope.select do |klass|
|
82
|
-
klass < parent_class
|
83
|
-
end.sort do |k_1, k_2|
|
84
|
-
next -1 if k_2 < k_1
|
85
|
-
next 1 if k_1 < k_2
|
86
|
-
0
|
87
|
-
end.tap do |siblings|
|
88
|
-
if direct
|
89
|
-
siblings.reject! do |si|
|
90
|
-
siblings.any? {|s| si < s}
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
# @param parent_class [Class] the parent class we want to find children of.
|
97
|
-
# @param direct [Boolean] it will only include direct child classes.
|
98
|
-
# @return [Boolean] `true` if the current class has child classes, and `false` otherwise.
|
99
|
-
def descendants?(parent_class: self, direct: false)
|
100
|
-
descendants(parent_class: parent_class, direct: direct).length.positive?
|
101
|
-
end
|
102
|
-
|
103
|
-
# Keeps track on class instance variables that should be inherited by child classes.
|
104
|
-
# @note
|
105
|
-
# - subclasses will inherit the value as is at that moment
|
106
|
-
# - any change afterwards will be only on the specific class (in line with class instance variables)
|
107
|
-
# - adapted from https://stackoverflow.com/a/10729812/4352306
|
108
|
-
# TODO: this separates the logic of the method to the instance var.
|
109
|
-
# Think if would be possible to join them somehow.
|
110
|
-
def inheritable_class_vars(*vars)
|
111
|
-
@inheritable_class_vars ||= [:inheritable_class_vars]
|
112
|
-
@inheritable_class_vars += vars
|
113
|
-
end
|
114
|
-
|
115
|
-
# Builds the attr_reader and attr_writer of `attrs` and registers
|
116
|
-
# the associated instance variable as inheritable.
|
117
|
-
def inheritable_attrs(*attrs)
|
118
|
-
attrs.each do |attr|
|
119
|
-
class_eval %(
|
120
|
-
class << self; attr_accessor :#{attr} end
|
121
|
-
), __FILE__, __LINE__ - 2
|
122
|
-
end
|
123
|
-
|
124
|
-
inheritable_class_vars(*attrs)
|
125
|
-
end
|
126
|
-
|
127
|
-
# This callback method is called whenever a subclass of the current class is created.
|
128
|
-
# @note
|
129
|
-
# - values of the instance variables are copied as they are (no dups or clones)
|
130
|
-
# - the above means: avoid methods that change the state of the mutable object on it
|
131
|
-
# - mutating methods would reflect the changes on other classes as well
|
132
|
-
# - therefore, `freeze` will be called on the values that are inherited.
|
133
|
-
def inherited(subclass)
|
134
|
-
super
|
135
|
-
inheritable_class_vars.each do |var|
|
136
|
-
instance_var = instance_variable_name(var)
|
137
|
-
value = instance_variable_get(instance_var)
|
138
|
-
subclass.instance_variable_set(instance_var, value.freeze)
|
139
|
-
end
|
140
|
-
end
|
5
|
+
include Eco::Language::Klass::HelpersBuilt
|
141
6
|
end
|
142
7
|
end
|
143
8
|
end
|
@@ -1,8 +1,7 @@
|
|
1
1
|
class Eco::API::Common::Loaders::Config
|
2
|
-
|
3
|
-
extend Eco::Language::Methods::DelegateMissing
|
2
|
+
include Eco::Language::Delegation::DelegatingMissingOnClass
|
4
3
|
|
5
|
-
|
4
|
+
delegating_missing_on_class_to :config
|
6
5
|
|
7
6
|
class << self
|
8
7
|
# To create samples of configurations
|
@@ -29,8 +28,6 @@ class Eco::API::Common::Loaders::Config
|
|
29
28
|
config.active_enviro
|
30
29
|
end
|
31
30
|
end
|
32
|
-
|
33
|
-
delegate_missing_to :config
|
34
31
|
end
|
35
32
|
|
36
33
|
require_relative 'config/cli'
|
@@ -32,7 +32,7 @@ module Eco
|
|
32
32
|
# @param handler [Eco::API::Error::Hanlder] the `error handler` instance object.
|
33
33
|
# @param job [Eco::API::Session::Batch::Job] the `Batch::Job` made on purpose for this handler.
|
34
34
|
def main(data, session, options, handler, job) # rubocop:disable Lint/UnusedMethodArgument
|
35
|
-
raise
|
35
|
+
raise 'You should implement this method'
|
36
36
|
end
|
37
37
|
|
38
38
|
def error
|
@@ -134,7 +134,7 @@ module Eco
|
|
134
134
|
# (i.e. Array instread of String with '|' delimiters).
|
135
135
|
# @param deps [Hash] the merged dependencies (default to the class object and when calling the parser).
|
136
136
|
def parser(_data, _deps)
|
137
|
-
raise
|
137
|
+
raise 'You should implement this method'
|
138
138
|
end
|
139
139
|
|
140
140
|
# @param data [Hash, Ecoportal::API::V1::Person] all the person data at the specified `serializing_phase`:
|
@@ -144,7 +144,7 @@ module Eco
|
|
144
144
|
# - when `:person`: it will receive the `person` object.
|
145
145
|
# @param deps [Hash] the merged dependencies (default to the class object and when calling the parser).
|
146
146
|
# def serializer(data, deps)
|
147
|
-
# raise
|
147
|
+
# raise 'You should implement this method'
|
148
148
|
# end
|
149
149
|
|
150
150
|
# @return [String, Symbol] the field/attribute or type this parser is linked to.
|
@@ -17,7 +17,7 @@ module Eco
|
|
17
17
|
# @param policy [Eco::API::Policies::Policy] the `policy` instance object.
|
18
18
|
# @param job [Eco::API::Session::Batch::Job] the `Batch::Job` that these `people` belong to the queue thereof.
|
19
19
|
def main(data, session, options, policy, job = nil) # rubocop:disable Lint/UnusedMethodArgument
|
20
|
-
raise
|
20
|
+
raise 'You should implement this method'
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -33,7 +33,7 @@ module Eco
|
|
33
33
|
# @param options [Hash] the options that modify the case behaviour or bring some dependencies.
|
34
34
|
# @param usecase [Eco::API::Policies::Policy] the `usecase` instance object.
|
35
35
|
def main(*_args)
|
36
|
-
raise
|
36
|
+
raise 'You should implement this method'
|
37
37
|
end
|
38
38
|
|
39
39
|
def cli_apply!
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Eco::API::Common::People::DefaultParsers::ArchivedParser < Eco::API::Common::Loaders::Parser
|
2
|
+
attribute 'archived'
|
3
|
+
|
4
|
+
def parser(hash, _deps)
|
5
|
+
value = hash[attribute]
|
6
|
+
value = value.first if value.is_a?(Array)
|
7
|
+
truthy?(value)
|
8
|
+
end
|
9
|
+
|
10
|
+
def serializer(person, _deps)
|
11
|
+
person.archived?.to_s
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def truthy?(value)
|
17
|
+
%w[true y yes x].include?(value.to_s&.downcase)
|
18
|
+
end
|
19
|
+
end
|
@@ -1,17 +1,17 @@
|
|
1
1
|
class Eco::API::Common::People::DefaultParsers::BooleanParser < Eco::API::Common::Loaders::Parser
|
2
2
|
attribute :boolean
|
3
3
|
|
4
|
-
def parser(value,
|
5
|
-
value.is_a?(Array) ? value.map { |v| truthy(v) } : truthy(value)
|
4
|
+
def parser(value, _deps)
|
5
|
+
value.is_a?(Array) ? value.map { |v| truthy?(v) } : truthy?(value)
|
6
6
|
end
|
7
7
|
|
8
|
-
def serializer(value,
|
8
|
+
def serializer(value, _deps)
|
9
9
|
value.to_s
|
10
10
|
end
|
11
11
|
|
12
12
|
private
|
13
13
|
|
14
|
-
def truthy(value)
|
14
|
+
def truthy?(value)
|
15
15
|
%w[true y yes x].include?(value.to_s.strip.downcase)
|
16
16
|
end
|
17
17
|
end
|
@@ -16,7 +16,7 @@ class Eco::API::Common::People::DefaultParsers::DateParser < Eco::API::Common::L
|
|
16
16
|
|
17
17
|
def parse_date(value, attr:)
|
18
18
|
return value.map {|val| parse_date(val, attr: attr)}.compact if value.is_a?(Enumerable)
|
19
|
-
return
|
19
|
+
return if blank?(value)
|
20
20
|
|
21
21
|
value = value.to_s.strip
|
22
22
|
return wrong!(value, attr: attr) unless date?(value)
|
@@ -31,9 +31,9 @@ class Eco::API::Common::People::DefaultParsers::DateParser < Eco::API::Common::L
|
|
31
31
|
|
32
32
|
def serialize_date(value)
|
33
33
|
return value.map {|val| serialize_date(val)}.compact if value.is_a?(Enumerable)
|
34
|
-
return
|
34
|
+
return if blank?(value)
|
35
35
|
return value if value.is_a?(String)
|
36
|
-
return
|
36
|
+
return unless [Date, Time].any? {|type| value.is_a?(type)}
|
37
37
|
|
38
38
|
value&.strftime('%Y-%m-%d')
|
39
39
|
rescue TypeError, Date::Error
|
@@ -1,19 +1,19 @@
|
|
1
1
|
class Eco::API::Common::People::DefaultParsers::FreemiumParser < Eco::API::Common::Loaders::Parser
|
2
|
-
attribute
|
2
|
+
attribute 'freemium'
|
3
3
|
|
4
|
-
def parser(hash,
|
5
|
-
value = hash[
|
4
|
+
def parser(hash, _deps)
|
5
|
+
value = hash['freemium']
|
6
6
|
value = value.first if value.is_a?(Array)
|
7
|
-
truthy(value)
|
7
|
+
truthy?(value)
|
8
8
|
end
|
9
9
|
|
10
|
-
def serializer(person,
|
10
|
+
def serializer(person, _deps)
|
11
11
|
person.freemium&.to_s
|
12
12
|
end
|
13
13
|
|
14
14
|
private
|
15
15
|
|
16
|
-
def truthy
|
16
|
+
def truthy?(value)
|
17
17
|
%w[true y yes x].include?(value.to_s&.downcase)
|
18
18
|
end
|
19
19
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
class Eco::API::Common::People::DefaultParsers::LoginProvidersParser < Eco::API::Common::Loaders::Parser
|
2
|
-
attribute
|
2
|
+
attribute 'login_provider_ids'
|
3
3
|
parsing_phase :final
|
4
4
|
serializing_phase :final
|
5
5
|
|
6
6
|
def parser(hash, _deps)
|
7
|
-
hash[
|
7
|
+
hash['login_provider_ids'].map do |name|
|
8
8
|
login_providers.to_id(name&.downcase&.strip).tap do |known|
|
9
9
|
unless !name || known || unknown_pgs.include?(name)
|
10
10
|
unknown_pgs.push(name)
|
@@ -15,7 +15,7 @@ class Eco::API::Common::People::DefaultParsers::LoginProvidersParser < Eco::API:
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def serializer(hash, _deps)
|
18
|
-
if (ids = hash[
|
18
|
+
if (ids = hash['login_provider_ids'])
|
19
19
|
login_providers.to_name(ids)
|
20
20
|
else
|
21
21
|
[]
|
@@ -1,12 +1,12 @@
|
|
1
1
|
class Eco::API::Common::People::DefaultParsers::MultiParser < Eco::API::Common::Loaders::Parser
|
2
2
|
attribute :multiple
|
3
3
|
|
4
|
-
def parser(value,
|
4
|
+
def parser(value, _deps)
|
5
5
|
into_a(value)
|
6
6
|
end
|
7
7
|
|
8
|
-
def serializer(value,
|
9
|
-
into_a(value).join(
|
8
|
+
def serializer(value, _deps)
|
9
|
+
into_a(value).join('|')
|
10
10
|
end
|
11
11
|
|
12
12
|
private
|
@@ -14,7 +14,7 @@ class Eco::API::Common::People::DefaultParsers::MultiParser < Eco::API::Common::
|
|
14
14
|
def into_a(value)
|
15
15
|
return [] if value.nil?
|
16
16
|
return value if value.is_a?(Array)
|
17
|
-
return value.split(
|
17
|
+
return value.split('|') if value.is_a?(String) && value.include?('|')
|
18
18
|
[].push(value)
|
19
19
|
end
|
20
20
|
end
|
@@ -1,15 +1,18 @@
|
|
1
1
|
class Eco::API::Common::People::DefaultParsers::PolicyGroupsParser < Eco::API::Common::Loaders::Parser
|
2
|
-
attribute
|
2
|
+
attribute 'policy_group_ids'
|
3
3
|
parsing_phase :final
|
4
4
|
|
5
5
|
def parser(hash, _deps)
|
6
|
-
policy_group_ids = hash[
|
6
|
+
policy_group_ids = hash['policy_group_ids'] || []
|
7
|
+
|
7
8
|
policy_group_ids.map do |name|
|
8
9
|
policy_groups.to_id(name&.downcase&.strip).tap do |known|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
next if known
|
11
|
+
next if name.nil?
|
12
|
+
next if unknown_pgs.include?(name)
|
13
|
+
|
14
|
+
unknown_pgs.push(name)
|
15
|
+
log(:warn) { "Unknown Policy Group: '#{name}'" }
|
13
16
|
end
|
14
17
|
end.compact.tap do |pg_names|
|
15
18
|
pg_names.push(default_id) if pg_names.empty?
|
@@ -1,20 +1,21 @@
|
|
1
1
|
class Eco::API::Common::People::DefaultParsers::SendInvitesParser < Eco::API::Common::Loaders::Parser
|
2
|
-
attribute
|
2
|
+
attribute 'send_invites'
|
3
3
|
|
4
4
|
def parser(hash, _deps)
|
5
|
-
value = hash[
|
5
|
+
value = hash['send_invites']
|
6
6
|
value = value.first if value.is_a?(Array)
|
7
|
-
truthy(value)
|
7
|
+
truthy?(value)
|
8
8
|
end
|
9
9
|
|
10
10
|
def serializer(person, _deps)
|
11
|
-
return unless account = person.account
|
11
|
+
return unless (account = person.account)
|
12
|
+
|
12
13
|
account.send_invites&.to_s
|
13
14
|
end
|
14
15
|
|
15
16
|
private
|
16
17
|
|
17
|
-
def truthy(value)
|
18
|
+
def truthy?(value)
|
18
19
|
%w[true y yes x].include?(value.to_s&.downcase)
|
19
20
|
end
|
20
21
|
end
|
@@ -12,7 +12,7 @@ class Eco::API::Common::People::DefaultParsers::XLSParser < Eco::API::Common::Lo
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def serializer(_array_hash, _deps)
|
15
|
-
raise
|
15
|
+
raise 'Not implemented. TODO: using axlsx or rubyXL gems. See: https://spin.atomicobject.com/2017/03/22/parsing-excel-files-ruby/'
|
16
16
|
end
|
17
17
|
|
18
18
|
private
|
@@ -28,7 +28,7 @@ class Eco::API::Common::People::DefaultParsers::XLSParser < Eco::API::Common::Lo
|
|
28
28
|
|
29
29
|
def expected_headers
|
30
30
|
log(:info) {
|
31
|
-
|
31
|
+
'Headers detection is using your fields_map.json file (native behaviour)'
|
32
32
|
}
|
33
33
|
session.fields_mapper.list(:external).uniq
|
34
34
|
end
|
@@ -19,6 +19,7 @@ require_relative 'default_parsers/numeric_parser'
|
|
19
19
|
require_relative 'default_parsers/date_parser'
|
20
20
|
require_relative 'default_parsers/multi_parser'
|
21
21
|
require_relative 'default_parsers/send_invites_parser'
|
22
|
+
require_relative 'default_parsers/archived_parser'
|
22
23
|
require_relative 'default_parsers/freemium_parser'
|
23
24
|
require_relative 'default_parsers/policy_groups_parser'
|
24
25
|
require_relative 'default_parsers/login_providers_parser'
|