eco-helpers 3.0.29 → 3.0.31

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 (54) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +36 -1
  3. data/eco-helpers.gemspec +1 -1
  4. data/lib/eco/api/common/people/entries.rb +6 -4
  5. data/lib/eco/api/common/people/entry_factory.rb +94 -39
  6. data/lib/eco/api/common/people/person_entry.rb +93 -26
  7. data/lib/eco/api/common/people/person_parser.rb +3 -1
  8. data/lib/eco/api/custom/parser.rb +1 -1
  9. data/lib/eco/api/organization/people.rb +1 -0
  10. data/lib/eco/api/session/config.rb +7 -2
  11. data/lib/eco/api/usecases/default/locations/cli/codes_to_tags_cli.rb +3 -3
  12. data/lib/eco/api/usecases/default/locations/cli/csv_to_tree_cli.rb +1 -1
  13. data/lib/eco/api/usecases/default/locations/cli/tagtree_extract_cli.rb +11 -11
  14. data/lib/eco/api/usecases/default/locations/cli/tagtree_paths_cli.rb +3 -3
  15. data/lib/eco/api/usecases/default/locations/cli/tagtree_upload_cli.rb +4 -4
  16. data/lib/eco/api/usecases/default/meta/cli/graphql_schema_cli.rb +3 -3
  17. data/lib/eco/api/usecases/default/meta/graphql_schema.rb +3 -3
  18. data/lib/eco/api/usecases/default/people/amend/cli/clean_unknown_tags_cli.rb +2 -2
  19. data/lib/eco/api/usecases/default/people/amend/cli/reinvite_sync_cli.rb +1 -1
  20. data/lib/eco/api/usecases/default/people/amend/cli/reinvite_trans_cli.rb +3 -3
  21. data/lib/eco/api/usecases/default/people/amend/cli/restore_db_cli.rb +12 -12
  22. data/lib/eco/api/usecases/default/people/amend/refresh_case.rb +2 -2
  23. data/lib/eco/api/usecases/default/people/amend/reinvite_sync_case.rb +1 -1
  24. data/lib/eco/api/usecases/default/people/amend/reinvite_trans_case.rb +2 -2
  25. data/lib/eco/api/usecases/default/people/treat/analyse_people_case.rb +2 -1
  26. data/lib/eco/api/usecases/default/people/treat/cli/analyse_people_cli.rb +25 -25
  27. data/lib/eco/api/usecases/default/people/treat/cli/org_data_convert_cli.rb +7 -7
  28. data/lib/eco/api/usecases/default/people/treat/cli/supers_cyclic_identify_cli.rb +4 -5
  29. data/lib/eco/api/usecases/default/people/treat/cli/supers_hierachy_cli.rb +4 -4
  30. data/lib/eco/api/usecases/default/people/treat/org_data_convert_case.rb +3 -3
  31. data/lib/eco/api/usecases/default/people/treat/supers_cyclic_identify_case.rb +15 -14
  32. data/lib/eco/api/usecases/default/people/treat/supers_hierarchy_case.rb +12 -12
  33. data/lib/eco/api/usecases/default/utils/cli/entries_to_csv_cli.rb +20 -0
  34. data/lib/eco/api/usecases/default/utils/cli/group_csv_cli.rb +3 -3
  35. data/lib/eco/api/usecases/default/utils/cli/json_to_csv_cli.rb +1 -1
  36. data/lib/eco/api/usecases/default/utils/cli/sort_csv_cli.rb +1 -1
  37. data/lib/eco/api/usecases/default/utils/cli/split_csv_cli.rb +5 -5
  38. data/lib/eco/api/usecases/default/utils/cli/split_json_cli.rb +2 -2
  39. data/lib/eco/api/usecases/default/utils/entries_to_csv_case.rb +39 -0
  40. data/lib/eco/api/usecases/default/utils/group_csv_case.rb +3 -3
  41. data/lib/eco/api/usecases/default/utils/sort_csv_case.rb +1 -1
  42. data/lib/eco/api/usecases/default/utils/split_csv_case.rb +4 -4
  43. data/lib/eco/api/usecases/default/utils/split_json_case.rb +8 -6
  44. data/lib/eco/api/usecases/default/utils.rb +1 -0
  45. data/lib/eco/api/usecases/default_cases.rb +0 -1
  46. data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/inputable.rb +4 -1
  47. data/lib/eco/api/usecases/lib/files/sftp.rb +5 -1
  48. data/lib/eco/cli/scripting/args_helpers.rb +3 -2
  49. data/lib/eco/cli_default/input.rb +1 -0
  50. data/lib/eco/cli_default/usecases.rb +0 -7
  51. data/lib/eco/data/files/helpers.rb +3 -0
  52. data/lib/eco/version.rb +1 -1
  53. metadata +6 -5
  54. data/lib/eco/api/usecases/default_cases/entries_to_csv_case.rb +0 -14
