eco-helpers 1.4.0 → 1.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +150 -2
  3. data/LICENSE +21 -0
  4. data/eco-helpers.gemspec +11 -10
  5. data/lib/eco/api.rb +3 -0
  6. data/lib/eco/api/common.rb +5 -1
  7. data/lib/eco/api/common/base_loader.rb +54 -0
  8. data/lib/eco/api/common/class_auto_loader.rb +109 -0
  9. data/lib/eco/api/common/class_helpers.rb +33 -0
  10. data/lib/eco/api/common/class_hierarchy.rb +1 -1
  11. data/lib/eco/api/common/class_meta_basics.rb +16 -0
  12. data/lib/eco/api/common/loaders.rb +13 -0
  13. data/lib/eco/api/common/loaders/error_handler.rb +41 -0
  14. data/lib/eco/api/common/loaders/parser.rb +127 -0
  15. data/lib/eco/api/common/loaders/policy.rb +25 -0
  16. data/lib/eco/api/common/loaders/use_case.rb +40 -0
  17. data/lib/eco/api/common/people/default_parsers.rb +5 -10
  18. data/lib/eco/api/common/people/default_parsers/boolean_parser.rb +13 -23
  19. data/lib/eco/api/common/people/default_parsers/csv_parser.rb +20 -35
  20. data/lib/eco/api/common/people/default_parsers/date_parser.rb +15 -26
  21. data/lib/eco/api/common/people/default_parsers/freemium_parser.rb +20 -0
  22. data/lib/eco/api/common/people/default_parsers/login_providers_parser.rb +26 -0
  23. data/lib/eco/api/common/people/default_parsers/multi_parser.rb +15 -27
  24. data/lib/eco/api/common/people/default_parsers/numeric_parser.rb +14 -19
  25. data/lib/eco/api/common/people/default_parsers/policy_groups_parser.rb +31 -0
  26. data/lib/eco/api/common/people/default_parsers/send_invites_parser.rb +15 -24
  27. data/lib/eco/api/common/people/entries.rb +54 -24
  28. data/lib/eco/api/common/people/entry_factory.rb +18 -15
  29. data/lib/eco/api/common/people/person_attribute_parser.rb +29 -12
  30. data/lib/eco/api/common/people/person_entry.rb +308 -216
  31. data/lib/eco/api/common/people/person_entry_attribute_mapper.rb +5 -2
  32. data/lib/eco/api/common/people/person_parser.rb +52 -19
  33. data/lib/eco/api/common/session/base_session.rb +3 -6
  34. data/lib/eco/api/common/session/environment.rb +2 -23
  35. data/lib/eco/api/common/session/logger.rb +4 -0
  36. data/lib/eco/api/common/version_patches/ecoportal_api/external_person.rb +2 -0
  37. data/lib/eco/api/common/version_patches/ecoportal_api/internal_person.rb +9 -1
  38. data/lib/eco/api/common/version_patches/exception.rb +24 -2
  39. data/lib/eco/api/custom.rb +13 -0
  40. data/lib/eco/api/custom/error_handler.rb +20 -0
  41. data/lib/eco/api/custom/namespace.rb +7 -0
  42. data/lib/eco/api/custom/parser.rb +50 -0
  43. data/lib/eco/api/custom/policy.rb +28 -0
  44. data/lib/eco/api/custom/use_case.rb +16 -0
  45. data/lib/eco/api/error.rb +1 -0
  46. data/lib/eco/api/error/handlers.rb +10 -3
  47. data/lib/eco/api/microcases.rb +35 -0
  48. data/lib/eco/api/microcases/account_excluded.rb +24 -0
  49. data/lib/eco/api/microcases/append_usergroups.rb +19 -0
  50. data/lib/eco/api/microcases/core_excluded.rb +20 -0
  51. data/lib/eco/api/microcases/fix_default_group.rb +34 -0
  52. data/lib/eco/api/microcases/fix_filter_tags.rb +42 -0
  53. data/lib/eco/api/microcases/people_cache.rb +17 -0
  54. data/lib/eco/api/microcases/people_load.rb +59 -0
  55. data/lib/eco/api/microcases/people_refresh.rb +31 -0
  56. data/lib/eco/api/microcases/people_search.rb +65 -0
  57. data/lib/eco/api/microcases/refresh_abilities.rb +19 -0
  58. data/lib/eco/api/microcases/refresh_default_tag.rb +27 -0
  59. data/lib/eco/api/microcases/s3upload_targets.rb +39 -0
  60. data/lib/eco/api/microcases/set_account.rb +20 -0
  61. data/lib/eco/api/microcases/set_core.rb +18 -0
  62. data/lib/eco/api/microcases/set_core_with_supervisor.rb +23 -0
  63. data/lib/eco/api/microcases/set_supervisor.rb +30 -0
  64. data/lib/eco/api/microcases/strict_search.rb +19 -0
  65. data/lib/eco/api/microcases/with_each.rb +27 -0
  66. data/lib/eco/api/microcases/with_each_leaver.rb +24 -0
  67. data/lib/eco/api/microcases/with_each_present.rb +30 -0
  68. data/lib/eco/api/microcases/with_each_starter.rb +30 -0
  69. data/lib/eco/api/microcases/with_each_subordinate.rb +34 -0
  70. data/lib/eco/api/microcases/with_supervisor.rb +36 -0
  71. data/lib/eco/api/organization/people.rb +72 -35
  72. data/lib/eco/api/organization/presets_factory.rb +13 -4
  73. data/lib/eco/api/organization/presets_reference.json +9 -1
  74. data/lib/eco/api/organization/presets_values.json +4 -1
  75. data/lib/eco/api/policies.rb +11 -7
  76. data/lib/eco/api/session.rb +62 -29
  77. data/lib/eco/api/session/batch.rb +2 -45
  78. data/lib/eco/api/session/batch/base_policy.rb +7 -6
  79. data/lib/eco/api/session/batch/errors.rb +28 -4
  80. data/lib/eco/api/session/batch/feedback.rb +7 -1
  81. data/lib/eco/api/session/batch/job.rb +40 -23
  82. data/lib/eco/api/session/batch/jobs.rb +9 -4
  83. data/lib/eco/api/session/batch/jobs_groups.rb +1 -1
  84. data/lib/eco/api/session/batch/request_stats.rb +91 -58
  85. data/lib/eco/api/session/batch/status.rb +35 -31
  86. data/lib/eco/api/session/config.rb +106 -44
  87. data/lib/eco/api/session/config/api.rb +132 -7
  88. data/lib/eco/api/session/config/apis.rb +24 -25
  89. data/lib/eco/api/session/config/logger.rb +2 -2
  90. data/lib/eco/api/session/config/post_launch.rb +1 -1
  91. data/lib/eco/api/session/config/workflow.rb +8 -7
  92. data/lib/eco/api/usecases.rb +47 -33
  93. data/lib/eco/api/usecases/backup/append_usergroups_case.rb +36 -0
  94. data/lib/eco/api/usecases/backup/create_case.rb +104 -0
  95. data/lib/eco/api/usecases/backup/create_details_case.rb +31 -0
  96. data/lib/eco/api/usecases/backup/create_details_with_supervisor_case.rb +48 -0
  97. data/lib/eco/api/usecases/backup/hris_case.rb +124 -0
  98. data/lib/eco/api/usecases/backup/set_default_tag_case.rb +49 -0
  99. data/lib/eco/api/usecases/backup/set_supervisor_case.rb +41 -0
  100. data/lib/eco/api/usecases/backup/transfer_account_case.rb +90 -0
  101. data/lib/eco/api/usecases/backup/update_case.rb +112 -0
  102. data/lib/eco/api/usecases/backup/update_details_case.rb +64 -0
  103. data/lib/eco/api/usecases/backup/upsert_case.rb +114 -0
  104. data/lib/eco/api/usecases/base_case.rb +2 -0
  105. data/lib/eco/api/usecases/base_io.rb +3 -3
  106. data/lib/eco/api/usecases/default_cases.rb +23 -53
  107. data/lib/eco/api/usecases/default_cases/append_usergroups_case.rb +10 -31
  108. data/lib/eco/api/usecases/default_cases/change_email_case.rb +23 -47
  109. data/lib/eco/api/usecases/default_cases/codes_to_tags_case.rb +56 -43
  110. data/lib/eco/api/usecases/default_cases/create_case.rb +15 -101
  111. data/lib/eco/api/usecases/default_cases/create_details_case.rb +11 -26
  112. data/lib/eco/api/usecases/default_cases/create_details_with_supervisor_case.rb +12 -43
  113. data/lib/eco/api/usecases/default_cases/delete_sync_case.rb +11 -0
  114. data/lib/eco/api/usecases/default_cases/delete_trans_case.rb +14 -0
  115. data/lib/eco/api/usecases/default_cases/email_as_id_case.rb +10 -21
  116. data/lib/eco/api/usecases/default_cases/hris_case.rb +23 -120
  117. data/lib/eco/api/usecases/default_cases/new_email_case.rb +10 -23
  118. data/lib/eco/api/usecases/default_cases/new_id_case.rb +11 -25
  119. data/lib/eco/api/usecases/default_cases/new_id_case0.rb +14 -0
  120. data/lib/eco/api/usecases/default_cases/org_data_convert_case.rb +83 -0
  121. data/lib/eco/api/usecases/default_cases/refresh_abilities_case.rb +30 -0
  122. data/lib/eco/api/usecases/default_cases/refresh_case.rb +7 -20
  123. data/lib/eco/api/usecases/default_cases/reinvite_sync_case.rb +11 -0
  124. data/lib/eco/api/usecases/default_cases/reinvite_trans_case.rb +17 -0
  125. data/lib/eco/api/usecases/default_cases/remove_account_sync_case.rb +11 -0
  126. data/lib/eco/api/usecases/default_cases/remove_account_trans_case.rb +17 -0
  127. data/lib/eco/api/usecases/default_cases/reset_landing_page_case.rb +9 -19
  128. data/lib/eco/api/usecases/default_cases/restore_db_case.rb +92 -0
  129. data/lib/eco/api/usecases/default_cases/set_default_tag_case.rb +32 -40
  130. data/lib/eco/api/usecases/default_cases/set_supervisor_case.rb +15 -33
  131. data/lib/eco/api/usecases/default_cases/switch_supervisor_case.rb +66 -57
  132. data/lib/eco/api/usecases/default_cases/to_csv_case.rb +36 -44
  133. data/lib/eco/api/usecases/default_cases/to_csv_detailed_case.rb +40 -55
  134. data/lib/eco/api/usecases/default_cases/transfer_account_case.rb +264 -84
  135. data/lib/eco/api/usecases/default_cases/update_case.rb +15 -109
  136. data/lib/eco/api/usecases/default_cases/update_details_case.rb +14 -61
  137. data/lib/eco/api/usecases/default_cases/upsert_case.rb +16 -111
  138. data/lib/eco/api/usecases/use_case_io.rb +9 -9
  139. data/lib/eco/cli/config.rb +10 -2
  140. data/lib/eco/cli/config/default.rb +2 -1
  141. data/lib/eco/cli/config/default/input_filters.rb +58 -0
  142. data/lib/eco/cli/config/default/options.rb +60 -25
  143. data/lib/eco/cli/config/default/people.rb +4 -4
  144. data/lib/eco/cli/config/default/people_filters.rb +108 -0
  145. data/lib/eco/cli/config/default/usecases.rb +69 -32
  146. data/lib/eco/cli/config/default/workflow.rb +37 -27
  147. data/lib/eco/cli/config/filters.rb +50 -0
  148. data/lib/eco/cli/config/filters/input_filters.rb +29 -0
  149. data/lib/eco/cli/config/filters/people_filters.rb +29 -0
  150. data/lib/eco/cli/config/help.rb +49 -0
  151. data/lib/eco/cli/config/options_set.rb +17 -1
  152. data/lib/eco/cli/config/use_cases.rb +79 -53
  153. data/lib/eco/cli/scripting.rb +10 -2
  154. data/lib/eco/cli/scripting/args_helpers.rb +25 -15
  155. data/lib/eco/cli/scripting/argument.rb +1 -0
  156. data/lib/eco/cli/scripting/arguments.rb +1 -1
  157. data/lib/eco/csv.rb +8 -3
  158. data/lib/eco/csv/table.rb +1 -1
  159. data/lib/eco/data/crypto/encryption.rb +3 -0
  160. data/lib/eco/data/files/helpers.rb +6 -1
  161. data/lib/eco/language/match.rb +19 -9
  162. data/lib/eco/language/match_modifier.rb +13 -5
  163. data/lib/eco/language/models/collection.rb +77 -56
  164. data/lib/eco/language/models/parser_serializer.rb +39 -15
  165. data/lib/eco/version.rb +1 -1
  166. metadata +149 -63
  167. data/lib/eco/api/session/task.rb +0 -175
  168. data/lib/eco/api/usecases/default_case.rb +0 -19
  169. data/lib/eco/api/usecases/default_cases/delete_case.rb +0 -32
  170. data/lib/eco/api/usecases/default_cases/recover_db_case.rb +0 -98
  171. data/lib/eco/api/usecases/default_cases/refresh_presets_case.rb +0 -26
  172. data/lib/eco/api/usecases/default_cases/reinvite_case.rb +0 -41
  173. data/lib/eco/api/usecases/default_cases/remove_account_case.rb +0 -38
  174. data/lib/eco/cli/config/default/filters.rb +0 -70
  175. data/lib/eco/cli/config/people_filters.rb +0 -38
