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
@@ -1,149 +1,149 @@
|
|
1
1
|
ASSETS.cli.config do |cnf| # rubocop:disable Metrics/BlockLength
|
2
2
|
cnf.usecases do |cases| # rubocop:disable Metrics/BlockLength
|
3
|
-
desc =
|
4
|
-
cases.add(
|
5
|
-
file = SCR.get_file(
|
3
|
+
desc = 'It exports to a CSV the (filtered) people'
|
4
|
+
cases.add('-people-to-csv', :export, desc) do |people, session, options|
|
5
|
+
file = SCR.get_file('-people-to-csv', required: true, should_exist: false)
|
6
6
|
options.deep_merge!(export: {file: {name: file, format: :csv}})
|
7
7
|
|
8
|
-
case_name = options.dig(:export, :options, :detailed) ?
|
8
|
+
case_name = options.dig(:export, :options, :detailed) ? 'to-csv-detailed' : 'to-csv'
|
9
9
|
session.usecases.case(case_name)
|
10
|
-
end.add_option(
|
10
|
+
end.add_option('-nice-header', 'Outputs more descriptive standard headers') do |options|
|
11
11
|
options.deep_merge!(export: {options: {nice_header: true}})
|
12
|
-
end.add_option(
|
12
|
+
end.add_option('-internal-names', 'It is the most raw export. Useful to see all the data when name mappings override/overlap') do |options|
|
13
13
|
options.deep_merge!(export: {options: {internal_names: true}})
|
14
|
-
end.add_option(
|
14
|
+
end.add_option('-detailed', 'Includes much more information to the file (i.e. permissions_merged abilities, preferences)') do |options|
|
15
15
|
options.deep_merge!(export: {options: {detailed: true}})
|
16
|
-
end.add_option(
|
16
|
+
end.add_option('-permissions-custom', 'Used with -detailed. Adds the permissions_custom abilities') do |options|
|
17
17
|
options.deep_merge!(export: {options: {permissions_custom: true}})
|
18
|
-
end.add_option(
|
18
|
+
end.add_option('-split-schemas', 'It will generate 1 file per each schema') do |options|
|
19
19
|
options.deep_merge!(export: {options: {split_schemas: true}})
|
20
20
|
end
|
21
21
|
|
22
22
|
desc = "Forces a change of email in the same org. It won't succeed if email taken by an org member user"
|
23
|
-
cases.add(
|
23
|
+
cases.add('-change-email-from', :sync, desc, case_name: 'change-email')
|
24
24
|
|
25
25
|
desc = "Sets to -new-super the supervisor_id of the -old-super's subordinates"
|
26
|
-
cases.add(
|
26
|
+
cases.add('-switch-supervisor', :transform, desc, case_name: 'switch-supervisor') do |people, session, options|
|
27
27
|
unless options[:super]&.key?(:old)
|
28
|
-
msg =
|
28
|
+
msg = 'You must specify an -old-super to target whose supervisor is changing'
|
29
29
|
session.log(:error) { msg }
|
30
30
|
exit(1)
|
31
31
|
end
|
32
32
|
unless options[:super]&.key?(:new)
|
33
|
-
msg =
|
33
|
+
msg = 'You must specify the -new-super id. To reset to nil the supervisor, please, specify nil.'
|
34
34
|
session.log(:error) { msg }
|
35
35
|
exit(1)
|
36
36
|
end
|
37
|
-
end.add_option(
|
38
|
-
if old_id = SCR.get_arg(
|
39
|
-
old_id = old_id ==
|
37
|
+
end.add_option('-old-super', 'The supervisor id to be replaced on the subordinates') do |options|
|
38
|
+
if (old_id = SCR.get_arg('-old-super', with_param: true))
|
39
|
+
old_id = old_id == 'nil'? nil : old_id
|
40
40
|
options.deep_merge!(super: {old: old_id})
|
41
41
|
end
|
42
|
-
end.add_option(
|
43
|
-
if new_id = SCR.get_arg(
|
44
|
-
new_id = new_id ==
|
42
|
+
end.add_option('-new-super', 'The new supervisor id') do |options|
|
43
|
+
if (new_id = SCR.get_arg('-new-super', with_param: true))
|
44
|
+
new_id = new_id == 'nil'? nil : new_id
|
45
45
|
options.deep_merge!(super: {new: new_id})
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
-
desc =
|
50
|
-
cases.add(
|
51
|
-
.add_option(
|
52
|
-
file
|
49
|
+
desc = 'Input file dump into a CSV as is.'
|
50
|
+
cases.add('-entries-to-csv', :import, desc, case_name: 'entries-to-csv')
|
51
|
+
.add_option('-out') do |options|
|
52
|
+
file = SCR.get_file('-out')
|
53
53
|
options.deep_merge!(export: {file: file})
|
54
54
|
end
|
55
55
|
|
56
|
-
desc =
|
57
|
-
desc
|
58
|
-
cases.add(
|
56
|
+
desc = 'Clears the `permissions_custom`, provided that Policy Group abilities alone apply.'
|
57
|
+
desc << ' Please be mindfull if you use this option (there may be users that have been upgraded in ad-hoc manner).'
|
58
|
+
cases.add('-clear-abilities', :transform, desc, case_name: 'clear-abilities')
|
59
59
|
|
60
|
-
desc =
|
61
|
-
cases.add(
|
62
|
-
desc =
|
63
|
-
cases.add(
|
60
|
+
desc = 'Deletes everybody that has been filtered from the people manager'
|
61
|
+
cases.add('-delete', :transform, desc, case_name: 'delete')
|
62
|
+
desc = 'Deletes the people specified in the input data'
|
63
|
+
cases.add('-delete-from', :sync, desc, case_name: 'delete')
|
64
64
|
|
65
|
-
desc =
|
66
|
-
cases.add(
|
65
|
+
desc = 'Re-freshes the default_tag of users'
|
66
|
+
cases.add('-set-default-tag', :transform, desc, case_name: 'set-default-tag')
|
67
67
|
|
68
|
-
desc
|
69
|
-
|
70
|
-
|
71
|
-
cases.add(
|
72
|
-
|
73
|
-
|
74
|
-
|
68
|
+
desc = 'Creates people with with details and account'
|
69
|
+
as_1 = 'During the run, if new people is created, they are included in the People object of the current session.'
|
70
|
+
as_1 << " This makes them available to find them (i.e. via 'external-id') before they exist"
|
71
|
+
cases.add('-create-from', :sync, desc, case_name: 'create').
|
72
|
+
add_option('-append-starters', as_1) do |options|
|
73
|
+
options.deep_merge!(people: {append_created: true})
|
74
|
+
end
|
75
75
|
|
76
|
-
desc =
|
77
|
-
cases.add(
|
76
|
+
desc = 'It just adds everybody to an update job without doing any change. If the org has policies, it will refresh'
|
77
|
+
cases.add('-refresh', :transform, desc, case_name: 'refresh')
|
78
78
|
|
79
|
-
desc =
|
80
|
-
cases.add(
|
79
|
+
desc = 'Updates the people specified in the input data'
|
80
|
+
cases.add('-update-from', :sync, desc, case_name: 'update')
|
81
81
|
|
82
82
|
desc = "Does an actual transfer of USER from id|external_id account to 'destination-id' person"
|
83
|
-
cases.add(
|
84
|
-
|
85
|
-
|
86
|
-
|
83
|
+
cases.add('-transfer-account-from', :sync, desc, case_name: 'transfer-account').
|
84
|
+
add_option('-include-email', 'Specifies if the email should also be moved. Otherwise it only moves the account') do |options|
|
85
|
+
options.deep_merge!(include: {email: true})
|
86
|
+
end
|
87
87
|
|
88
|
-
desc =
|
89
|
-
cases.add(
|
90
|
-
|
91
|
-
|
92
|
-
|
88
|
+
desc = 'Tries to find the input entries and update them. It creates them if not found'
|
89
|
+
cases.add('-upsert-from', :sync, desc, case_name: 'upsert').
|
90
|
+
add_option('-append-starters', as_1) do |options|
|
91
|
+
options.deep_merge!(people: {append_created: true})
|
92
|
+
end
|
93
93
|
|
94
|
-
desc =
|
95
|
-
cases.add(
|
96
|
-
|
97
|
-
|
98
|
-
|
94
|
+
desc = 'It does like -upsert-from and additionally removes account and supervisor of those in people that are not in the entries (leavers)'
|
95
|
+
cases.add('-hris-from', :sync, desc, case_name: 'hris').
|
96
|
+
add_option('-append-starters', as_1) do |options|
|
97
|
+
options.deep_merge!(people: {append_created: true})
|
98
|
+
end
|
99
99
|
|
100
100
|
# Ooze cases
|
101
|
-
desc =
|
102
|
-
cases.add(
|
103
|
-
file = SCR.get_file(
|
104
|
-
options.deep_merge!(export: {file: {name: file ||
|
101
|
+
desc = 'APIv2 Case: Exports the target register into a CSV'
|
102
|
+
cases.add('-export-register', :other, desc, case_name: 'export-register') do |session, options, usecase|
|
103
|
+
file = SCR.get_file('-export-register', required: false, should_exist: false)
|
104
|
+
options.deep_merge!(export: {file: {name: file || 'RegisterExport.csv', format: :csv}})
|
105
105
|
|
106
106
|
unless options.dig(:source, :register_id)
|
107
107
|
session.log(:error) {
|
108
|
-
|
108
|
+
'You should specify the target register id'
|
109
109
|
}
|
110
110
|
exit(1)
|
111
111
|
end
|
112
|
-
end.add_option(
|
113
|
-
reg_id = SCR.get_arg(
|
112
|
+
end.add_option('-register-id', 'Target register id') do |options|
|
113
|
+
reg_id = SCR.get_arg('-register-id', with_param: true)
|
114
114
|
options.deep_merge!(source: {register_id: reg_id})
|
115
|
-
end.add_option(
|
115
|
+
end.add_option('-include-deindexed', 'Tells if deindexed fields should be included') do |options|
|
116
116
|
options.deep_merge!(export: {options: {include: {deindexed: true}}})
|
117
|
-
end.add_option(
|
117
|
+
end.add_option('-include-unnamed', 'Tells if unnamed fields should be included') do |options|
|
118
118
|
options.deep_merge!(export: {options: {include: {unnamed: true}}})
|
119
|
-
end.add_option(
|
119
|
+
end.add_option('-include-unhashed', 'Tells if fields with no hash reference (very short label) should be included') do |options|
|
120
120
|
options.deep_merge!(export: {options: {include: {unhashed: true}}})
|
121
|
-
end.add_option(
|
122
|
-
str = SCR.get_arg(
|
121
|
+
end.add_option('-delimiter', 'Sets the delimiter to be used in fields multi value') do |options|
|
122
|
+
str = SCR.get_arg('-delimiter', with_param: true)
|
123
123
|
options.deep_merge!(export: {options: {delimiter: str}})
|
124
|
-
end.add_option(
|
125
|
-
str = SCR.get_arg(
|
124
|
+
end.add_option('-created-from', 'Filters the register to the entries created FROM the specified date') do |options|
|
125
|
+
str = SCR.get_arg('-created-from', with_param: true)
|
126
126
|
date = Time.parse(str)
|
127
127
|
options.deep_merge!(export: {options: {filters: {created_at: {from: date}}}})
|
128
|
-
end.add_option(
|
129
|
-
str = SCR.get_arg(
|
128
|
+
end.add_option('-created-to', 'Filters the register to the entries created up TO the specified date') do |options|
|
129
|
+
str = SCR.get_arg('-created-to', with_param: true)
|
130
130
|
date = Time.parse(str)
|
131
131
|
options.deep_merge!(export: {options: {filters: {created_at: {to: date}}}})
|
132
|
-
end.add_option(
|
133
|
-
str = SCR.get_arg(
|
132
|
+
end.add_option('-updated-from', 'Filters the register by entries updated FROM the specified date') do |options|
|
133
|
+
str = SCR.get_arg('-updated-from', with_param: true)
|
134
134
|
date = Time.parse(str)
|
135
135
|
options.deep_merge!(export: {options: {filters: {updated_at: {from: date}}}})
|
136
|
-
end.add_option(
|
137
|
-
str = SCR.get_arg(
|
136
|
+
end.add_option('-updated-to', 'Filters the register by entries updated up TO the specified date') do |options|
|
137
|
+
str = SCR.get_arg('-updated-to', with_param: true)
|
138
138
|
date = Time.parse(str)
|
139
139
|
options.deep_merge!(export: {options: {filters: {updated_at: {to: date}}}})
|
140
|
-
end.add_option(
|
141
|
-
str = SCR.get_arg(
|
142
|
-
tags = str.split(
|
140
|
+
end.add_option('-all-tags', 'Filters the register to entries with ALL specified tags (| separator)') do |options|
|
141
|
+
str = SCR.get_arg('-all-tags', with_param: true)
|
142
|
+
tags = str.split('|')
|
143
143
|
options.deep_merge!(export: {options: {filters: {tags: {all: tags}}}})
|
144
|
-
end.add_option(
|
145
|
-
str = SCR.get_arg(
|
146
|
-
tags = str.split(
|
144
|
+
end.add_option('-any-tags', 'Filters the register to entries with ANY specified tags (| separator)') do |options|
|
145
|
+
str = SCR.get_arg('-all-tags', with_param: true)
|
146
|
+
tags = str.split('|')
|
147
147
|
options.deep_merge!(export: {options: {filters: {tags: {any: tags}}}})
|
148
148
|
end
|
149
149
|
end
|
@@ -11,7 +11,7 @@ class Eco::CliDefault::Workflow < Eco::API::Common::Loaders::Workflow
|
|
11
11
|
# workflows that assembly those classes?
|
12
12
|
# 5. Right on the load:data stage, set the io model
|
13
13
|
# based on (1).
|
14
|
-
|
14
|
+
#
|
15
15
|
class << self
|
16
16
|
attr_accessor :rescued
|
17
17
|
end
|
@@ -90,7 +90,7 @@ class Eco::CliDefault::Workflow < Eco::API::Common::Loaders::Workflow
|
|
90
90
|
on(:usecases) do
|
91
91
|
next if cli_usecases.process(io: io)
|
92
92
|
|
93
|
-
log(:info) {
|
93
|
+
log(:info) { 'No update operation specified... quitting' }
|
94
94
|
exit 0
|
95
95
|
end
|
96
96
|
|
@@ -111,8 +111,8 @@ class Eco::CliDefault::Workflow < Eco::API::Common::Loaders::Workflow
|
|
111
111
|
wf_post.skip!
|
112
112
|
|
113
113
|
log(:info) {
|
114
|
-
msg =
|
115
|
-
msg <<
|
114
|
+
msg = 'Although there are post_launch cases, they will NOT be RUN'
|
115
|
+
msg << ', because we are in dry-run (simulate).' if options[:dry_run]
|
116
116
|
msg
|
117
117
|
}
|
118
118
|
|
@@ -125,11 +125,11 @@ class Eco::CliDefault::Workflow < Eco::API::Common::Loaders::Workflow
|
|
125
125
|
|
126
126
|
unless refresh_data
|
127
127
|
log(:info) {
|
128
|
-
msg =
|
128
|
+
msg = 'Although there are post_launch cases, data will not be refreshed before their run'
|
129
129
|
if io.options[:dry_run]
|
130
|
-
msg <<
|
130
|
+
msg << ', because we are in dry-run (simulate).'
|
131
131
|
elsif !partial_update
|
132
|
-
msg <<
|
132
|
+
msg << ', because it is not a partial update (-get-partial option not present).'
|
133
133
|
end
|
134
134
|
msg
|
135
135
|
}
|
@@ -6,8 +6,10 @@ module Eco
|
|
6
6
|
|
7
7
|
class << self
|
8
8
|
def included(base)
|
9
|
-
|
10
|
-
|
9
|
+
super
|
10
|
+
|
11
|
+
base.send :include, InstanceMethods
|
12
|
+
base.extend ClassMethods
|
11
13
|
end
|
12
14
|
end
|
13
15
|
|
@@ -112,7 +114,7 @@ module Eco
|
|
112
114
|
File.join(path, basename)
|
113
115
|
end
|
114
116
|
|
115
|
-
def folder_files(folder =
|
117
|
+
def folder_files(folder = '.', pattern = '*', regexp: nil, older_than: nil)
|
116
118
|
target = File.join(File.expand_path(folder), pattern)
|
117
119
|
Dir[target].tap do |dir_files|
|
118
120
|
dir_files.select! {|f| File.file?(f)}
|
@@ -131,8 +133,8 @@ module Eco
|
|
131
133
|
end.sort
|
132
134
|
end
|
133
135
|
|
134
|
-
def csv_files(folder =
|
135
|
-
folder_files(folder,
|
136
|
+
def csv_files(folder = '.', regexp: nil, older_than: nil)
|
137
|
+
folder_files(folder, '*.csv', regexp: regexp, older_than: older_than).sort
|
136
138
|
end
|
137
139
|
end
|
138
140
|
|
@@ -1,23 +1,64 @@
|
|
1
1
|
module Eco
|
2
2
|
module Data
|
3
3
|
module FuzzyMatch
|
4
|
-
class Result < Struct.new(
|
5
|
-
|
4
|
+
class Result < Struct.new(
|
5
|
+
:match,
|
6
|
+
:value,
|
7
|
+
:needle_value,
|
8
|
+
:dice,
|
9
|
+
:levenshtein,
|
10
|
+
:jaro_winkler,
|
11
|
+
:ngrams,
|
12
|
+
:words_ngrams,
|
13
|
+
:chars_position
|
14
|
+
)
|
15
|
+
ALL_METHODS = %i[
|
16
|
+
dice levenshtein jaro_winkler
|
17
|
+
ngrams words_ngrams chars_position
|
18
|
+
].freeze
|
6
19
|
|
7
20
|
attr_accessor :pivot
|
8
21
|
|
9
|
-
def dice
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
def
|
14
|
-
|
22
|
+
def dice
|
23
|
+
super&.round(3)
|
24
|
+
end
|
25
|
+
|
26
|
+
def levenshtein
|
27
|
+
super&.round(3)
|
28
|
+
end
|
29
|
+
|
30
|
+
def jaro_winkler
|
31
|
+
super&.round(3)
|
32
|
+
end
|
33
|
+
|
34
|
+
def ngrams
|
35
|
+
super&.round(3)
|
36
|
+
end
|
37
|
+
|
38
|
+
def words_ngrams
|
39
|
+
super&.round(3)
|
40
|
+
end
|
41
|
+
|
42
|
+
def chars_position
|
43
|
+
super&.round(3)
|
44
|
+
end
|
15
45
|
|
16
46
|
#Shortcuts
|
17
|
-
def lev
|
18
|
-
|
19
|
-
|
20
|
-
|
47
|
+
def lev
|
48
|
+
levenshtein
|
49
|
+
end
|
50
|
+
|
51
|
+
def jaro
|
52
|
+
jaro_winkler
|
53
|
+
end
|
54
|
+
|
55
|
+
def wngrams
|
56
|
+
words_ngrams
|
57
|
+
end
|
58
|
+
|
59
|
+
def pos
|
60
|
+
chars_position
|
61
|
+
end
|
21
62
|
|
22
63
|
def average
|
23
64
|
values = [dice, levenshtein, jaro_winkler, ngrams, words_ngrams, chars_position]
|
@@ -36,52 +77,54 @@ module Eco
|
|
36
77
|
|
37
78
|
def all_threshold?(methods = order, threshold = 0.15)
|
38
79
|
return true unless threshold
|
80
|
+
|
39
81
|
[methods].flatten.compact.all? {|method| threshold?(method, threshold)}
|
40
82
|
end
|
41
83
|
|
42
84
|
def any_threshold?(methods = order, threshold = 0.15)
|
43
85
|
return true unless threshold
|
86
|
+
|
44
87
|
[methods].flatten.compact.any? {|method| threshold?(method, threshold)}
|
45
88
|
end
|
46
89
|
|
47
90
|
def threshold?(method = :dice, threshold = 0.15)
|
48
|
-
raise "Uknown method '#{method}'" unless
|
49
|
-
|
91
|
+
raise ArgumentError, "Uknown method '#{method}'" unless respond_to?(method, true)
|
92
|
+
|
93
|
+
send(method) >= threshold
|
50
94
|
end
|
51
95
|
|
52
96
|
def order=(values)
|
53
97
|
@order = [values].flatten.compact.tap do |o|
|
54
|
-
o << [
|
98
|
+
o << %i[words_ngrams dice] if o.empty?
|
55
99
|
end
|
56
100
|
end
|
57
101
|
|
58
102
|
def order
|
59
|
-
@order ||= [
|
103
|
+
@order ||= %i[words_ngrams dice]
|
60
104
|
end
|
61
105
|
|
62
|
-
def <=>(
|
63
|
-
compare(
|
106
|
+
def <=>(other)
|
107
|
+
compare(other)
|
64
108
|
end
|
65
109
|
|
66
110
|
def values_at(*keys)
|
67
111
|
keys.map do |key|
|
68
|
-
|
112
|
+
send(key) if respond_to?(key)
|
69
113
|
end
|
70
114
|
end
|
71
115
|
|
72
116
|
private
|
73
117
|
|
74
118
|
def compare(other, order: self.order)
|
75
|
-
return 0
|
76
|
-
raise "Uknown method '#{method}'" unless self.respond_to?(method) && other.respond_to?(method)
|
77
|
-
return -1 if self.send(method) > other.send(method)
|
78
|
-
return 1 if self.send(method) < other.send(method)
|
79
|
-
compare(other, order: order[1..-1])
|
80
|
-
end
|
119
|
+
return 0 unless (method = order.first)
|
81
120
|
|
121
|
+
raise "Uknown method '#{method}'" unless respond_to?(method, true) && other.respond_to?(method, true)
|
82
122
|
|
123
|
+
return -1 if send(method) > other.send(method)
|
124
|
+
return 1 if send(method) < other.send(method)
|
125
|
+
compare(other, order: order[1..])
|
126
|
+
end
|
83
127
|
end
|
84
|
-
|
85
128
|
end
|
86
129
|
end
|
87
130
|
end
|
@@ -12,14 +12,16 @@ module Eco
|
|
12
12
|
|
13
13
|
def each(&block)
|
14
14
|
return to_enum(:each) unless block
|
15
|
+
|
15
16
|
raw_results.each(&block)
|
16
17
|
end
|
17
18
|
|
18
19
|
# Merges the results of both Results object
|
19
20
|
def merge(res)
|
20
|
-
unless
|
21
|
+
unless needle == res.needle
|
21
22
|
raise "To merge 2 Results, needle should be the same ('#{value}'). Given '#{res.value}'"
|
22
23
|
end
|
24
|
+
|
23
25
|
self.class.new(needle, value, raw_results.concat(res.raw_results))
|
24
26
|
end
|
25
27
|
|
@@ -29,9 +31,10 @@ module Eco
|
|
29
31
|
|
30
32
|
def relevant_results(**options)
|
31
33
|
options = {order: order, threshold: threshold || 0.5}.merge(options)
|
34
|
+
|
32
35
|
raw_results.select do |result|
|
33
36
|
result.all_threshold?(options[:order], options[:threshold])
|
34
|
-
end.
|
37
|
+
end.then do |filtered|
|
35
38
|
self.class.new(needle, value, filtered).tap do |results|
|
36
39
|
results.order = options[:order]
|
37
40
|
end
|
@@ -47,7 +50,7 @@ module Eco
|
|
47
50
|
end
|
48
51
|
|
49
52
|
def order
|
50
|
-
@order ||= [
|
53
|
+
@order ||= %i[words_ngrams dice]
|
51
54
|
end
|
52
55
|
|
53
56
|
def results
|
@@ -55,23 +58,20 @@ module Eco
|
|
55
58
|
end
|
56
59
|
|
57
60
|
def print
|
58
|
-
msg = results.map
|
59
|
-
result.print
|
60
|
-
end.join("\n ")
|
61
|
+
msg = results.map(&:print).join("\n ")
|
61
62
|
|
62
63
|
puts "'#{value}':\n " + msg
|
63
64
|
end
|
64
65
|
|
65
66
|
private
|
66
67
|
|
67
|
-
def item_string(item, attr = self.method)
|
68
|
+
def item_string(item, attr = self.method) # rubocop:disable Style/RedundantSelf
|
68
69
|
return item if !item || item.is_a?(String) || !attr
|
70
|
+
|
69
71
|
attr = attr.to_sym
|
70
|
-
|
72
|
+
item.send(attr) if item.respond_to?(attr, true)
|
71
73
|
end
|
72
|
-
|
73
74
|
end
|
74
|
-
|
75
75
|
end
|
76
76
|
end
|
77
77
|
end
|
@@ -2,11 +2,13 @@ module Eco
|
|
2
2
|
module Data
|
3
3
|
module FuzzyMatch
|
4
4
|
class Score < Struct.new(:score, :total)
|
5
|
-
|
6
5
|
def ratio(decimals = 6)
|
7
|
-
tot =
|
8
|
-
|
9
|
-
|
6
|
+
tot = total
|
7
|
+
sc = score
|
8
|
+
|
9
|
+
tot = 1 unless tot&.positive?
|
10
|
+
sc = 0 unless sc&.positive?
|
11
|
+
|
10
12
|
(sc.to_f / tot).round(decimals)
|
11
13
|
end
|
12
14
|
|
@@ -16,7 +18,10 @@ module Eco
|
|
16
18
|
|
17
19
|
def increase(value = 1)
|
18
20
|
self.score += value
|
19
|
-
|
21
|
+
|
22
|
+
msg = "Score #{self.score} (increase: #{value}) can't be greater than total #{total}"
|
23
|
+
raise msg if score > total
|
24
|
+
|
20
25
|
self.score
|
21
26
|
end
|
22
27
|
|
@@ -26,7 +31,7 @@ module Eco
|
|
26
31
|
|
27
32
|
def values_at(*keys)
|
28
33
|
keys.map do |key|
|
29
|
-
|
34
|
+
send(key) if respond_to?(key, true)
|
30
35
|
end
|
31
36
|
end
|
32
37
|
|
@@ -37,13 +42,13 @@ module Eco
|
|
37
42
|
|
38
43
|
def merge!(scr)
|
39
44
|
raise "Expecting Score object. Given: #{scr.class}" unless scr.is_a?(Score)
|
45
|
+
|
40
46
|
increase_total(scr.total)
|
41
47
|
increase(scr.score)
|
48
|
+
|
42
49
|
self
|
43
50
|
end
|
44
|
-
|
45
51
|
end
|
46
|
-
|
47
52
|
end
|
48
53
|
end
|
49
54
|
end
|