@@ -81,7 +81,7 @@ module Eco
81
81
 
82
82
  # Select Options
83
83
  def select_tables
84
- return nil unless @schema
84
+ return unless @schema
85
85
 
86
86
  @select_tables ||= @schema.fields.select do |fld|
87
87
  fld.type == 'select'
@@ -226,6 +226,7 @@ module Eco
226
226
 
227
227
  to_h.merge!(parser.to_h)
228
228
  patched!
229
+
229
230
  self
230
231
  end
231
232
 
@@ -252,6 +253,7 @@ module Eco
252
253
  end
253
254
 
254
255
  patched!
256
+
255
257
  self
256
258
  end
257
259
  # @!endgroup
@@ -5,7 +5,7 @@
5
5
  #
6
6
  # active_when_any "some-field1", "some-field2" # optional
7
7
  # parsing_phase :final # optional, default is (default :internal)
8
- # serializing_phase :final # optional, it will be (default :person)
8
+ # serializing_phase :final # optional, it will be (default :person)
9
9
  #
10
10
  # def parser(hash, deps)
11
11
  # get_values(hash).map do |name|
@@ -127,6 +127,7 @@ module Eco
127
127
  id = attr_value(object, 'id')
128
128
  external_id = attr_value(object, 'external_id')
129
129
  email = attr_value(object, 'email')
130
+
130
131
  person(id: id, external_id: external_id, email: email, strict: strict)
131
132
  end
132
133
  # @!endgroup
@@ -236,10 +236,15 @@ module Eco
236
236
  org['location_codes']
237
237
  end
238
238
 
239
- def locations_mapper
239
+ def locations_mapper(insensitive: false)
240
240
  return @locations_mapper if instance_variable_defined?(:@locations_mapper)
241
+
241
242
  file = file_manager.newest(location_codes)
242
- @locations_mapper = Eco::Data::Mapper.new(file_manager.load_json(file), internal: :first)
243
+ @locations_mapper = Eco::Data::Mapper.new(
244
+ file_manager.load_json(file),
245
+ internal: :first,
246
+ insensitive: insensitive
247
+ )
243
248
  end
244
249
 
245
250
  def tagtree=(file)
@@ -2,7 +2,7 @@ class Eco::API::UseCases::Default::Locations::CodesToTagsCase
2
2
  # Class to define the CLI integration of a usecase anywhere it suits.
3
3
  class Cli < Eco::API::UseCases::Cli
4
4
  str = "Adds a column 'ecoPortalTag' to the input CSV "
5
- str << "with the tags that the location codes map to"
5
+ str << 'with the tags that the location codes map to'
6
6
  desc str
7
7
 
8
8
  callback do |_sess, options, _case|
@@ -10,8 +10,8 @@ class Eco::API::UseCases::Default::Locations::CodesToTagsCase
10
10
  options.deep_merge!(other: {file: {name: file, format: :csv}})
11
11
  end
12
12
 
13
- add_option("-column", "Specify the input column header with the codes") do |options|
14
- col_codes = SCR.get_arg("-column", with_param: true)
13
+ add_option('-column', 'Specify the input column header with the codes') do |options|
14
+ col_codes = SCR.get_arg('-column', with_param: true)
15
15
  options.deep_merge!(other: {file: {codes_column: col_codes}})
16
16
  end
17
17
  end
@@ -1,7 +1,7 @@
1
1
  class Eco::API::UseCases::Default::Locations::CsvToTree
2
2
  # Class to define the CLI integration of a usecase anywhere it suits.
3
3
  class Cli < Eco::API::UseCases::Cli
4
- str = "Creates a JSON file with the tagtree from a CSV file"
4
+ str = 'Creates a JSON file with the tagtree from a CSV file'
5
5
  desc str
6
6
 
7
7
  callback do |_sess, options, _case|
@@ -1,33 +1,33 @@
1
1
  class Eco::API::UseCases::Default::Locations::TagtreeExtract
