eco-helpers 3.0.25 → 3.0.27

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.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +39 -1
  3. data/eco-helpers.gemspec +1 -1
  4. data/lib/eco/api/common/loaders/base.rb +13 -1
  5. data/lib/eco/api/common/loaders/case_base.rb +1 -1
  6. data/lib/eco/api/common/loaders/error_handler.rb +1 -1
  7. data/lib/eco/api/common/loaders/parser.rb +2 -2
  8. data/lib/eco/api/common/loaders/policy.rb +1 -1
  9. data/lib/eco/api/common/loaders/use_case.rb +1 -1
  10. data/lib/eco/api/common/people/default_parsers/archived_parser.rb +19 -0
  11. data/lib/eco/api/common/people/default_parsers/boolean_parser.rb +4 -4
  12. data/lib/eco/api/common/people/default_parsers/date_parser.rb +3 -3
  13. data/lib/eco/api/common/people/default_parsers/freemium_parser.rb +6 -6
  14. data/lib/eco/api/common/people/default_parsers/login_providers_parser.rb +3 -3
  15. data/lib/eco/api/common/people/default_parsers/multi_parser.rb +4 -4
  16. data/lib/eco/api/common/people/default_parsers/policy_groups_parser.rb +9 -6
  17. data/lib/eco/api/common/people/default_parsers/send_invites_parser.rb +6 -5
  18. data/lib/eco/api/common/people/default_parsers/xls_parser.rb +2 -2
  19. data/lib/eco/api/common/people/default_parsers.rb +1 -0
  20. data/lib/eco/api/common/people/entries.rb +16 -15
  21. data/lib/eco/api/common/people/person_entry.rb +53 -37
  22. data/lib/eco/api/common/people/person_parser.rb +8 -6
  23. data/lib/eco/api/common/session/logger/channels.rb +1 -1
  24. data/lib/eco/api/common/session/logger.rb +2 -2
  25. data/lib/eco/api/common/session/mailer/aws_provider.rb +3 -2
  26. data/lib/eco/api/common/session/mailer/provider_base.rb +6 -2
  27. data/lib/eco/api/common/session/mailer/sendgrid_provider.rb +9 -9
  28. data/lib/eco/api/common/session/mailer.rb +8 -3
  29. data/lib/eco/api/common/session/sftp.rb +2 -2
  30. data/lib/eco/api/common/version_patches/object.rb +2 -1
  31. data/lib/eco/api/custom/mailer.rb +1 -1
  32. data/lib/eco/api/error/handlers.rb +3 -3
  33. data/lib/eco/api/error.rb +17 -17
  34. data/lib/eco/api/microcases/people/apply_changes/set_account/account_excluded.rb +3 -11
  35. data/lib/eco/api/microcases/people/apply_changes/set_core/core_excluded.rb +4 -1
  36. data/lib/eco/api/microcases/people/manage/search.rb +3 -1
  37. data/lib/eco/api/organization/people.rb +1 -0
  38. data/lib/eco/api/policies.rb +2 -2
  39. data/lib/eco/api/session/batch/job.rb +2 -2
  40. data/lib/eco/api/session/batch/launcher.rb +4 -5
  41. data/lib/eco/api/session/batch/searcher.rb +4 -4
  42. data/lib/eco/api/session/config/api.rb +2 -2
  43. data/lib/eco/api/session/config/apis/enviro_spaces.rb +3 -3
  44. data/lib/eco/api/session/config/apis/space_helpers.rb +4 -4
  45. data/lib/eco/api/session/config/apis.rb +1 -1
  46. data/lib/eco/api/session/config/post_launch.rb +7 -4
  47. data/lib/eco/api/session/config/sftp.rb +1 -1
  48. data/lib/eco/api/session/config/tagtree.rb +1 -1
  49. data/lib/eco/api/session/config/workflow.rb +4 -4
  50. data/lib/eco/api/session/config.rb +25 -24
  51. data/lib/eco/api/session.rb +4 -4
  52. data/lib/eco/api/usecases/base_io/validations.rb +4 -3
  53. data/lib/eco/api/usecases/cli/option.rb +5 -2
  54. data/lib/eco/api/usecases/default/people/amend/clear_abilities_case.rb +2 -2
  55. data/lib/eco/api/usecases/default/people/amend/restore_db_case.rb +16 -9
  56. data/lib/eco/api/usecases/default/people/treat/analyse_people_case.rb +20 -20
  57. data/lib/eco/api/usecases/default.rb +5 -5
  58. data/lib/eco/api/usecases/default_cases/to_csv_case.rb +8 -8
  59. data/lib/eco/api/usecases/default_cases/upsert_case.rb +4 -4
  60. data/lib/eco/api/usecases/graphql/helpers/base.rb +1 -1
  61. data/lib/eco/api/usecases/graphql/helpers/location/base/tree_tracking.rb +5 -1
  62. data/lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb +2 -1
  63. data/lib/eco/api/usecases/graphql/helpers/location/command/result.rb +3 -3
  64. data/lib/eco/api/usecases/graphql/helpers/location/command.rb +3 -0
  65. data/lib/eco/api/usecases/graphql/samples/location/command/dsl.rb +2 -2
  66. data/lib/eco/api/usecases/graphql/samples/location/command/service/tree_update.rb +9 -3
  67. data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/inputable.rb +5 -4
  68. data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing.rb +5 -2
  69. data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff.rb +3 -3
  70. data/lib/eco/api/usecases/graphql/utils/sftp.rb +1 -1
  71. data/lib/eco/api/usecases/lib/{file_pattern.rb → files/file_pattern.rb} +5 -1
  72. data/lib/eco/api/usecases/lib/{sftp.rb → files/sftp.rb} +27 -16
  73. data/lib/eco/api/usecases/lib/files.rb +7 -0
  74. data/lib/eco/api/usecases/lib.rb +1 -2
  75. data/lib/eco/api/usecases/ooze_cases/export_register_case.rb +5 -5
  76. data/lib/eco/api/usecases/ooze_samples/helpers/exportable_ooze.rb +14 -11
  77. data/lib/eco/api/usecases/ooze_samples/helpers_migration/copying.rb +14 -23
  78. data/lib/eco/api/usecases/ooze_samples/helpers_migration/typed_fields_pairing.rb +49 -27
  79. data/lib/eco/api/usecases/ooze_samples/ooze_base_case.rb +9 -9
  80. data/lib/eco/api/usecases/ooze_samples/ooze_run_base_case.rb +1 -1
  81. data/lib/eco/api/usecases/ooze_samples/register_export_case.rb +25 -17
  82. data/lib/eco/api/usecases/ooze_samples/register_migration_case.rb +41 -24
  83. data/lib/eco/api/usecases/ooze_samples/register_update_case.rb +16 -15
  84. data/lib/eco/api/usecases/samples/drivers/cli/sftp_cli.rb +15 -15
  85. data/lib/eco/api/usecases/samples/drivers/cli/url_pull_cli.rb +5 -5
  86. data/lib/eco/api/usecases/samples/drivers/sftp_sample.rb +2 -2
  87. data/lib/eco/api/usecases/use_case.rb +6 -6
  88. data/lib/eco/api/usecases/use_case_chain/chaining.rb +6 -6
  89. data/lib/eco/api/usecases/use_case_chain.rb +4 -4
  90. data/lib/eco/api/usecases/use_case_io.rb +2 -1
  91. data/lib/eco/api/usecases.rb +9 -9
  92. data/lib/eco/cli/config/options_set.rb +4 -4
  93. data/lib/eco/cli/config/use_cases.rb +3 -3
  94. data/lib/eco/cli/scripting/argument.rb +1 -1
  95. data/lib/eco/cli_default/input.rb +9 -9
  96. data/lib/eco/cli_default/options.rb +125 -100
  97. data/lib/eco/cli_default/people.rb +3 -3
  98. data/lib/eco/cli_default/usecases.rb +83 -83
  99. data/lib/eco/cli_default/workflow.rb +7 -7
  100. data/lib/eco/data/files/helpers.rb +3 -3
  101. data/lib/eco/data/fuzzy_match/result.rb +69 -26
  102. data/lib/eco/data/fuzzy_match/results.rb +10 -10
  103. data/lib/eco/data/fuzzy_match/score.rb +13 -8
  104. data/lib/eco/data/fuzzy_match.rb +65 -48
  105. data/lib/eco/data/locations/node_base/treeify.rb +13 -11
  106. data/lib/eco/data/mapper.rb +4 -4
  107. data/lib/eco/language/auxiliar_logger.rb +4 -4
  108. data/lib/eco/language/delegation/const_delegator.rb +64 -0
  109. data/lib/eco/language/delegation/const_lookup_hooks.rb +81 -0
  110. data/lib/eco/language/delegation/delegated_class.rb +84 -0
  111. data/lib/eco/language/delegation.rb +8 -0
  112. data/lib/eco/language/klass/when_inherited.rb +1 -0
  113. data/lib/eco/language/methods/delegate_missing.rb +1 -0
  114. data/lib/eco/language/models/class_helpers.rb +25 -23
  115. data/lib/eco/language/models/collection.rb +12 -2
  116. data/lib/eco/language.rb +1 -0
  117. data/lib/eco/version.rb +1 -1
  118. metadata +12 -6