@@ -1,19 +0,0 @@
1
- module Eco
2
- module API
3
- class UseCases
4
- class DefaultCase
5
-
6
- def initialize(cases, **options)
7
- raise "Expected a Eco::API::UseCases object. Given #{cases.class}" if !cases.is_a?(Eco::API::UseCases)
8
- @cases = cases
9
- @options = options
10
- end
11
-
12
- def process
13
- raise "You should reimplement this method"
14
- end
15
-
16
- end
17
- end
18
- end
19
- end
@@ -1,32 +0,0 @@
1
- module Eco
2
- module API
3
- class UseCases
4
- class DefaultCases
5
- class DeleteCase < DefaultCase
6
-
7
- def process
8
- @cases.define("delete", type: :transform) do |people, session, options, usecase|
9
- delete = session.job_group("main").new("delete", usecase: usecase, type: :delete, sets: [:core, :details, :account])
10
- people.each_with_index do |person, i|
11
- delete.add(person)
12
- end
13
- end
14
-
15
- @cases.define("delete", type: :sync) do |entries, people, session, options, usecase|
16
- delete = session.job_group("main").new("delete", usecase: usecase, type: :delete, sets: [:core, :details, :account])
17
- strict_search = session.config.people.strict_search? && (!options[:search]&.key?(:strict) || options.dig(:search, :strict))
18
- entries.each_with_index do |entry, i|
19
- if person = people.find(entry, strict: strict_search)
20
- delete.add(person)
21
- else
22
- session.logger.error("Entry(#{i}) - this person does not exist: #{entry.to_s(:identify)}")
23
- end
24
- end
25
- end
26
- end
27
-
28
- end
29
- end
30
- end
31
- end
32
- end
@@ -1,98 +0,0 @@
1
- module Eco
2
- module API
3
- class UseCases
4
- class DefaultCases
5
- class RecoverDBCase < DefaultCase
6
-
7
- def process
8
- @cases.define("recover-db", type: :sync) do |entries, people, session, options, usecase|
9
- unless entries.is_a?(Eco::API::Organization::People)
10
- raise "Your input should be an 'Eco::API::Organization::People' object. Got: #{entries.class}"
11
- end
12
-
13
- if options.dig(:include, :create)
14
- creation = session.job_group("main").new("create", usecase: usecase, type: :create, sets: [:core, :details, :account])
15
- end
16
-
17
- update = session.job_group("main").new("update", usecase: usecase, type: :update, sets: [:core, :details, :account])
18
-
19
- if options.dig(:include, :delete)
20
- remove = session.job_group("main").new("remove", usecase: usecase, type: :delete, sets: [:core, :details, :account])
21
- people.exclude(entries).map {|person| remove.add(person)}
22
- end
23
-
24
- strict_search = session.config.people.strict_search? && (!options[:search]&.key?(:strict) || options.dig(:search, :strict))
25
- pgs = session.policy_groups
26
-
27
- not_exist = []
28
-
29
- entries.each.with_index do |entry, i|
30
- create = ! (person = people.find(entry, strict: strict_search))
31
-
32
- if create && !options.dig(:include, :create)
33
- not_exist.push(entry);
34
- else
35
- person = session.new_person if create
36
-
37
- unless options.dig(:exclude, :core)
38
- person.external_id = entry.external_id unless options.dig(:exclude, :external_id)
39
- person.name = entry.name unless options.dig(:exclude, :name)
40
- person.email = entry.email unless options.dig(:exclude, :email)
41
- person.supervisor_id = entry.supervisor_id unless options.dig(:exclude, :supervisor)
42
- person.filter_tags = entry.filter_tags || [] unless options.dig(:exclude, :filter_tags)
43
- end
44
-
45
- unless options.dig(:exclude, :account)
46
- #person.account = entry.account
47
- if eaccount = entry.account
48
- person.account ||= {}
49
- person.account.default_tag = eaccount.default_tag unless options.dig(:exclude, :filter_tags)
50
-
51
- unless options.dig(:exclude, :policy_groups) && person.account.policy_group_ids
52
- person.account.policy_group_ids = eaccount.policy_group_ids
53
- end
54
-
55
- unless options.dig(:exclude, :abilities) && (person.account.permissions_preset || person.account.permissions_custom)
56
- person.account.permissions_preset = eaccount.permissions_preset if eaccount.permissions_preset
57
- person.account.permissions_custom = eaccount.permissions_custom
58
- end
59
- person.account.login_provider_ids = eaccount.login_provider_ids if eaccount.login_provider_ids
60
- person.account.accept_eula = eaccount.accept_eula if eaccount.accept_eula
61
-
62
- if eaccount.preferences
63
- person.account.doc["preferences"] = JSON.parse((eaccount.doc["preferences"] || {}).to_json)
64
- end
65
-
66
- person.account.starred_ids = eaccount.starred_ids if eaccount.landing_page_id
67
- person.account.landing_page_id = eaccount.landing_page_id if eaccount.landing_page_id
68
-
69
- person.account&.send_invites = options[:send_invites] if options.key?(:send_invites)
70
- end
71
- end
72
-
73
- unless options.dig(:exclude, :details)
74
- person.details = entry.details
75
- end
76
-
77
- creation.add(person) if create
78
- update.add(person) unless create
79
- end
80
- end
81
-
82
- unless not_exist.empty?
83
- session.logger.error("There were #{not_exist.length} entries of the back up that do not exist in the (filtered?) people manager")
84
- session.logger.error("Some examples:")
85
- not_exist.slice(0, 4).each_with_index do |entry, i|
86
- session.logger.error("Entry(#{i}) - this person does not exist: #{entry.name} (#{entry.email})")
87
- end
88
- end
89
-
90
- end
91
- end
92
-
93
- end
94
-
95
- end
96
- end
97
- end
98
- end
@@ -1,26 +0,0 @@
1
- module Eco
2
- module API
3
- class UseCases
4
- class DefaultCases
5
- class RefreshPresets < DefaultCase
6
-
7
- def process
8
- @cases.define("refresh-presets", type: :transform) do |people, session, options, usecase|
9
- job = session.job_group("main").new("update", usecase: usecase, type: :update, sets: :account)
10
-
11
- users = people.users
12
- session.logger.warn("There are no people with account amoung your #{people.length} people") unless users.length > 0
13
- users.each do |person|
14
- person.account.permissions_custom = session.new_preset(person)
15
- job.add(person)
16
- end
17
-
18
- end
19
- end
20
-
21
- end
22
-
23
- end
24
- end
25
- end
26
- end
@@ -1,41 +0,0 @@
1
- module Eco
2
- module API
3
- class UseCases
4
- class DefaultCases
5
- class ReinviteCase < DefaultCase
6
-
7
- def process
8
- @cases.define("reinvite", type: :transform) do |people, session, options, usecase|
9
- invite = session.job_group("main").new("invite", usecase: usecase, type: :update, sets: :account)
10
- people.users.each do |person|
11
- person.account.send_invites = true
12
- invite.add(person)
13
- end
14
- invite
15
- end
16
-
17
- @cases.define("reinvite", type: :sync) do |entries, people, session, options, usecase|
18
- invite = session.job_group("main").new("invite", usecase: usecase, type: :update, sets: :account)
19
-
20
- users = people.users
21
- strict_search = session.config.people.strict_search? && (!options[:search]&.key?(:strict) || options.dig(:search, :strict))
22
-
23
- entries.each_with_index do |entry, i|
24
- if person = people.find(entry, strict: strict_search)
25
- if person.account
26
- person.account.send_invites = true
27
- invite.add(person)
28
- end
29
- else
30
- session.logger.error("Entry(#{i}) - this person does not exist: #{entry.to_s(:identify)}")
31
- end
32
- end
33
-
34
- end
35
- end
36
-
37
- end
38
- end
39
- end
40
- end
41
- end
@@ -1,38 +0,0 @@
1
- module Eco
2
- module API
3
- class UseCases
4
- class DefaultCases
5
- class RemoveAccountCase < DefaultCase
6
-
7
- def process
8
-
9
- @cases.define("remove-account", type: :transform) do |people, session, options, usecase|
10
- update = session.job_group("main").new("update", usecase: usecase, type: :update, sets: [:core, :account])
11
- people.users.map do |person|
12
- person.account = nil
13
- update.add(person)
14
- end
15
- end
16
-
17
- @cases.define("remove-account", type: :sync) do |entries, people, session, options, usecase|
18
- update = session.job_group("main").new("update", usecase: usecase, type: :update, sets: [:core, :account])
19
-
20
- strict_search = session.config.people.strict_search? && (!options[:search]&.key?(:strict) || options.dig(:search, :strict))
21
-
22
- entries.each.with_index do |entry, i|
23
- if person = people.find(entry, strict: strict_search)
24
- person.account = nil
25
- update.add(person)
26
- else
27
- session.logger.error("Entry(#{i}) - this person does not exist: #{entry.to_s(:identify)}")
28
- end
29
- end
30
- end
31
-
32
- end
33
-
34
- end
35
- end
36
- end
37
- end
38
- end
@@ -1,70 +0,0 @@
1
- ASSETS.cli.config do |cnf|
2
- cnf.people_filters do |filters|
3
-
4
- filters.add("-only-users") do |people, session, options|
5
- options.deep_merge!(people: {filter: {account: true}})
6
- people.users
7
- end
8
-
9
- filters.add("-no-account") do |people, session, options|
10
- options.deep_merge!(people: {filter: {account: false}})
11
- people.account_present(false)
12
- end
13
-
14
- filters.add("-with-details") do |people, session, options|
15
- options.deep_merge!(people: {filter: {details: true}})
16
- people.details_present
17
- end
18
-
19
- filters.add("-no-id") do |people, session, options|
20
- options.deep_merge!(people: {filter: {external_id: nil}})
21
- people.external_id_present(false)
22
- end
23
-
24
- filters.add("-supervisors") do |people, session, options|
25
- options.deep_merge!(people: {filter: {subordinates: true}})
26
- people.newFrom people.to_a.select {|person| person.subordinates > 0}
27
- end
28
-
29
- filters.add("-supervisor-id") do |people, session, options|
30
- id = SCR.get_arg("-supervisor-id", with_param: true)
31
- options.deep_merge!(people: {filter: {supervisor_id: id}})
32
- unless sup = people.person(id: id, external_id: id, email: id, strict: true)
33
- status = session.batch.search([{"id" => id}])
34
- sup = status.people.first
35
- end
36
- raise "Supervisor with id '#{id}' does not exist" unless sup
37
- people.supervisor_id(sup.id)
38
- end
39
-
40
- filters.add("-no-default-tag") do |people, session, options|
41
- options.deep_merge!(people: {filter: {account: {default_tag: nil}}})
42
- filtered = people.select do |person|
43
- !person.account&.default_tag
44
- end
45
- people.newFrom filtered
46
- end
47
-
48
- filters.add("-schema-id") do |people, session, options|
49
- sch_name = SCR.get_arg("-schema-id", with_param: true)
50
- sch_id = session.schemas.to_id(sch_name)
51
-
52
- unless sch_id
53
- msg = "You need to specify the schema id"
54
- session.logger.error(msg)
55
- exit(1)
56
- end
57
-
58
- options.deep_merge!(people: {filter: {details: {schema_id: sch_id}}})
59
- session.logger.info("Filtering people entries with schema #{session.schemas.to_name(sch_id)}")
60
-
61
- filtered = people.select do |person|
62
- person.details && (person.details.schema_id == sch_id)
63
- end
64
- session.logger.info("Filtered #{filtered.count} people out of #{people.count} total")
65
-
66
- people.newFrom filtered
67
- end
68
-
69
- end
70
- end
@@ -1,38 +0,0 @@
1
- module Eco
2
- class CLI
3
- class Config
4
- class PeopleFilters
5
- attr_reader :core_config
6
-
7
- def initialize(core_config:)
8
- @core_config = core_config
9
- @filters = {}
10
- end
11
-
12
- def add(option)
13
- raise "Missing block to define the filters builder" unless block_given?
14
- callback = Proc.new
15
- [option].flatten.compact.each do |opt|
16
- @filters[opt] = callback
17
- end
18
- self
19
- end
20
-
21
- def process(io:)
22
- unless io && io.is_a?(Eco::API::UseCases::BaseIO)
23
- raise "You need to provide Eco::API::UseCases::BaseIO object. Given: #{io.class}"
24
- end
25
-
26
- io = io.new(type: :transform)
27
- @filters.each do |arg, callback|
28
- if SCR.get_arg(arg)
29
- io = io.new(people: callback.call(*io.params))
30
- end
31
- end
32
- io.people
33
- end
34
-
35
- end
36
- end
37
- end
38
- end