2
2
  # Class to define the CLI integration of a usecase anywhere it suits.
3
3
  class Cli < Eco::API::UseCases::Cli
4
- desc "Converts a tagtree into a specific format"
4
+ desc 'Converts a tagtree into a specific format'
5
5
 
6
- add_option("-include-archived", "Whether the archived nodes should be included") do |options|
6
+ add_option('-include-archived', 'Whether the archived nodes should be included') do |options|
7
7
  options.deep_merge!(output: {include: {archived: true}})
8
8
  end
9
9
 
10
- add_option("-format", "Kind of extract (list | json | nodes | csv_tree | excel_tree | excel_nodes )") do |options|
11
- format = SCR.get_arg("-format", with_param: true)
10
+ add_option('-format', 'Kind of extract (list | json | nodes | csv_tree | excel_tree | excel_nodes )') do |options|
11
+ format = SCR.get_arg('-format', with_param: true)
12
12
  options.deep_merge!(output: {format: format})
13
13
  end
14
14
 
15
- add_option("-node-attrs", "Attributes to be dumped (i.e. name|id ). Default: id") do |options|
16
- attrs = SCR.get_arg("-node-attrs", with_param: true)
15
+ add_option('-node-attrs', 'Attributes to be dumped (i.e. name|id ). Default: id') do |options|
16
+ attrs = SCR.get_arg('-node-attrs', with_param: true)
17
17
  options.deep_merge!(output: {attrs: attrs.split('|').map(&:to_sym)})
18
18
  end
19
19
 
20
- add_option("-with-ancestors", "Include full path of ancestors in tree csv/excel_tree") do |options|
20
+ add_option('-with-ancestors', 'Include full path of ancestors in tree csv/excel_tree') do |options|
21
21
  options.deep_merge!(output: {include: {ancestors: true}})
22
22
  end
23
23
 
24
- add_option("-indent", "Custom indentation (i.e. \"++\")") do |options|
25
- indent = SCR.get_arg("-indent", with_param: true) || ""
24
+ add_option('-indent', 'Custom indentation (i.e. \"++\")') do |options|
25
+ indent = SCR.get_arg('-indent', with_param: true) || ''
26
26
  options.deep_merge!(output: {indent: indent})
27
27
  end
28
28
 
29
- add_option("-file-as-source", "Use a file as locations input (rather than the live locations)") do |options|
30
- file = SCR.get_file("-file-as-source", required: true, should_exist: true)
29
+ add_option('-file-as-source', 'Use a file as locations input (rather than the live locations)') do |options|
30
+ file = SCR.get_file('-file-as-source', required: true, should_exist: true)
31
31
  options.deep_merge!(source: {file: file})
32
32
  end
33
33
  end
@@ -1,11 +1,11 @@
1
1
  class Eco::API::UseCases::Default::Locations::TagTreePaths
2
2
  # Class to define the CLI integration of a usecase anywhere it suits.
3
3
  class Cli < Eco::API::UseCases::Cli
4
- str = "Creates a CSV with the paths to each tag"
4
+ str = 'Creates a CSV with the paths to each tag'
5
5
  desc str
6
6
 
7
- add_option("-column", "Specify the input column header with the codes") do |options|
8
- col_codes = SCR.get_arg("-column", with_param: true)
7
+ add_option('-column', 'Specify the input column header with the codes') do |options|
8
+ col_codes = SCR.get_arg('-column', with_param: true)
9
9
  options.deep_merge!(other: {file: {codes_column: col_codes}})
10
10
  end
11
11
  end
@@ -8,13 +8,13 @@ class Eco::API::UseCases::Default::Locations::TagtreeUpload
8
8
  options.deep_merge!(source: {file: file})
9
9
  end
10
10
 
11
- add_option("-top-id", "To nest the upload under some existing node (i.e. top node)") do |options|
12
- format = SCR.get_arg("-top-id", with_param: true)
11
+ add_option('-top-id', 'To nest the upload under some existing node (i.e. top node)') do |options|
12
+ format = SCR.get_arg('-top-id', with_param: true)
13
13
  options.deep_merge!(input: {top_id: format})
14
14
  end
15
15
 
16
- add_option("-structure-id", "Target structure id") do |options|
17
- id = SCR.get_arg("-structure-id", with_param: true)
16
+ add_option('-structure-id', 'Target structure id') do |options|
17
+ id = SCR.get_arg('-structure-id', with_param: true)
18
18
  options.deep_merge!(source: {structure_id: id})
