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
data/lib/eco/api/error.rb
CHANGED
@@ -9,82 +9,82 @@ module Eco
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
@str_err =
|
12
|
+
@str_err = 'api error on the server reply'
|
13
13
|
@match = /.*/
|
14
14
|
#RxValidId = /[a-f0-9]{24}/
|
15
15
|
|
16
16
|
class Unclassified < Eco::API::Error
|
17
|
-
@str_error =
|
17
|
+
@str_error = 'Unclassified error message'
|
18
18
|
@match = /.*/
|
19
19
|
end
|
20
20
|
|
21
21
|
class InternalServerError < Eco::API::Error
|
22
|
-
@str_err =
|
22
|
+
@str_err = 'Internal Server Error'
|
23
23
|
@match = /#{@str_err}/
|
24
24
|
end
|
25
25
|
|
26
26
|
class UnknownPersonId < Eco::API::Error
|
27
|
-
@str_err =
|
27
|
+
@str_err = 'Unknown person id'
|
28
28
|
@match = /Cannot find person with id (.*)/
|
29
29
|
end
|
30
30
|
|
31
31
|
class ExternalIdTaken < Eco::API::Error
|
32
|
-
@str_err =
|
32
|
+
@str_err = 'external ID already taken'
|
33
33
|
@match = /#{@str_err}/
|
34
34
|
end
|
35
35
|
|
36
36
|
class EmailMissing < Eco::API::Error
|
37
|
-
@str_err =
|
37
|
+
@str_err = 'missing email for account creation'
|
38
38
|
@match = /#{@str_err}/
|
39
39
|
end
|
40
40
|
|
41
41
|
class EmailInvalid < Eco::API::Error
|
42
|
-
@str_err =
|
42
|
+
@str_err = 'Email is invalid'
|
43
43
|
@match = /#{@str_err}/
|
44
44
|
end
|
45
45
|
|
46
46
|
class EmailTaken < Eco::API::Error
|
47
|
-
@str_err =
|
48
|
-
@str_err_2 =
|
47
|
+
@str_err = 'user email already taken'
|
48
|
+
@str_err_2 = 'Email is already taken'
|
49
49
|
@match = /(?:#{@str_err}|#{@str_err_2})/
|
50
50
|
end
|
51
51
|
|
52
52
|
class SupervisorNotFound < Eco::API::Error
|
53
|
-
@str_err =
|
53
|
+
@str_err = 'Supervisor not found'
|
54
54
|
@match = /Supervisor (.*?) not found/
|
55
55
|
end
|
56
56
|
|
57
57
|
class CyclicSupervisor < Eco::API::Error
|
58
|
-
@str_err =
|
58
|
+
@str_err = 'Supervisor is cyclic!'
|
59
59
|
@match = /#{@str_err}/
|
60
60
|
end
|
61
61
|
|
62
62
|
class SchemaNotFound < Eco::API::Error
|
63
|
-
@str_err =
|
63
|
+
@str_err = 'Schema not found'
|
64
64
|
@match = /Schema (.*?) not found/
|
65
65
|
end
|
66
66
|
|
67
67
|
class InvalidObjectId < Eco::API::Error
|
68
|
-
@str_err =
|
68
|
+
@str_err = 'Invalid ObjectId.'
|
69
69
|
@match = /'(.*?)' is an invalid ObjectId./
|
70
70
|
end
|
71
71
|
|
72
72
|
class UnknownField < Eco::API::Error
|
73
|
-
@str_err =
|
73
|
+
@str_err = 'Unknown field.'
|
74
74
|
@match = /(.+?) is an unknown field/
|
75
75
|
|
76
76
|
class UnknownCoreField < UnknownField
|
77
|
-
@str_err =
|
77
|
+
@str_err = 'Unknown core field.'
|
78
78
|
@match = /(.+?) is an unknown field/
|
79
79
|
end
|
80
80
|
|
81
81
|
class UnknownAccountField < UnknownField
|
82
|
-
@str_err =
|
82
|
+
@str_err = 'Unknown account field.'
|
83
83
|
@match = /account > (.+?) is an unknown field/
|
84
84
|
end
|
85
85
|
|
86
86
|
class UnknownDetailsField < UnknownField
|
87
|
-
@str_err =
|
87
|
+
@str_err = 'Unknown details field.'
|
88
88
|
@match = /details > (.+?) is an unknown field/
|
89
89
|
end
|
90
90
|
end
|
@@ -12,17 +12,9 @@ module Eco
|
|
12
12
|
[].tap do |account_excluded|
|
13
13
|
next if person.new?
|
14
14
|
|
15
|
-
if options.dig(:exclude, :policy_groups)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
if options.dig(:exclude, :default_tag)
|
20
|
-
account_excluded.push('default_tag')
|
21
|
-
end
|
22
|
-
|
23
|
-
if options.dig(:exclude, :login_providers)
|
24
|
-
account_excluded.push('login_provider_ids')
|
25
|
-
end
|
15
|
+
account_excluded.push('policy_group_ids') if options.dig(:exclude, :policy_groups)
|
16
|
+
account_excluded.push('default_tag') if options.dig(:exclude, :default_tag)
|
17
|
+
account_excluded.push('login_provider_ids') if options.dig(:exclude, :login_providers)
|
26
18
|
end
|
27
19
|
end
|
28
20
|
end
|
@@ -5,13 +5,16 @@ module Eco
|
|
5
5
|
module ApplyChanges
|
6
6
|
module SetCore
|
7
7
|
module CoreExcluded
|
8
|
+
CAN_EXCLUDE_CREATION = %w[filter_tags archived contractor_organization_id].freeze
|
9
|
+
CAN_EXCLUDE_UPDATE = %w[name external_id email filter_tags contractor_organization_id].freeze
|
10
|
+
|
8
11
|
# @note by default `supervisor_id` is always excluded.
|
9
12
|
# @param person [Ecoportal::API::V1::Person] the person we want to update, carrying the changes to be done.
|
10
13
|
# @param options [Hash] the options.
|
11
14
|
# @return [Array<String>] the core parameters that should not be included.
|
12
15
|
def core_excluded(person, options)
|
13
16
|
['supervisor_id'].tap do |core_excluded|
|
14
|
-
can_exclude = person.new??
|
17
|
+
can_exclude = person.new?? CAN_EXCLUDE_CREATION : CAN_EXCLUDE_UPDATE
|
15
18
|
|
16
19
|
exclusions = can_exclude.select do |attr|
|
17
20
|
options.dig(:exclude, attr.to_sym)
|
data/lib/eco/api/policies.rb
CHANGED
@@ -3,8 +3,8 @@ module Eco
|
|
3
3
|
# @todo the autoloading happens on `add`, and there could be multiple pending children to load.
|
4
4
|
# This could translate into the policies not being loaded in order
|
5
5
|
class Policies < Eco::API::UseCases
|
6
|
-
autoloads_children_of
|
7
|
-
autoload_namespace_ignore
|
6
|
+
autoloads_children_of 'Eco::API::Common::Loaders::Policy'
|
7
|
+
autoload_namespace_ignore 'Eco::API'
|
8
8
|
|
9
9
|
attr_reader :policies
|
10
10
|
|
@@ -313,7 +313,7 @@ module Eco
|
|
313
313
|
|
314
314
|
msg = "Job ('#{name}':#{type}): "
|
315
315
|
if (by_pass_filter = entry.external_id && @accept_update_with_no_id)
|
316
|
-
msg <<
|
316
|
+
msg << 'entry errored on creation (failed creation)'
|
317
317
|
msg << " but will try with person code: #{ref}"
|
318
318
|
else
|
319
319
|
msg << "excluded unexisting entry (failed creation): #{ref}"
|
@@ -504,7 +504,7 @@ module Eco
|
|
504
504
|
def backup_update(requests, simulate: false)
|
505
505
|
dry_run = simulate ? '_dry_run' : ''
|
506
506
|
dir = config.people.requests_folder
|
507
|
-
filename = name.split(' ').join('-').gsub(/[=\\\/><,"-]+/,
|
507
|
+
filename = name.split(' ').join('-').gsub(/[=\\\/><,"-]+/, '_') # rubocop:disable Style/RedundantArgument
|
508
508
|
file = File.join(dir, "#{type}_data_#{filename}#{dry_run}.json")
|
509
509
|
file_manager.save_json(requests, file, :timestamp)
|
510
510
|
end
|
@@ -12,7 +12,7 @@ module Eco
|
|
12
12
|
module Launcher
|
13
13
|
def self.included(base)
|
14
14
|
unless base <= Eco::API::Common::Session::BaseSession
|
15
|
-
msg =
|
15
|
+
msg = 'To be included only in Eco::API::Common::Session::BaseSession. '
|
16
16
|
msg << "Tried on '#{base}'"
|
17
17
|
raise msg
|
18
18
|
end
|
@@ -67,7 +67,6 @@ module Eco
|
|
67
67
|
people_api: api&.people,
|
68
68
|
silent: false
|
69
69
|
)
|
70
|
-
|
71
70
|
tap_status(status: status, enviro: enviro, queue: data, method: method) do |overall_status|
|
72
71
|
pending_for_server_error = data.to_a[0..]
|
73
72
|
|
@@ -83,7 +82,7 @@ module Eco
|
|
83
82
|
|
84
83
|
msg = "starting batch '#{method}' iteration #{iteration}/#{iterations}, "
|
85
84
|
msg << "with #{slice.length} entries of #{data.length} -- #{done} done"
|
86
|
-
msg << (
|
85
|
+
msg << (' ' * 20)
|
87
86
|
log(:info) { msg } unless silent
|
88
87
|
|
89
88
|
start_slice = Time.now
|
@@ -92,7 +91,7 @@ module Eco
|
|
92
91
|
people_api.batch(job_mode: as_job_mode) do |batch|
|
93
92
|
slice.each do |person|
|
94
93
|
batch.public_send(method, person) do |response|
|
95
|
-
faltal(
|
94
|
+
faltal('Request with no response') unless response
|
96
95
|
|
97
96
|
next if server_error?(response)
|
98
97
|
|
@@ -108,7 +107,7 @@ module Eco
|
|
108
107
|
msg = " ... iteration #{iteration}/#{iterations} done "
|
109
108
|
msg << "in #{str_per_sec(start_slice, slice.length)} "
|
110
109
|
msg << "(average: #{str_per_sec(start_time, done)})"
|
111
|
-
msg << (
|
110
|
+
msg << (' ' * 20)
|
112
111
|
log(:info) { msg } unless silent
|
113
112
|
end # next slice
|
114
113
|
end
|
@@ -8,7 +8,7 @@ module Eco
|
|
8
8
|
module Searcher
|
9
9
|
def self.included(base)
|
10
10
|
unless base <= Eco::API::Session::Batch
|
11
|
-
msg =
|
11
|
+
msg = 'To be included only in Eco::API::Common::Session::BaseSession. '
|
12
12
|
msg << "Tried on '#{base}'"
|
13
13
|
raise msg
|
14
14
|
end
|
@@ -66,7 +66,7 @@ module Eco
|
|
66
66
|
if entry.respond_to?(:email)
|
67
67
|
email = entry.email
|
68
68
|
elsif entry.respond_to?(:to_h)
|
69
|
-
email = entry.to_h[
|
69
|
+
email = entry.to_h['email']
|
70
70
|
end
|
71
71
|
|
72
72
|
people_matching = []
|
@@ -95,8 +95,8 @@ module Eco
|
|
95
95
|
private
|
96
96
|
|
97
97
|
def get(params: {}, silent: false, options: self.options)
|
98
|
-
msg =
|
99
|
-
msg <<
|
98
|
+
msg = 'cannot batch get without api connnection, '
|
99
|
+
msg << 'please provide a valid api connection!'
|
100
100
|
fatal msg unless (people_api = api&.people)
|
101
101
|
|
102
102
|
params = {per_page: batch_size(options)}.merge(params)
|
@@ -236,12 +236,12 @@ module Eco
|
|
236
236
|
next unless api
|
237
237
|
next if log_connection? # prevent over-logging
|
238
238
|
|
239
|
-
msg
|
239
|
+
msg = "Created api#{self.version(version)} connection "
|
240
240
|
msg << "on enviro #{description}, "
|
241
241
|
msg << "pointing to '#{host}' in '#{mode}' mode"
|
242
242
|
|
243
243
|
@logger.info(msg)
|
244
|
-
api.logger.level = ::Logger::UNKNOWN if api.respond_to?(:logger)
|
244
|
+
api.logger.level = ::Logger::UNKNOWN if api.respond_to?(:logger, true)
|
245
245
|
end
|
246
246
|
end
|
247
247
|
|
@@ -6,8 +6,8 @@ module Eco
|
|
6
6
|
include Enumerable
|
7
7
|
|
8
8
|
def initialize(config:)
|
9
|
+
super
|
9
10
|
@postcases = []
|
10
|
-
super(config: config)
|
11
11
|
end
|
12
12
|
|
13
13
|
def length
|
@@ -15,11 +15,12 @@ module Eco
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def empty?
|
18
|
-
count
|
18
|
+
count.zero?
|
19
19
|
end
|
20
20
|
|
21
21
|
def each(&block)
|
22
22
|
return to_enum(:each) unless block
|
23
|
+
|
23
24
|
items.each(&block)
|
24
25
|
end
|
25
26
|
|
@@ -35,7 +36,10 @@ module Eco
|
|
35
36
|
end
|
36
37
|
|
37
38
|
def select(usecases)
|
38
|
-
|
39
|
+
msg = 'Required Eco::API::UseCases to select the target post cases. '
|
40
|
+
msg << "Given: #{usecases.class}."
|
41
|
+
raise msg unless usecases.is_a?(Eco::API::UseCases)
|
42
|
+
|
39
43
|
each_with_object([]) do |pc, targets|
|
40
44
|
targets.push(usecases.case(pc[:name], type: pc[:type]))
|
41
45
|
end
|
@@ -50,7 +54,6 @@ module Eco
|
|
50
54
|
def by_type
|
51
55
|
@postcases.group_by {|pc| pc[:type]}
|
52
56
|
end
|
53
|
-
|
54
57
|
end
|
55
58
|
end
|
56
59
|
end
|
@@ -45,7 +45,7 @@ module Eco
|
|
45
45
|
@tagtree ||= live_tree(**kargs).tap do |tr| # rubocop:disable Naming/MemoizedInstanceVariableName
|
46
46
|
next if tr && !tr.empty?
|
47
47
|
|
48
|
-
msg =
|
48
|
+
msg = 'Could not find a local or live locations structure.'
|
49
49
|
raise MissingTagtree, msg
|
50
50
|
end
|
51
51
|
end
|
@@ -126,7 +126,7 @@ module Eco
|
|
126
126
|
# @yieldreturn [Eco::API::UseCases::BaseIO] the `io` input/output object carried througout all the _workflow_
|
127
127
|
# @return [Eco::API::Session::Config::Workflow] the current stage object (to ease chainig).
|
128
128
|
def on(key = nil, &block)
|
129
|
-
msg =
|
129
|
+
msg = 'A block should be given.'
|
130
130
|
raise ArgumentError, msg unless block_given?
|
131
131
|
|
132
132
|
if key
|
@@ -178,7 +178,7 @@ module Eco
|
|
178
178
|
# @yieldreturn [Eco::API::UseCases::BaseIO] `io` the input/output object carried througout all the _workflow_
|
179
179
|
# @return [Eco::API::Session::Config::Workflow] the current stage object (to ease chainig).
|
180
180
|
def before(key = nil, &block)
|
181
|
-
msg =
|
181
|
+
msg = 'A block should be given.'
|
182
182
|
raise ArgumentError, msg unless block_given?
|
183
183
|
|
184
184
|
if key
|
@@ -205,7 +205,7 @@ module Eco
|
|
205
205
|
# @yieldreturn [Eco::API::UseCases::BaseIO] `io` the input/output object carried througout all the _workflow_
|
206
206
|
# @return [Eco::API::Session::Config::Workflow] the current stage object (to ease chainig).
|
207
207
|
def after(key = nil, &block)
|
208
|
-
msg =
|
208
|
+
msg = 'A block should be given.'
|
209
209
|
raise ArgumentError, msg unless block_given?
|
210
210
|
|
211
211
|
if key
|
@@ -241,7 +241,7 @@ module Eco
|
|
241
241
|
# @yieldreturn [Eco::API::UseCases::BaseIO] the `io` input/output object carried througout all the _workflow_
|
242
242
|
# @return [Eco::API::Session::Config::Workflow] the current stage object (to ease chainig).
|
243
243
|
def run(key = nil, io:, &block)
|
244
|
-
raise
|
244
|
+
raise 'Missing BaseIO object' unless io.is_a?(Eco::API::UseCases::BaseIO)
|
245
245
|
|
246
246
|
rescuable(io) do
|
247
247
|
if key
|
@@ -7,7 +7,7 @@ module Eco
|
|
7
7
|
def initialize(name = :default)
|
8
8
|
super(nil)
|
9
9
|
@name = name
|
10
|
-
self[
|
10
|
+
self['org'] = {}
|
11
11
|
end
|
12
12
|
|
13
13
|
# @!group Config instance pure methods
|
@@ -30,25 +30,25 @@ module Eco
|
|
30
30
|
# Helper to manage `SFTP` files and folders.
|
31
31
|
# @return [Eco::API::Session::Config::SFTP]
|
32
32
|
def sftp
|
33
|
-
self[
|
33
|
+
self['sftp'] ||= Eco::API::Session::Config::SFTP.new(config: self)
|
34
34
|
end
|
35
35
|
|
36
36
|
# Helper to upload files and folders to `S3`.
|
37
37
|
# @return [Eco::API::Session::Config::S3Storage]
|
38
38
|
def s3storage
|
39
|
-
self[
|
39
|
+
self['s3_storage'] ||= Eco::API::Session::Config::S3Storage.new(config: self)
|
40
40
|
end
|
41
41
|
|
42
42
|
# Helper to send emails.
|
43
43
|
# @return [Eco::API::Session::Config::Mailer]
|
44
44
|
def mailer
|
45
|
-
self[
|
45
|
+
self['mailer'] ||= Eco::API::Session::Config::Mailer.new(config: self)
|
46
46
|
end
|
47
47
|
|
48
48
|
# Helper scope reporting structures.
|
49
49
|
# @return [Eco::API::Session::Config::TagTree]
|
50
50
|
def tagtree_config
|
51
|
-
org[
|
51
|
+
org['tagtree_config'] ||= Eco::API::Session::Config::TagTree.new(config: self)
|
52
52
|
end
|
53
53
|
# @!endgroup
|
54
54
|
|
@@ -56,7 +56,7 @@ module Eco
|
|
56
56
|
|
57
57
|
# @return [Eco::API::Session::Config::Logger]
|
58
58
|
def logger
|
59
|
-
self[
|
59
|
+
self['logger'] ||= Eco::API::Session::Config::Logger.new(config: self)
|
60
60
|
end
|
61
61
|
|
62
62
|
def log_console_level=(value)
|
@@ -89,7 +89,7 @@ module Eco
|
|
89
89
|
|
90
90
|
# @return [Eco::API::Session::Config::Apis]
|
91
91
|
def apis
|
92
|
-
self[
|
92
|
+
self['apis'] ||= Eco::API::Session::Config::Apis.new(config: self)
|
93
93
|
end
|
94
94
|
|
95
95
|
# @return [Boolean] `true` if there is any api configuration defined, `false` otherwise
|
@@ -159,13 +159,13 @@ module Eco
|
|
159
159
|
# @deprecated old helper to fix the dry-run mode
|
160
160
|
# @note this is now done via `options[:dry_run]`, parsed as an option
|
161
161
|
def dry_run!
|
162
|
-
self[
|
162
|
+
self['dry-run'] = true
|
163
163
|
end
|
164
164
|
|
165
165
|
# @deprecated old helper to check if we are in dry-run mode
|
166
166
|
# @note this is now done via `options[:dry_run]`, which is parsed as an option
|
167
167
|
def dry_run?
|
168
|
-
self[
|
168
|
+
self['dry-run']
|
169
169
|
end
|
170
170
|
# @!endgroup
|
171
171
|
|
@@ -173,7 +173,7 @@ module Eco
|
|
173
173
|
|
174
174
|
# @return [Eco::API::Session::Config::Files]
|
175
175
|
def files
|
176
|
-
self[
|
176
|
+
self['files'] ||= Eco::API::Session::Config::Files.new(config: self)
|
177
177
|
end
|
178
178
|
|
179
179
|
# Defines in the base folder from where files are expected to be found when relative paths are used
|
@@ -225,15 +225,15 @@ module Eco
|
|
225
225
|
|
226
226
|
# @!group Organization related shortcuts
|
227
227
|
def org
|
228
|
-
self[
|
228
|
+
self['org']
|
229
229
|
end
|
230
230
|
|
231
231
|
def location_codes=(file)
|
232
|
-
org[
|
232
|
+
org['location_codes'] = file
|
233
233
|
end
|
234
234
|
|
235
235
|
def location_codes
|
236
|
-
org[
|
236
|
+
org['location_codes']
|
237
237
|
end
|
238
238
|
|
239
239
|
def locations_mapper
|
@@ -317,7 +317,7 @@ module Eco
|
|
317
317
|
|
318
318
|
# @return [Eco::API::Session::Config::People]
|
319
319
|
def people
|
320
|
-
self[
|
320
|
+
self['people'] ||= Eco::API::Session::Config::People.new(config: self)
|
321
321
|
end
|
322
322
|
|
323
323
|
# Define the default usergroup that should be given to people with no usergroups.
|
@@ -367,7 +367,7 @@ module Eco
|
|
367
367
|
|
368
368
|
# @return [Eco::API::UseCases]
|
369
369
|
def usecases
|
370
|
-
@usecases = self[
|
370
|
+
@usecases = self['usecases'] ||= Eco::API::UseCases.new
|
371
371
|
if block_given?
|
372
372
|
yield(@usecases)
|
373
373
|
self
|
@@ -378,12 +378,12 @@ module Eco
|
|
378
378
|
|
379
379
|
# @return [Eco::API::Session::Config::PostLaunch]
|
380
380
|
def post_launch
|
381
|
-
self[
|
381
|
+
self['post_launch'] ||= Eco::API::Session::Config::PostLaunch.new(config: self)
|
382
382
|
end
|
383
383
|
|
384
384
|
# @return [Eco::API::Policies]
|
385
385
|
def policies
|
386
|
-
@policies = self[
|
386
|
+
@policies = self['policies'] ||= Eco::API::Policies.new
|
387
387
|
|
388
388
|
if block_given?
|
389
389
|
yield(@policies)
|
@@ -395,7 +395,8 @@ module Eco
|
|
395
395
|
|
396
396
|
# @return [Eco::API::Session::Batch::Policies]
|
397
397
|
def batch_policies(&block)
|
398
|
-
@batch_policies = self[
|
398
|
+
@batch_policies = self['batch_policies'] ||= Eco::API::Session::Batch::Policies.new('batch_policy')
|
399
|
+
|
399
400
|
if block_given?
|
400
401
|
@batch_policies.evaluate(@batch_policies, &block)
|
401
402
|
self
|
@@ -406,7 +407,7 @@ module Eco
|
|
406
407
|
|
407
408
|
# @return [Eco::API::Error::Handlers]
|
408
409
|
def error_handlers
|
409
|
-
@error_handlers = self[
|
410
|
+
@error_handlers = self['error_handlers'] ||= Eco::API::Error::Handlers.new
|
410
411
|
if block_given?
|
411
412
|
yield(@error_handlers)
|
412
413
|
self
|
@@ -417,7 +418,7 @@ module Eco
|
|
417
418
|
|
418
419
|
# @return [Eco::API::Session::Config::Workflow]
|
419
420
|
def workflow
|
420
|
-
@workflow = self[
|
421
|
+
@workflow = self['workflow'] ||= Eco::API::Session::Config::Workflow.new(config: self)
|
421
422
|
@workflow.tap do |wf|
|
422
423
|
yield(wf) if block_given?
|
423
424
|
end
|
@@ -425,14 +426,14 @@ module Eco
|
|
425
426
|
|
426
427
|
# @return [nil, Interger] seconds between jobs
|
427
428
|
def delay_between_jobs(seconds = nil)
|
428
|
-
self[
|
429
|
-
self[
|
429
|
+
self['delay_between_jobs'] = seconds if seconds
|
430
|
+
self['delay_between_jobs']
|
430
431
|
end
|
431
432
|
|
432
433
|
# @return [nil, Interger] seconds between job groups
|
433
434
|
def delay_between_job_groups(seconds = nil)
|
434
|
-
self[
|
435
|
-
self[
|
435
|
+
self['delay_between_job_groups'] = seconds if seconds
|
436
|
+
self['delay_between_job_groups']
|
436
437
|
end
|
437
438
|
# @!endgroup
|
438
439
|
end
|
data/lib/eco/api/session.rb
CHANGED
@@ -7,7 +7,7 @@ module Eco
|
|
7
7
|
def initialize(init = {})
|
8
8
|
env = init
|
9
9
|
|
10
|
-
msg =
|
10
|
+
msg = 'Expected object Eco::API::Session::Config or Eco::API::Common::Session::Environment. '
|
11
11
|
msg << " Given: #{init}"
|
12
12
|
|
13
13
|
correct_env = env.is_a?(Session::Config) || env.is_a?(Eco::API::Common::Session::Environment)
|
@@ -23,7 +23,7 @@ module Eco
|
|
23
23
|
@person_factories = {}
|
24
24
|
|
25
25
|
log(:debug) {
|
26
|
-
"LINE COMMAND: #{$0} #{ARGV.join(
|
26
|
+
"LINE COMMAND: #{$0} #{ARGV.join(' ')}" # rubocop:disable Style/SpecialGlobalVars
|
27
27
|
}
|
28
28
|
end
|
29
29
|
|
@@ -169,7 +169,7 @@ module Eco
|
|
169
169
|
# @param phase [Symbol] the phase when this parser should be active.
|
170
170
|
# @return [Object] the parsed attribute.
|
171
171
|
def parse_attribute(attr, source, phase = :internal, deps: {})
|
172
|
-
msg =
|
172
|
+
msg = 'There are no parsers defined'
|
173
173
|
raise msg unless (parsers = entry_factory.person_parser)
|
174
174
|
|
175
175
|
parsers.parse(attr, source, phase, deps: deps)
|
@@ -367,7 +367,7 @@ module Eco
|
|
367
367
|
path = s3uploader.upload_directory(directory, recurse: recurse)
|
368
368
|
else
|
369
369
|
log(:error) {
|
370
|
-
|
370
|
+
'To use Session.s3upload, you must specify either directory, file or content and file name'
|
371
371
|
}
|
372
372
|
end
|
373
373
|
return path unless link
|