@@ -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 "Eco::API::Common::Loaders::Policy"
7
- autoload_namespace_ignore "Eco::API"
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 << "entry errored on creation (failed creation)"
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(/[=\\\/><,"-]+/, "_") # rubocop:disable Style/RedundantArgument
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 = "To be included only in Eco::API::Common::Session::BaseSession. "
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 << (" " * 20)
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("Request with no response") unless response
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 << (" " * 20)
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 = "To be included only in Eco::API::Common::Session::BaseSession. "
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["email"]
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 = "cannot batch get without api connnection, "
99
- msg << "please provide a valid api connection!"
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 = "Created api#{self.version(version)} connection "
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
 
@@ -34,8 +34,8 @@ module Eco
34
34
  def apis?(space = nil)
35
35
  return apis(space).any? unless space.nil?
36
36
 
37
- spaces.each_key.any? do |space|
38
- apis?(space)
37
+ spaces.each_key.any? do |spc|
38
+ apis?(spc)
39
39
  end
40
40
  end
41
41
 
@@ -75,7 +75,7 @@ module Eco
75
75
  def missing_api_message(name, space: space_option)
76
76
  space ||= space_option
77
77
 
78
- msg = "Missing credentials for "
78
+ msg = 'Missing credentials for '
79
79
  msg << "#{full_name(name, space: space)} Api env."
80
80
 
81
81
  if enviro_spaces?(name)
@@ -4,6 +4,10 @@ module Eco
4
4
  class Config
5
5
  class Apis
6
6
  module SpaceHelpers
7
+ def set_options_space!(space)
8
+ ASSETS.cli.options.deep_merge!(api: {space: space})
9
+ end
10
+
7
11
  def space_option?
8
12
  SCR.get_arg('-space')
9
13
  end
@@ -20,10 +24,6 @@ module Eco
20
24
  end
21
25
  end
22
26
 
23
- def set_options_space!(space)
24
- ASSETS.cli.options.deep_merge!(api: {space: space})
25
- end
26
-
27
27
  private
28
28
 
29
29
  def to_space(...)
@@ -72,7 +72,7 @@ module Eco
72
72
  space ||= space_option
73
73
 
74
74
  msg = missing_api_message(name, space: space)
75
- raise UndefinedApi, msg unless self.api?(name, space: space)
75
+ raise UndefinedApi, msg unless api?(name, space: space)
76
76
 
77
77
  self['active-name'] = name
78
78
  self['active-api'] = apis(space)[name]
@@ -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 == 0
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
- raise "Required Eco::API::UseCases to select the target post cases" unless usecases.is_a?(Eco::API::UseCases)
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
@@ -21,7 +21,7 @@ module Eco
21
21
  end
22
22
 
23
23
  def remote_folder
24
- [base_path, enviro_subpath].compact.join("/")
24
+ [base_path, enviro_subpath].compact.join('/')
25
25
  end
26
26
  end
27
27
  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 = "Could not find a local or live locations structure."
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 = "A block should be given."
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 = "A block should be given."
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 = "A block should be given."
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 "Missing BaseIO object" unless io.is_a?(Eco::API::UseCases::BaseIO)
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["org"] = {}
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["sftp"] ||= Eco::API::Session::Config::SFTP.new(config: 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["s3_storage"] ||= Eco::API::Session::Config::S3Storage.new(config: 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["mailer"] ||= Eco::API::Session::Config::Mailer.new(config: 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["tagtree_config"] ||= Eco::API::Session::Config::TagTree.new(config: self)
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["logger"] ||= Eco::API::Session::Config::Logger.new(config: 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["apis"] ||= Eco::API::Session::Config::Apis.new(config: 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["dry-run"] = true
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["dry-run"]
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["files"] ||= Eco::API::Session::Config::Files.new(config: 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["org"]
228
+ self['org']
229
229
  end
230
230
 
231
231
  def location_codes=(file)
232
- org["location_codes"] = file
232
+ org['location_codes'] = file
233
233
  end
234
234
 
235
235
  def location_codes
236
- org["location_codes"]
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["people"] ||= Eco::API::Session::Config::People.new(config: 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["usecases"] ||= Eco::API::UseCases.new
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["post_launch"] ||= Eco::API::Session::Config::PostLaunch.new(config: 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["policies"] ||= Eco::API::Policies.new
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["batch_policies"] ||= Eco::API::Session::Batch::Policies.new("batch_policy")
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["error_handlers"] ||= Eco::API::Error::Handlers.new
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["workflow"] ||= Eco::API::Session::Config::Workflow.new(config: 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["delay_between_jobs"] = seconds if seconds
429
- self["delay_between_jobs"]
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["delay_between_job_groups"] = seconds if seconds
435
- self["delay_between_job_groups"]
435
+ self['delay_between_job_groups'] = seconds if seconds
436
+ self['delay_between_job_groups']
436
437
  end
437
438
  # @!endgroup
438
439
  end
@@ -7,7 +7,7 @@ module Eco
7
7
  def initialize(init = {})
8
8
  env = init
9
9
 
10
- msg = "Expected object Eco::API::Session::Config or Eco::API::Common::Session::Environment. "
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(" ")}" # rubocop:disable Style/SpecialGlobalVars
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 = "There are no parsers defined"
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
- "To use Session.s3upload, you must specify either directory, file or content and file name"
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
@@ -12,6 +12,7 @@ class Eco::API::UseCases::BaseIO
12
12
  msg = "#{msg} of type '#{type}'" if type
13
13
  msg = "#{msg} (#{klass})" if klass
14
14
  msg = "#{msg} requires an object '#{required}'. Given: #{given}."
15
+
15
16
  super(msg)
16
17
  end
17
18
 
@@ -71,9 +72,9 @@ class Eco::API::UseCases::BaseIO
71
72
  elsif missing_data?
72
73
  raise MissingParameter.new(
73
74
  'UseCase',
74
- type: type,
75
- required: model,
76
- given: data.class,
75
+ type: type,
76
+ required: model,
77
+ given: data.class,
77
78
  usecase: self
78
79
  )
79
80
  elsif !options.is_a?(Hash)
@@ -4,7 +4,9 @@ class Eco::API::UseCases::Cli
4
4
  attr_accessor :name, :desc, :callback
5
5
 
6
6
  def initialize(name, desc, &block)
7
- @name, @desc, @callback = name, desc, block
7
+ @name = name
8
+ @desc = desc
9
+ @callback = block
8
10
  end
9
11
 
10
12
  def dup(name: self.name, desc: self.desc, &block)
@@ -12,7 +14,8 @@ class Eco::API::UseCases::Cli
12
14
  end
13
15
 
14
16
  def link_case(cli_config_case)
15
- raise ArgumentError, "cli_config_case must have an 'add_option' method. Given: #{cli_config_case.class}" unless cli_config_case.respond_to?(:add_option)
17
+ msg = "cli_config_case must have an 'add_option' method. Given: #{cli_config_case.class}"
18
+ raise ArgumentError, msg unless cli_config_case.respond_to?(:add_option)
16
19
 
17
20
  cli_config_case.add_option(name, desc, &callback)
18
21
  end
@@ -1,5 +1,5 @@
1
1
  class Eco::API::UseCases::Default::People::Amend::ClearAbilitiesTransCase < Eco::API::Common::Loaders::UseCase
2
- name "clear-abilities"
2
+ name 'clear-abilities'
3
3
  type :transform
4
4
 
5
5
  def main(*_args)
@@ -9,7 +9,7 @@ class Eco::API::UseCases::Default::People::Amend::ClearAbilitiesTransCase < Eco:
9
9
  private
10
10
 
11
11
  def clear_abilities(users)
12
- update = session.new_job("main", "clear-abilities", :update, usecase, :account)
12
+ update = session.new_job('main', 'clear-abilities', :update, usecase, :account)
13
13
  users.each do |person|
14
14
  person.account.permissions_custom = nil_abilities.dup
15
15
  update.add(person)
@@ -1,7 +1,7 @@
1
1
  # @example
2
2
  # -restore-db-from backup.json -skip-api-policies -skip-batch-policy -include-excluded -simulate
3
3
  class Eco::API::UseCases::Default::People::Amend::RestoreDBCase < Eco::API::Common::Loaders::UseCase
4
- name "restore-db"
4
+ name 'restore-db'
5
5
  type :sync
6
6
 
7
7
  require_relative 'cli/restore_db_cli'
@@ -9,9 +9,9 @@ class Eco::API::UseCases::Default::People::Amend::RestoreDBCase < Eco::API::Comm
9
9
  def main(entries, people, session, options, usecase) # rubocop:disable Metrics/AbcSize
10
10
  require_people_as_entries!(entries)
11
11
 
12
- restart = session.new_job("main", "restart", :create, usecase) if options.dig(:include, :create)
13
- update = session.new_job("main", "update", :update, usecase)
14
- delete = session.new_job("main", "delete", :update, usecase)
12
+ restart = session.new_job('main', 'restart', :create, usecase) if options.dig(:include, :create)
13
+ update = session.new_job('main', 'update', :update, usecase)
14
+ delete = session.new_job('main', 'delete', :update, usecase)
15
15
 
16
16
  if options.dig(:include, :delete)
17
17
  micro.with_each_leaver(entries, people, options) do |person|
@@ -43,13 +43,20 @@ class Eco::API::UseCases::Default::People::Amend::RestoreDBCase < Eco::API::Comm
43
43
 
44
44
  private
45
45
 
46
- def core_copy(entry, person)
46
+ def core_copy(entry, person) # rubocop:disable Metrics/AbcSize
47
+ person.archived = entry.archived unless options.dig(:exclude, :archived)
47
48
  person.external_id = entry.external_id unless options.dig(:exclude, :external_id)
48
49
  person.name = entry.name unless options.dig(:exclude, :name)
49
50
  person.email = entry.email unless options.dig(:exclude, :email)
50
51
  person.supervisor_id = entry.supervisor_id unless options.dig(:exclude, :supervisor)
51
52
  person.filter_tags = entry.filter_tags unless options.dig(:exclude, :filter_tags)
52
- person.freemium = entry.freemium
53
+
54
+ unless options.dig(:exclude, :contractor_organization_id)
55
+ person.contractor_organization_id =
56
+ entry.contractor_organization_id
57
+ end
58
+
59
+ person.freemium = entry.freemium
53
60
  end
54
61
 
55
62
  def account_copy(src, dst) # rubocop:disable Metrics/AbcSize
@@ -64,7 +71,7 @@ class Eco::API::UseCases::Default::People::Amend::RestoreDBCase < Eco::API::Comm
64
71
  end
65
72
 
66
73
  if src.preferences # rubocop:disable Style/IfUnlessModifier
67
- dst.doc["preferences"] = JSON.parse((src.doc["preferences"] || {}).to_json)
74
+ dst.doc['preferences'] = JSON.parse((src.doc['preferences'] || {}).to_json)
68
75
  end
69
76
 
70
77
  unless options[:source_enviro]
@@ -92,8 +99,8 @@ class Eco::API::UseCases::Default::People::Amend::RestoreDBCase < Eco::API::Comm
92
99
  log(:error) {
93
100
  msg = []
94
101
  msg << "There were #{re_starters.length} entries of the backup "
95
- msg << "that do not exist in the (filtered?) people manager."
96
- msg << "Some examples:"
102
+ msg << 'that do not exist in the (filtered?) people manager.'
103
+ msg << 'Some examples:'
97
104
  msg << " * #{examples.join("\n * ")}"
98
105
  msg.join("\n")
99
106
  }