19
19
  end
20
20
  end
@@ -1,14 +1,14 @@
1
1
  class Eco::API::UseCases::Default::Meta::GraphQLSchema
2
2
  class Cli < Eco::API::UseCases::Cli
3
- desc "Retrieves and stores the GraphQL Schema"
3
+ desc 'Retrieves and stores the GraphQL Schema'
4
4
 
5
5
  callback do |_sess, options, _case|
6
6
  file = SCR.get_arg(cli_name, with_param: true)
7
7
  options.deep_merge!(output: {file: {name: file}})
8
8
  end
9
9
 
10
- add_option("-format", "Kind of extract (definition | json | yaml )") do |options|
11
- format = SCR.get_arg("-format", with_param: true)
10
+ add_option('-format', 'Kind of extract (definition | json | yaml )') do |options|
11
+ format = SCR.get_arg('-format', with_param: true)
12
12
  options.deep_merge!(output: {format: format})
13
13
  end
14
14
  end
@@ -3,11 +3,11 @@ class Eco::API::UseCases::Default::Meta::GraphQLSchema < Eco::API::Common::Loade
3
3
 
4
4
  require_relative 'cli/graphql_schema_cli'
5
5
 
6
- OUT_FOLDER = "sftp".freeze
6
+ OUT_FOLDER = 'sftp'.freeze
7
7
  OUT_TIME_FORMAT = '%Y%m%dT%H%M%S'.freeze
8
- OUT_FILENAME = "graphql_schema".freeze
8
+ OUT_FILENAME = 'graphql_schema'.freeze
9
9
 
10
- name "graphql-schema"
10
+ name 'graphql-schema'
11
11
  type :other
12
12
 
13
13
  def main(*_args)
@@ -5,11 +5,11 @@ class Eco::API::UseCases::Default::People::Amend::CleanUnknownTags
5
5
  str << 'It will preserve standard register tags of most common registers (i.e. EVENT, RISK).'
6
6
  desc str
7
7
 
8
- add_option("-clean-register-tags", "Will also try to remove register tags") do |options|
8
+ add_option('-clean-register-tags', 'Will also try to remove register tags') do |options|
9
9
  options.deep_merge!(usecase: {clean_register_tags: true})
10
10
  end
11
11
 
12
- add_option("-clean-archived", "Will also try to remove archived tags") do |options|
12
+ add_option('-clean-archived', 'Will also try to remove archived tags') do |options|
13
13
  options.deep_merge!(usecase: {clean_archived: true})
14
14
  end
15
15
  end
@@ -1,6 +1,6 @@
1
1
  class Eco::API::UseCases::Default::People::Amend::ReinviteSyncCase
2
2
  class Cli < Eco::API::UseCases::Default::People::Amend::ReinviteTransCase::Cli
3
- str = "Re-sends invites to target users that have not accepted the invite as yet"
3
+ str = 'Re-sends invites to target users that have not accepted the invite as yet'
4
4
  desc str
5
5
 
6
6
  cli_name '-reinvite-from'
@@ -1,10 +1,10 @@
1
1
  class Eco::API::UseCases::Default::People::Amend::ReinviteTransCase
2
2
  class Cli < Eco::API::UseCases::Cli
3
- str = "Re-sends invites to all filtered users that have not accepted the invite as yet"
3
+ str = 'Re-sends invites to all filtered users that have not accepted the invite as yet'
4
4
  desc str
5
5
 
6
- str = "If also send an invite email to those that have accepted the invite"
7
- add_option("-force", str) do |options|
6
+ str = 'If also send an invite email to those that have accepted the invite'
7
+ add_option('-force', str) do |options|
8
8
  options.deep_merge!(force: {invite: true})
9
9
  end
10
10
  end
@@ -1,25 +1,25 @@
1
1
  class Eco::API::UseCases::Default::People::Amend::RestoreDBCase
2
2
  class Cli < Eco::API::UseCases::Cli
3
- str = "Restores the people manager by using a backup.json file"
3
+ str = 'Restores the people manager by using a backup.json file'
4
4
  desc str
5
5
 
6
6
  callback do |input, session, _opts, _case|
7
- unless input && input.is_a?(Eco::API::Organization::People)
8
- file = SCR.get_file(cli_name, required: true)
9
- input = Eco::API::Organization::People.new(JSON.parse(File.read(file)))
10
- session.log(:info) {
11
- "Source DB: loaded #{input.length} entries."
12
- }
13
- end
7
+ next if input.is_a?(Eco::API::Organization::People)
8
+
9
+ file = SCR.get_file(cli_name, required: true)
10
+ input = Eco::API::Organization::People.new(JSON.parse(File.read(file)))
11
+ session.log(:info) {
12
+ "Source DB: loaded #{input.length} entries."
13
+ }
14
14
  end
15
15
 
16
- str = "If it should DELETE people that do not exist in the backup file"
17
- add_option("-include-delete", str) do |options|
16
+ str = 'If it should DELETE people that do not exist in the backup file'
17
+ add_option('-include-delete', str) do |options|
18
18
  options.deep_merge!(include: {delete: true})
19
19
  end
20
20
 
21
- str = "If it should CREATE people that do not exist in the people manager"
22
- add_option("-include-create", str) do |options|
21
+ str = 'If it should CREATE people that do not exist in the people manager'
22
+ add_option('-include-create', str) do |options|
23
23
  options.deep_merge!(include: {create: true})
24
24
  end
25
25
  end
@@ -1,9 +1,9 @@
1
1
  class Eco::API::UseCases::Default::People::Amend::RefreshCase < Eco::API::Common::Loaders::UseCase
2
- name "refresh"
2
+ name 'refresh'
3
3
  type :transform
4
4
 
5
5
  def main(people, session, _options, usecase)
6
- update = session.new_job("main", "update", :update, usecase)
6
+ update = session.new_job('main', 'update', :update, usecase)
7
7
  people.each {|person| update.add(person)}
8
8
  end
9
9
  end
@@ -1,6 +1,6 @@
1
1
  module Eco::API::UseCases::Default::People::Amend
2
2
  class ReinviteSyncCase < ReinviteTransCase
3
- name "reinvite"
3
+ name 'reinvite'
4
4
  type :sync
5
5
 
6
6
  require_relative 'cli/reinvite_sync_cli'
@@ -1,5 +1,5 @@
1
1
  class Eco::API::UseCases::Default::People::Amend::ReinviteTransCase < Eco::API::Common::Loaders::UseCase
2
- name "reinvite"
2
+ name 'reinvite'
3
3
  type :transform
4
4
 
5
5
  require_relative 'cli/reinvite_trans_cli'
@@ -11,7 +11,7 @@ class Eco::API::UseCases::Default::People::Amend::ReinviteTransCase < Eco::API::
11
11
  private
12
12
 
13
13
  def reinvite(users)
14
- invite = session.new_job("main", "invite", :update, usecase, :account)
14
+ invite = session.new_job('main', 'invite', :update, usecase, :account)
15
15
  users.each do |person|
16
16
  if force_invite?
17
17
  person.account.force_send_invites = true
@@ -97,7 +97,7 @@ class Eco::API::UseCases::Default::People::Treat::Analyse < Eco::API::Common::Lo
97
97
 
98
98
  session.process_case(
99
99
  'to-csv',
100
- type: :export,
100
+ type: :export,
101
101
  data: data,
102
102
  options: opts.merge(options.slice(:export))
103
103
  )
@@ -109,6 +109,7 @@ class Eco::API::UseCases::Default::People::Treat::Analyse < Eco::API::Common::Lo
109
109
 
110
110
  def field_similarity
111
111
  return :name unless use_field?
112
+
112
113
  use_field_proc
113
114
  end
114
115
 
@@ -1,65 +1,65 @@
1
1
  class Eco::API::UseCases::Default::People::Treat::Analyse
2
2
  class Cli < Eco::API::UseCases::Cli
3
- str = "Provides a set of tools to analyse a set of people (i.e. detect duplicates)"
3
+ str = 'Provides a set of tools to analyse a set of people (i.e. detect duplicates)'
4
4
  desc str
5
5
 
6
6
  callback do |_people, _session, options|
7
- options.deep_merge!(output: {file: "people_analysis.txt"}) unless options.dig(:output, :file)
7
+ options.deep_merge!(output: {file: 'people_analysis.txt'}) unless options.dig(:output, :file)
8
8
  #unless options.dig(:usecase, :analyse_people, :use_field)
9
9
  # options.deep_merge!(usecase: {analyse_people: {use_field: :name}})
10
10
  #end
11
11
  end
12
12
 
13
- add_option("-to", "Specify the output file.") do |options|
14
- file = SCR.get_file("-to", required: true, should_exist: false)
13
+ add_option('-to', 'Specify the output file.') do |options|
14
+ file = SCR.get_file('-to', required: true, should_exist: false)
15
15
  options.deep_merge!(output: {file: file})
16
16
  end
17
17
 
18
- str = "Generates a list of people with possible duplicates."
19
- add_option("-identify-duplicates", str) do |options|
18
+ str = 'Generates a list of people with possible duplicates.'
19
+ add_option('-identify-duplicates', str) do |options|
20
20
  options.deep_merge!(usecase: {analyse_people: {identify_duplicates: true}})
21
21
  end
22
22
 
23
- str = "Works with -identify-duplicates. Sets field to be used in the comparison."
24
- add_option("-use-field", str) do |options|
25
- expression = SCR.get_arg("-use-field", with_param: true)
23
+ str = 'Works with -identify-duplicates. Sets field to be used in the comparison.'
24
+ add_option('-use-field', str) do |options|
25
+ expression = SCR.get_arg('-use-field', with_param: true)
26
26
  options.deep_merge!(usecase: {analyse_people: {use_field: expression}})
27
27
  end
28
28
 
29
- str = "Works with -identify-duplicates. Adds an additional layer of comparison."
30
- add_option("-facet-field", str) do |options|
31
- expression = SCR.get_arg("-facet-field", with_param: true)
29
+ str = 'Works with -identify-duplicates. Adds an additional layer of comparison.'
30
+ add_option('-facet-field', str) do |options|
31
+ expression = SCR.get_arg('-facet-field', with_param: true)
32
32
  options.deep_merge!(usecase: {analyse_people: {facet_field: expression}})
33
33
  end
34
34
 
35
- str = "Works with -identify-duplicates. Skips the rearrangement stage."
36
- add_option("-only-screening", str) do |options|
35
+ str = 'Works with -identify-duplicates. Skips the rearrangement stage.'
36
+ add_option('-only-screening', str) do |options|
37
37
  options.deep_merge!(usecase: {analyse_people: {only_screening: true}})
38
38
  end
39
39
 
40
- str = "Works with -identify-duplicates. Re-adjust scores ignoring matching words."
41
- add_option("-ignore-matching-words", str) do |options|
40
+ str = 'Works with -identify-duplicates. Re-adjust scores ignoring matching words.'
41
+ add_option('-ignore-matching-words', str) do |options|
42
42
  options.deep_merge!(usecase: {analyse_people: {ignore_matching_words: true}})
43
43
  end
44
44
 
45
- str = "Works with -identify-duplicates. Re-adjust the comparing strings to do not have repeated words."
46
- add_option("-unique-words", str) do |options|
45
+ str = 'Works with -identify-duplicates. Re-adjust the comparing strings to do not have repeated words.'
46
+ add_option('-unique-words', str) do |options|
47
47
  options.deep_merge!(usecase: {analyse_people: {unique_words: true}})
48
48
  end
49
49
 
50
- add_option("-identify-unnamed", "Identifies all people with no names.") do |options|
50
+ add_option('-identify-unnamed', 'Identifies all people with no names.') do |options|
51
51
  options.deep_merge!(usecase: {analyse_people: {identify_unnamed: true}})
52
52
  end
53
53
 
54
- str = "Generates a json file with all the people involved in the final results of the analysis."
55
- add_option("-backup-people-results", str) do |options|
56
- file = SCR.get_file("-backup-people-results", required: true, should_exist: false)
54
+ str = 'Generates a json file with all the people involved in the final results of the analysis.'
55
+ add_option('-backup-people-results', str) do |options|
56
+ file = SCR.get_file('-backup-people-results', required: true, should_exist: false)
57
57
  options.deep_merge!(usecase: {analyse_people: {backup_people: File.expand_path(file)}})
58
58
  end
59
59
 
60
- str = "Genarates a CSV file with all people of the final results."
61
- add_option("-to-csv", str) do |options|
62
- file = SCR.get_file("-to-csv", required: true, should_exist: false) || "Results.csv"
60
+ str = 'Genarates a CSV file with all people of the final results.'
61
+ add_option('-to-csv', str) do |options|
62
+ file = SCR.get_file('-to-csv', required: true, should_exist: false) || 'Results.csv'
63
63
  options.deep_merge!(usecase: {analyse_people: {csv_file: File.expand_path(file)}})
64
64
  end
65
65
  end
@@ -1,7 +1,7 @@
1
1
  class Eco::API::UseCases::Default::People::Treat::OrgDataConvertCase
2
2
  class Cli < Eco::API::UseCases::Cli
3
3
  str = "Usage '#{cli_name} backup.json -restore-db-from'."
4
- str << " Transforms an input .json file to the values of the destination environment "
4
+ str << ' Transforms an input .json file to the values of the destination environment '
5
5
  str << " (names missmatch won't solve: i.e. usergroups)"
6
6
  desc str
7
7
 
@@ -16,19 +16,19 @@ class Eco::API::UseCases::Default::People::Treat::OrgDataConvertCase
16
16
 
17
17
  unless options[:source_enviro]
18
18
  session.log(:error) {
19
- "You need to specify a -source-enviro for the conversion to work out"
19
+ 'You need to specify a -source-enviro for the conversion to work out'
20
20
  }
21
21
  exit(1)
22
22
  end
23
23
  end
24
24
 
25
- str = "The defined -source-enviro API configuration that the backup file was generated from"
26
- add_option("-source-enviro", str) do |options|
27
- options.merge!(source_enviro: SCR.get_arg("-source-enviro", with_param: true))
25
+ str = 'The defined -source-enviro API configuration that the backup file was generated from'
26
+ add_option('-source-enviro', str) do |options|
27
+ options.merge!(source_enviro: SCR.get_arg('-source-enviro', with_param: true))
28
28
  end
29
29
 
30
- str = "Prevents the script to crash when backup file has missing usergroups in the org"
31
- add_option("-ignore-missing-policy-groups", str) do |options|
30
+ str = 'Prevents the script to crash when backup file has missing usergroups in the org'
31
+ add_option('-ignore-missing-policy-groups', str) do |options|
32
32
  options.deep_merge!(ignore: {missing: {policy_groups: true}})
33
33
  end
34
34
  end
@@ -1,14 +1,13 @@
1
1
  class Eco::API::UseCases::Default::People::Treat::SupersCyclicIdentify
2
2
  class Cli < Eco::API::UseCases::Cli
3
- str = "Provides a set of tools to analyse a set of people (i.e. detect duplicates)"
4
- desc str
3
+ desc 'Identifies Cyclic supervisor chains'
5
4
 
6
5
  # callback do |_people, _session, options|
7
- # options.deep_merge!(output: {file: "cyclic_supers.txt"}) unless options.dig(:output, :file)
6
+ # options.deep_merge!(output: {file: 'cyclic_supers.txt'}) unless options.dig(:output, :file)
8
7
  # end
9
8
 
10
- add_option("-to", "Specify the output file") do |options|
11
- file = SCR.get_file("-to", required: true, should_exist: false)
9
+ add_option('-to', 'Specify the output file') do |options|
10
+ file = SCR.get_file('-to', required: true, should_exist: false)
12
11
  options.deep_merge!(output: {file: file})
13
12
  end
14
13
  end
@@ -1,14 +1,14 @@
1
1
  class Eco::API::UseCases::Default::People::Treat::SupersHierarchy
2
2
  class Cli < Eco::API::UseCases::Cli
3
- str = "Draws the Supervisors hiearchy in a file"
3
+ str = 'Draws the Supervisors hiearchy in a file'
4
4
  desc str
5
5
 
6
6
  # callback do |_people, _session, options|
7
- # options.deep_merge!(output: {file: "supers_hierarchy.txt"}) unless options.dig(:output, :file)
7
+ # options.deep_merge!(output: {file: 'supers_hierarchy.txt'}) unless options.dig(:output, :file)
8
8
  # end
9
9
 
10
- add_option("-to", "Specify the output file") do |options|
11
- file = SCR.get_file("-to", required: true, should_exist: false)
10
+ add_option('-to', 'Specify the output file') do |options|
11
+ file = SCR.get_file('-to', required: true, should_exist: false)
12
12
  options.deep_merge!(output: {file: file})
13
13
  end
14
14
  end
@@ -1,5 +1,5 @@
1
1
  class Eco::API::UseCases::Default::People::Treat::OrgDataConvertCase < Eco::API::Common::Loaders::UseCase
2
- name "org-data-convert"
2
+ name 'org-data-convert'
3
3
  type :import
4
4
 
5
5
  require_relative 'cli/org_data_convert_cli'
@@ -45,7 +45,7 @@ class Eco::API::UseCases::Default::People::Treat::OrgDataConvertCase < Eco::API:
45
45
  return unless person.details
46
46
 
47
47
  person.details.as_json.tap do |details_doc|
48
- details_doc["schema_id"] = session.schema.id
48
+ details_doc['schema_id'] = session.schema.id
49
49
  person.add_details(session.schema)
50
50
  person.details = details_doc
51
51
  end
@@ -85,7 +85,7 @@ class Eco::API::UseCases::Default::People::Treat::OrgDataConvertCase < Eco::API:
85
85
  def source_enviro
86
86
  @source_enviro ||= options[:source_enviro].tap do |enviro|
87
87
  next if enviro
88
- error("A source environment is required to migrate data from")
88
+ error('A source environment is required to migrate data from')
89
89
  end
90
90
  end
91
91
 
@@ -4,9 +4,9 @@ class Eco::API::UseCases::Default::People::Treat::SupersCyclicIdentify < Eco::AP
4
4
 
5
5
  require_relative 'cli/supers_cyclic_identify_cli'
6
6
 
7
- OUT_FOLDER = "sftp".freeze
7
+ OUT_FOLDER = 'sftp'.freeze
8
8
  OUT_TIME_FORMAT = '%Y%m%dT%H%M%S'.freeze
9
- OUT_FILENAME = "cyclic_supers".freeze
9
+ OUT_FILENAME = 'cyclic_supers'.freeze
10
10
 
11
11
  def main(*_args)
12
12
  options[:end_get] = false
@@ -21,28 +21,28 @@ class Eco::API::UseCases::Default::People::Treat::SupersCyclicIdentify < Eco::AP
21
21
 
22
22
  def save!(data)
23
23
  if data.empty?
24
- log(:info) { "There were no cyclic supervisors identified!!" }
24
+ log(:info) { 'There were no cyclic supervisors identified!!' }
25
25
  return
26
26
  end
27
27
 
28
- ext = File.extname(file).downcase.delete(".")
28
+ ext = File.extname(file).downcase.delete('.')
29
29
 
30
30
  case ext
31
- when "txt"
31
+ when 'txt'
32
32
  create_file(data, file: output_filename(ext: 'txt'), format: :txt)
33
- when "html"
34
- log(:warn) { "html is still not supported" }
33
+ when 'html'
34
+ log(:warn) { 'html is still not supported' }
35
35
  exit(1)
36
36
  # create_file(data, file: file, format: :html)
37
- when "json"
38
- log(:warn) { "json is still not supported" }
37
+ when 'json'
38
+ log(:warn) { 'json is still not supported' }
39
39
  exit(1)
40
40
  # create_file(data, file: file, format: :json)
41
41
  end
42
42
  end
43
43
 
44
44
  def create_file(sets, file:, format: :txt)
45
- File.open(file, "w") do |fd|
45
+ File.open(file, 'w') do |fd|
46
46
  fd << sets_to_str(sets, format: format)
47
47
  end
48
48
 
@@ -53,7 +53,7 @@ class Eco::API::UseCases::Default::People::Treat::SupersCyclicIdentify < Eco::AP
53
53
 
54
54
  def sets_to_str(sets, format: :txt)
55
55
  raise "Required Array. Given: #{sets.class}" unless sets.is_a?(Array)
56
- "".tap do |str|
56
+ ''.tap do |str|
57
57
  sets.each do |set|
58
58
  str << set_to_str(set, format: format)
59
59
  end
@@ -63,13 +63,14 @@ class Eco::API::UseCases::Default::People::Treat::SupersCyclicIdentify < Eco::AP
63
63
  def set_to_str(set, lev: 0, format: :txt)
64
64
  raise "Required Array. Given: #{set.class}" unless set.is_a?(Array)
65
65
 
66
- "".tap do |str|
66
+ ''.tap do |str|
67
67
  entry = set.shift
68
- str << (" " * lev)
69
- str << lev&.positive? ? "+-#{lev}- " : ""
68
+ str << (' ' * lev)
69
+ str << lev&.positive? ? "+-#{lev}- " : ''
70
70
  str << entry.name
71
71
  str << " (#{entry.external_id}|#{entry.email}|#{entry.id})\n"
72
72
  next unless set && !set.empty?
73
+
73
74
  str << set_to_str(set, lev: lev + 1, format: format)
74
75
  end
75
76
  end