eco-helpers 2.6.4 → 2.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +95 -0
  4. data/CHANGELOG.md +128 -2
  5. data/Rakefile +13 -7
  6. data/eco-helpers.gemspec +2 -2
  7. data/lib/eco/api/common/loaders/base.rb +2 -2
  8. data/lib/eco/api/common/loaders/case_base.rb +1 -1
  9. data/lib/eco/api/common/loaders/config/workflow/mailer.rb +5 -5
  10. data/lib/eco/api/common/loaders/error_handler.rb +8 -5
  11. data/lib/eco/api/common/loaders/parser.rb +44 -22
  12. data/lib/eco/api/common/loaders/policy.rb +6 -4
  13. data/lib/eco/api/common/loaders/use_case.rb +13 -7
  14. data/lib/eco/api/common/people/base_parser.rb +0 -2
  15. data/lib/eco/api/common/people/default_parsers/boolean_parser.rb +0 -1
  16. data/lib/eco/api/common/people/default_parsers/csv_parser.rb +1 -1
  17. data/lib/eco/api/common/people/default_parsers/date_parser.rb +64 -12
  18. data/lib/eco/api/common/people/default_parsers/freemium_parser.rb +0 -1
  19. data/lib/eco/api/common/people/default_parsers/login_providers_parser.rb +13 -5
  20. data/lib/eco/api/common/people/default_parsers/multi_parser.rb +0 -1
  21. data/lib/eco/api/common/people/default_parsers/numeric_parser.rb +18 -5
  22. data/lib/eco/api/common/people/default_parsers/policy_groups_parser.rb +8 -8
  23. data/lib/eco/api/common/people/default_parsers/select_parser.rb +50 -26
  24. data/lib/eco/api/common/people/default_parsers/send_invites_parser.rb +6 -6
  25. data/lib/eco/api/common/people/default_parsers/xls_parser.rb +9 -12
  26. data/lib/eco/api/common/people/default_parsers.rb +1 -12
  27. data/lib/eco/api/common/people/entries.rb +13 -13
  28. data/lib/eco/api/common/people/entry_factory.rb +76 -45
  29. data/lib/eco/api/common/people/person_attribute_parser.rb +8 -12
  30. data/lib/eco/api/common/people/person_entry.rb +86 -75
  31. data/lib/eco/api/common/people/person_entry_attribute_mapper.rb +60 -44
  32. data/lib/eco/api/common/people/person_factory.rb +30 -22
  33. data/lib/eco/api/common/people/person_modifier.rb +11 -13
  34. data/lib/eco/api/common/people/person_parser.rb +101 -39
  35. data/lib/eco/api/common/people/supervisor_helpers.rb +25 -26
  36. data/lib/eco/api/common/session/base_session.rb +9 -9
  37. data/lib/eco/api/common/session/environment.rb +7 -5
  38. data/lib/eco/api/common/session/sftp.rb +59 -32
  39. data/lib/eco/api/common/version_patches/exception.rb +11 -13
  40. data/lib/eco/api/error.rb +32 -20
  41. data/lib/eco/api/organization/node_classifications.rb +82 -0
  42. data/lib/eco/api/organization/policy_groups.rb +4 -6
  43. data/lib/eco/api/organization/tag_tree.rb +169 -93
  44. data/lib/eco/api/organization.rb +1 -0
  45. data/lib/eco/api/session/batch/job.rb +1 -1
  46. data/lib/eco/api/session/config/tagtree.rb +41 -23
  47. data/lib/eco/api/session/config/workflow.rb +113 -88
  48. data/lib/eco/api/session/config.rb +6 -0
  49. data/lib/eco/api/session.rb +51 -29
  50. data/lib/eco/api/usecases/base_io.rb +28 -25
  51. data/lib/eco/api/usecases/default/locations/cli/tagtree_extract_cli.rb +7 -2
  52. data/lib/eco/api/usecases/default/locations/cli/tagtree_upload_cli.rb +21 -0
  53. data/lib/eco/api/usecases/default/locations/csv_to_tree_case.rb +3 -3
  54. data/lib/eco/api/usecases/default/locations/tagtree_extract_case.rb +54 -23
  55. data/lib/eco/api/usecases/default/locations/tagtree_upload_case.rb +87 -0
  56. data/lib/eco/api/usecases/default/locations.rb +1 -0
  57. data/lib/eco/api/usecases/default/people/analyse_people_case.rb +60 -56
  58. data/lib/eco/api/usecases/default/people/change_email_case.rb +8 -9
  59. data/lib/eco/api/usecases/default/people/clean_unknown_tags_case.rb +13 -11
  60. data/lib/eco/api/usecases/default/people/clear_abilities_case.rb +2 -2
  61. data/lib/eco/api/usecases/default/people/org_data_convert_case.rb +25 -27
  62. data/lib/eco/api/usecases/default/people/refresh_case.rb +2 -2
  63. data/lib/eco/api/usecases/default/people/reinvite_trans_case.rb +1 -1
  64. data/lib/eco/api/usecases/default/people/reinvite_trans_cli.rb +0 -1
  65. data/lib/eco/api/usecases/default/people/restore_db_case.rb +39 -34
  66. data/lib/eco/api/usecases/default/people/set_default_tag_case.rb +19 -15
  67. data/lib/eco/api/usecases/default/people/supers_cyclic_identify_case.rb +16 -12
  68. data/lib/eco/api/usecases/default_cases/hris_case.rb +17 -15
  69. data/lib/eco/api/usecases/default_cases/samples/sftp_case.rb +30 -16
  70. data/lib/eco/api/usecases/graphql/base.rb +5 -3
  71. data/lib/eco/api/usecases/graphql/helpers/base/case_env.rb +4 -1
  72. data/lib/eco/api/usecases/graphql/helpers/base/graphql_env.rb +14 -0
  73. data/lib/eco/api/usecases/graphql/helpers/base.rb +5 -4
  74. data/lib/eco/api/usecases/graphql/helpers/location/base/classifications_parser.rb +60 -0
  75. data/lib/eco/api/usecases/graphql/helpers/location/base/tree_tracking.rb +72 -0
  76. data/lib/eco/api/usecases/graphql/helpers/location/base.rb +25 -59
  77. data/lib/eco/api/usecases/graphql/helpers/location/command/diff/as_update.rb +59 -0
  78. data/lib/eco/api/usecases/graphql/helpers/location/command/diff/compare.rb +49 -0
  79. data/lib/eco/api/usecases/graphql/helpers/location/command/diff.rb +11 -0
  80. data/lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb +46 -0
  81. data/lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/diff_sortable/for_archive.rb +23 -0
  82. data/lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/diff_sortable/for_unarchive.rb +65 -0
  83. data/lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/diff_sortable.rb +49 -0
  84. data/lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/sortable/relation_safe_sort.rb +119 -0
  85. data/lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/sortable.rb +59 -0
  86. data/lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages.rb +82 -0
  87. data/lib/eco/api/usecases/graphql/helpers/location/command/diffs.rb +20 -0
  88. data/lib/eco/api/usecases/graphql/helpers/location/command/optimizations.rb +84 -0
  89. data/lib/eco/api/usecases/graphql/helpers/location/command/result.rb +4 -4
  90. data/lib/eco/api/usecases/graphql/helpers/location/command/results.rb +24 -12
  91. data/lib/eco/api/usecases/graphql/helpers/location/command.rb +21 -24
  92. data/lib/eco/api/usecases/graphql/helpers/location/tags_remap/tags_map.rb +1 -1
  93. data/lib/eco/api/usecases/graphql/helpers/location/tags_remap/tags_set.rb +10 -11
  94. data/lib/eco/api/usecases/graphql/helpers/location/tags_remap.rb +8 -9
  95. data/lib/eco/api/usecases/graphql/samples/location/command/dsl.rb +41 -12
  96. data/lib/eco/api/usecases/graphql/samples/location/command/results.rb +11 -80
  97. data/lib/eco/api/usecases/graphql/samples/location/command/service/tree_update.rb +89 -0
  98. data/lib/eco/api/usecases/graphql/samples/location/command/service.rb +6 -0
  99. data/lib/eco/api/usecases/graphql/samples/location/command/track_changed_ids.rb +89 -0
  100. data/lib/eco/api/usecases/graphql/samples/location/command.rb +3 -0
  101. data/lib/eco/api/usecases/graphql/samples/location/service/base.rb +9 -0
  102. data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/heading.rb +18 -0
  103. data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/inputable.rb +53 -0
  104. data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing/classifications.rb +34 -0
  105. data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing/helpers.rb +28 -0
  106. data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing.rb +46 -0
  107. data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible.rb +38 -0
  108. data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff.rb +105 -0
  109. data/lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/discarded.rb +16 -0
  110. data/lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/input.rb +15 -0
  111. data/lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/node_attr_maps.rb +22 -0
  112. data/lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb +45 -0
  113. data/lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter.rb +36 -0
  114. data/lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/output.rb +56 -0
  115. data/lib/eco/api/usecases/graphql/samples/location/service/tree_to_list.rb +41 -0
  116. data/lib/eco/api/usecases/graphql/samples/location/service.rb +8 -0
  117. data/lib/eco/api/usecases/graphql/samples/location.rb +1 -0
  118. data/lib/eco/api/usecases/graphql/utils/sftp.rb +96 -36
  119. data/lib/eco/api/usecases/ooze_cases/export_register_case.rb +8 -6
  120. data/lib/eco/api/usecases/ooze_samples/helpers/creatable.rb +4 -3
  121. data/lib/eco/api/usecases/ooze_samples/helpers/exportable_ooze.rb +39 -25
  122. data/lib/eco/api/usecases/ooze_samples/helpers/exportable_register.rb +13 -15
  123. data/lib/eco/api/usecases/ooze_samples/helpers/filters.rb +50 -21
  124. data/lib/eco/api/usecases/ooze_samples/helpers/ooze_handlers.rb +21 -11
  125. data/lib/eco/api/usecases/ooze_samples/helpers/rescuable.rb +2 -0
  126. data/lib/eco/api/usecases/ooze_samples/helpers/shortcuts.rb +49 -43
  127. data/lib/eco/api/usecases/ooze_samples/ooze_base_case.rb +17 -19
  128. data/lib/eco/api/usecases/ooze_samples/register_export_case.rb +48 -43
  129. data/lib/eco/api/usecases/ooze_samples/register_update_case.rb +33 -34
  130. data/lib/eco/api/usecases/ooze_samples/target_oozes_update_case.rb +8 -10
  131. data/lib/eco/api/usecases.rb +0 -1
  132. data/lib/eco/cli/config/use_cases.rb +31 -29
  133. data/lib/eco/cli_default/workflow.rb +13 -14
  134. data/lib/eco/csv/table.rb +34 -25
  135. data/lib/eco/data/hashes/array_diff.rb +24 -35
  136. data/lib/eco/data/hashes/diff_result/meta.rb +131 -0
  137. data/lib/eco/data/hashes/diff_result.rb +65 -57
  138. data/lib/eco/data/hashes/sanke_camel_indifferent_access.rb +278 -0
  139. data/lib/eco/data/hashes.rb +1 -1
  140. data/lib/eco/data/locations/convert.rb +1 -1
  141. data/lib/eco/data/locations/node_base/csv_convert.rb +19 -9
  142. data/lib/eco/data/locations/node_base/parsing.rb +4 -2
  143. data/lib/eco/data/locations/node_base/treeify.rb +149 -132
  144. data/lib/eco/data/locations/node_base.rb +15 -4
  145. data/lib/eco/data/locations/node_diff/accessors.rb +13 -5
  146. data/lib/eco/data/locations/node_diff/nodes_diff/clustered_treeify.rb +101 -0
  147. data/lib/eco/data/locations/node_diff/nodes_diff/diffs_tree.rb +99 -0
  148. data/lib/eco/data/locations/node_diff/{selectors.rb → nodes_diff/selectors.rb} +1 -1
  149. data/lib/eco/data/locations/node_diff/nodes_diff.rb +50 -35
  150. data/lib/eco/data/locations/node_diff.rb +45 -17
  151. data/lib/eco/data/locations/node_level/parsing.rb +15 -21
  152. data/lib/eco/data/locations/node_level.rb +66 -22
  153. data/lib/eco/data/locations/node_plain/parsing.rb +1 -1
  154. data/lib/eco/data/locations/node_plain.rb +60 -7
  155. data/lib/eco/data/strings/camel_case.rb +35 -0
  156. data/lib/eco/data/strings/snake_case.rb +18 -0
  157. data/lib/eco/data/strings.rb +8 -0
  158. data/lib/eco/data.rb +1 -0
  159. data/lib/eco/language/methods/call_detector.rb +11 -0
  160. data/lib/eco/language/methods/dsl_able.rb +7 -1
  161. data/lib/eco/language/methods.rb +2 -1
  162. data/lib/eco/language/models/collection.rb +23 -25
  163. data/lib/eco/language/models/parser_serializer.rb +24 -5
  164. data/lib/eco/version.rb +1 -1
  165. data/lib/eco-helpers.rb +0 -1
  166. metadata +52 -7
  167. data/lib/eco/data/hashes/diff_meta.rb +0 -52
@@ -0,0 +1,35 @@
1
+ module Eco
2
+ module Data
3
+ module Strings
4
+ module CamelCase
5
+ # From ActiveSupport
6
+ # @see https://api.rubyonrails.org/classes/ActiveSupport/Inflector.html#method-i-camelize
7
+ def camel_case(term, uppercase_first_letter = false)
8
+ string = term.to_s
9
+ # String#camelize takes a symbol (:upper or :lower), so here we also support :lower to keep the methods consistent.
10
+ if !uppercase_first_letter || uppercase_first_letter == :lower
11
+ string = string.sub(camel_regex) { |match| match.downcase! || match }
12
+ elsif string.match?(/\A[a-z\d]*\z/)
13
+ return string.capitalize
14
+ else
15
+ string = string.sub(/^[a-z\d]*/) { |match| match.capitalize! || match }
16
+ end
17
+ string.gsub!(/(?:_|(\/))([a-z\d]*)/i) do
18
+ word = $2
19
+ substituted = word.capitalize! || word
20
+ $1 ? "::#{substituted}" : substituted
21
+ end
22
+ string
23
+ end
24
+
25
+ def camel_regex
26
+ @camel_regex ||= /^(?:#{acro_regex}(?=\b|[A-Z_])|\w)/
27
+ end
28
+
29
+ def acro_regex
30
+ @acro_regex ||= /(?=a)b/
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,18 @@
1
+ module Eco
2
+ module Data
3
+ module Strings
4
+ module SnakeCase
5
+ # From ActiveSupport
6
+ # @see https://api.rubyonrails.org/classes/ActiveSupport/Inflector.html#method-i-underscore
7
+ def snake_case(camel_cased_word)
8
+ return camel_cased_word.to_s.dup unless /[A-Z-]|::/.match?(camel_cased_word)
9
+ word = camel_cased_word.to_s.gsub("::", "/")
10
+ word.gsub!(/(?<=[A-Z])(?=[A-Z][a-z])|(?<=[a-z\d])(?=[A-Z])/, "_")
11
+ word.tr!("-", "_")
12
+ word.downcase!
13
+ word
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,8 @@
1
+ require_relative 'strings/snake_case'
2
+ require_relative 'strings/camel_case'
3
+ module Eco
4
+ module Data
5
+ module Strings
6
+ end
7
+ end
8
+ end
data/lib/eco/data.rb CHANGED
@@ -3,6 +3,7 @@ module Eco
3
3
  end
4
4
  end
5
5
 
6
+ require_relative 'data/strings'
6
7
  require_relative 'data/files'
7
8
  require_relative 'data/mapper'
8
9
  require_relative 'data/fuzzy_match'
@@ -0,0 +1,11 @@
1
+ module Eco
2
+ module Language
3
+ module Methods
4
+ module CallDetector
5
+ def called_via?(klass, sym)
6
+ klass == method(sym).owner
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -7,7 +7,7 @@ module Eco
7
7
  # original evaluate caller.
8
8
  def evaluate(*args, **kargs, &block)
9
9
  return unless block_given?
10
- @self_before_evaluate = eval "self", block.binding
10
+ @self_before_evaluate = eval('self', block.binding, __FILE__, __LINE__)
11
11
  instance_exec(*args, **kargs, &block).tap do
12
12
  @self_before_evaluate = nil
13
13
  end
@@ -19,6 +19,12 @@ module Eco
19
19
  super unless @self_before_evaluate
20
20
  @self_before_evaluate.send(method, *args, **kargs, &block)
21
21
  end
22
+
23
+ # This allows to capture a method using `name` method.
24
+ # @note that for a Dsl this is not necessary
25
+ def respond_to_missing?(name, include_private = false)
26
+ super
27
+ end
22
28
  end
23
29
  end
24
30
  end
@@ -5,5 +5,6 @@ module Eco
5
5
  end
6
6
  end
7
7
 
8
- require_relative 'methods/dsl_able'
8
+ require_relative 'methods/call_detector'
9
9
  require_relative 'methods/delegate_missing'
10
+ require_relative 'methods/dsl_able'
@@ -1,14 +1,14 @@
1
+ # rubocop:disable Style/OptionalBooleanParameter
1
2
  module Eco
2
3
  module Language
3
4
  module Models
4
5
  class Collection
5
6
  include Enumerable
6
7
 
7
- BASIC_METHODS = ["present", "empty", "present_all?", "present_some?"]
8
- EXTENDED_METHODS = BASIC_METHODS + ["exclude", "remove", "attr", "attr?", "attrs", "unique_attrs", "contains"]
8
+ BASIC_METHODS = %w[present empty present_all? present_some?].freeze
9
+ EXTENDED_METHODS = BASIC_METHODS + %w[exclude remove attr attr? attrs unique_attrs contains]
9
10
 
10
11
  class << self
11
-
12
12
  def attr_presence(*attrs)
13
13
  block = ->(method) { attrs_create_method(attrs, method) }
14
14
  BASIC_METHODS.each(&block)
@@ -27,16 +27,15 @@ module Eco
27
27
  else
28
28
  attr_method = "#{attr}_#{method}"
29
29
  end
30
- define_method attr_method do |*args|
30
+ define_method attr_method do |*args|
31
31
  send(method, attr, *args)
32
32
  end
33
33
  end
34
34
  end
35
-
36
35
  end
37
36
 
38
37
  def initialize(data = [], klass:, factory: nil, handy: Eco::Assets::Language.new)
39
- raise "Raise klass required, given: #{klass}" if !klass
38
+ raise "Raise klass required, given: #{klass}" unless klass
40
39
  @klass = klass
41
40
  @factory = factory
42
41
  @handy = handy
@@ -52,7 +51,7 @@ module Eco
52
51
  newFrom to_a
53
52
  end
54
53
 
55
- def newFrom(data)
54
+ def newFrom(data) # rubocop:disable Naming/MethodName
56
55
  self.class.new(data, klass: @klass, factory: @factory)
57
56
  end
58
57
 
@@ -66,7 +65,7 @@ module Eco
66
65
  end
67
66
 
68
67
  def empty?
69
- count == 0
68
+ count.zero?
70
69
  end
71
70
 
72
71
  def each(&block)
@@ -74,19 +73,19 @@ module Eco
74
73
  @items.each(&block)
75
74
  end
76
75
 
77
- def <(value)
76
+ def <(other)
78
77
  @items.clear
79
- self << value
78
+ self << other
80
79
  end
81
80
 
82
- def <<(value)
83
- @items.concat(into_a(value))
81
+ def <<(other)
82
+ @items.concat(into_a(other))
84
83
  on_change
85
84
  self
86
85
  end
87
86
 
88
87
  def update(&block)
89
- newFrom self.map(&block)
88
+ newFrom map(&block)
90
89
  end
91
90
 
92
91
  def delete!(value)
@@ -107,7 +106,7 @@ module Eco
107
106
  return present(attr, value) if boolean?(value)
108
107
  select do |object|
109
108
  match?(attr_value(object, attr), value, modifier)
110
- end.yield_self do |matching|
109
+ end.then do |matching|
111
110
  newFrom matching
112
111
  end
113
112
  end
@@ -145,7 +144,7 @@ module Eco
145
144
 
146
145
  # @!group `attr` presence methods
147
146
  def present(attr, flag = true)
148
- block = ->(o) { attr_value_present?(o, attr) == !!flag }
147
+ block = ->(o) { attr_value_present?(o, attr) == !!flag } # rubocop:disable Style/DoubleNegation
149
148
  newFrom select(&block)
150
149
  end
151
150
 
@@ -158,7 +157,7 @@ module Eco
158
157
  end
159
158
 
160
159
  def present_some?(attr, flag = true)
161
- present(attr, flag).length > 0
160
+ present(attr, flag).length.positive?
162
161
  end
163
162
  # @!endgroup
164
163
 
@@ -177,23 +176,21 @@ module Eco
177
176
 
178
177
  def attr_value(obj, attr)
179
178
  return nil unless obj && attr
180
- case
181
- when obj.is_a?(Hash)
179
+ if obj.is_a?(Hash)
182
180
  obj[attr]
183
- when obj.respond_to?(attr.to_sym)
181
+ elsif obj.respond_to?(attr.to_sym)
184
182
  obj.send(attr)
185
183
  end
186
184
  end
187
185
 
188
186
  def attr_value_present?(obj, attr)
189
- return false unless value = attr_value(obj, attr)
190
- case
191
- when value.is_a?(Enumerable)
187
+ return false unless (value = attr_value(obj, attr))
188
+ if value.is_a?(Enumerable)
192
189
  value.count > 1
193
- when value.is_a?(String)
190
+ elsif value.is_a?(String)
194
191
  !value.strip.empty?
195
192
  else
196
- !!value
193
+ !value.nil?
197
194
  end
198
195
  end
199
196
 
@@ -214,8 +211,9 @@ module Eco
214
211
  def boolean?(value)
215
212
  value == !!value
216
213
  end
217
-
218
214
  end
219
215
  end
220
216
  end
221
217
  end
218
+
219
+ # rubocop:enable Style/OptionalBooleanParameter
@@ -47,11 +47,17 @@ module Eco
47
47
  # @note
48
48
  # - the method depenencies override keys of the _default dependencies_.
49
49
  # @raise [Exception] when there is **no** `parser` defined.
50
+ # @yield [key, value] the dependency resolver. The block is called is value is a Proc.
51
+ # @yieldparam key [Symbol] the dependency key name.
52
+ # @yieldparam value [Any] the depedency value.
53
+ # @yieldreturn value the new value
50
54
  # @param source [Any] source data to be parsed.
51
55
  # @param dependencies [Hash] _additional dependencies_ that should be merged to the _default dependencies_.
52
- def parse(source, category = :default, dependencies: {})
56
+ def parse(source, category = :default, dependencies: {}, &block)
53
57
  raise "There is no parser of type '#{category}' for this attribue '#{attr}'" unless parser_category?(category)
54
- call_block(source, @dependencies.merge(dependencies), attr, &@parser[category.to_sym])
58
+
59
+ deps = resolve_dependencies(@dependencies.merge(dependencies), &block)
60
+ call_block(source, deps, attr, &@parser[category.to_sym])
55
61
  end
56
62
 
57
63
  # Calls the `serializer` of this attribute by passing `object` and resolved dependencies.
@@ -60,9 +66,11 @@ module Eco
60
66
  # @raise [Exception] when there is **no** `serializer` defined.
61
67
  # @param object [Any] source data to be serialized.
62
68
  # @param dependencies [Hash] _additional dependencies_ that should be merged to the _default dependencies_.
63
- def serialize(object, category = :default, dependencies: {})
69
+ def serialize(object, category = :default, dependencies: {}, &block)
64
70
  raise "There is no serializer of type '#{category}' for this attribue '#{attr}'" unless serializer_category?(category)
65
- call_block(object, @dependencies.merge(dependencies), attr, &@serializer[category.to_sym])
71
+
72
+ deps = resolve_dependencies(@dependencies.merge(dependencies), &block)
73
+ call_block(object, deps, attr, &@serializer[category.to_sym])
66
74
  end
67
75
 
68
76
  # Checks if there's a `parser` defined for `category`
@@ -79,13 +87,24 @@ module Eco
79
87
 
80
88
  private
81
89
 
90
+ # For each Proc value it yields to resolve the dependency
91
+ def resolve_dependencies(deps)
92
+ return deps unless block_given?
93
+
94
+ deps.dup.tap do |out|
95
+ deps.each do |key, value|
96
+ next unless value.is_a?(Proc)
97
+ out[key] = yield(key, value)
98
+ end
99
+ end
100
+ end
101
+
82
102
  # The methods may expect less parameters from some type of parsers.
83
103
  # Here, we ensure they are called with the expected number of parameters.
84
104
  def call_block(*args, &block)
85
105
  params = block.parameters.zip(args).map(&:last)
86
106
  yield(*params)
87
107
  end
88
-
89
108
  end
90
109
  end
91
110
  end
data/lib/eco/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Eco
2
- VERSION = "2.6.4"
2
+ VERSION = "2.7.0"
3
3
  end
data/lib/eco-helpers.rb CHANGED
@@ -4,7 +4,6 @@ require 'pp'
4
4
  require 'dotenv'
5
5
  require 'dotenv/load'
6
6
 
7
-
8
7
  module Eco
9
8
  end
10
9
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eco-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.4
4
+ version: 2.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura
@@ -136,7 +136,7 @@ dependencies:
136
136
  requirements:
137
137
  - - ">="
138
138
  - !ruby/object:Gem::Version
139
- version: 1.1.6
139
+ version: 1.1.8
140
140
  - - "<"
141
141
  - !ruby/object:Gem::Version
142
142
  version: '1.2'
@@ -146,7 +146,7 @@ dependencies:
146
146
  requirements:
147
147
  - - ">="
148
148
  - !ruby/object:Gem::Version
149
- version: 1.1.6
149
+ version: 1.1.8
150
150
  - - "<"
151
151
  - !ruby/object:Gem::Version
152
152
  version: '1.2'
@@ -156,7 +156,7 @@ dependencies:
156
156
  requirements:
157
157
  - - ">="
158
158
  - !ruby/object:Gem::Version
159
- version: 0.3.13
159
+ version: 0.3.15
160
160
  - - "<"
161
161
  - !ruby/object:Gem::Version
162
162
  version: '0.4'
@@ -166,7 +166,7 @@ dependencies:
166
166
  requirements:
167
167
  - - ">="
168
168
  - !ruby/object:Gem::Version
169
- version: 0.3.13
169
+ version: 0.3.15
170
170
  - - "<"
171
171
  - !ruby/object:Gem::Version
172
172
  version: '0.4'
@@ -479,6 +479,7 @@ extra_rdoc_files: []
479
479
  files:
480
480
  - ".gitignore"
481
481
  - ".rspec"
482
+ - ".rubocop.yml"
482
483
  - ".yardopts"
483
484
  - CHANGELOG.md
484
485
  - Gemfile
@@ -589,6 +590,7 @@ files:
589
590
  - lib/eco/api/microcases/with_supervisor.rb
590
591
  - lib/eco/api/organization.rb
591
592
  - lib/eco/api/organization/login_providers.rb
593
+ - lib/eco/api/organization/node_classifications.rb
592
594
  - lib/eco/api/organization/people.rb
593
595
  - lib/eco/api/organization/people_similarity.rb
594
596
  - lib/eco/api/organization/person_schemas.rb
@@ -636,10 +638,12 @@ files:
636
638
  - lib/eco/api/usecases/default.rb
637
639
  - lib/eco/api/usecases/default/locations.rb
638
640
  - lib/eco/api/usecases/default/locations/cli/tagtree_extract_cli.rb
641
+ - lib/eco/api/usecases/default/locations/cli/tagtree_upload_cli.rb
639
642
  - lib/eco/api/usecases/default/locations/codes_to_tags_case.rb
640
643
  - lib/eco/api/usecases/default/locations/create_tag_paths_case.rb
641
644
  - lib/eco/api/usecases/default/locations/csv_to_tree_case.rb
642
645
  - lib/eco/api/usecases/default/locations/tagtree_extract_case.rb
646
+ - lib/eco/api/usecases/default/locations/tagtree_upload_case.rb
643
647
  - lib/eco/api/usecases/default/people.rb
644
648
  - lib/eco/api/usecases/default/people/analyse_people_case.rb
645
649
  - lib/eco/api/usecases/default/people/change_email_case.rb
@@ -674,9 +678,24 @@ files:
674
678
  - lib/eco/api/usecases/graphql/helpers.rb
675
679
  - lib/eco/api/usecases/graphql/helpers/base.rb
676
680
  - lib/eco/api/usecases/graphql/helpers/base/case_env.rb
681
+ - lib/eco/api/usecases/graphql/helpers/base/graphql_env.rb
677
682
  - lib/eco/api/usecases/graphql/helpers/location.rb
678
683
  - lib/eco/api/usecases/graphql/helpers/location/base.rb
684
+ - lib/eco/api/usecases/graphql/helpers/location/base/classifications_parser.rb
685
+ - lib/eco/api/usecases/graphql/helpers/location/base/tree_tracking.rb
679
686
  - lib/eco/api/usecases/graphql/helpers/location/command.rb
687
+ - lib/eco/api/usecases/graphql/helpers/location/command/diff.rb
688
+ - lib/eco/api/usecases/graphql/helpers/location/command/diff/as_update.rb
689
+ - lib/eco/api/usecases/graphql/helpers/location/command/diff/compare.rb
690
+ - lib/eco/api/usecases/graphql/helpers/location/command/diffs.rb
691
+ - lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages.rb
692
+ - lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb
693
+ - lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/diff_sortable.rb
694
+ - lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/diff_sortable/for_archive.rb
695
+ - lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/diff_sortable/for_unarchive.rb
696
+ - lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/sortable.rb
697
+ - lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/sortable/relation_safe_sort.rb
698
+ - lib/eco/api/usecases/graphql/helpers/location/command/optimizations.rb
680
699
  - lib/eco/api/usecases/graphql/helpers/location/command/result.rb
681
700
  - lib/eco/api/usecases/graphql/helpers/location/command/results.rb
682
701
  - lib/eco/api/usecases/graphql/helpers/location/tags_remap.rb
@@ -687,7 +706,26 @@ files:
687
706
  - lib/eco/api/usecases/graphql/samples/location/command.rb
688
707
  - lib/eco/api/usecases/graphql/samples/location/command/dsl.rb
689
708
  - lib/eco/api/usecases/graphql/samples/location/command/results.rb
709
+ - lib/eco/api/usecases/graphql/samples/location/command/service.rb
710
+ - lib/eco/api/usecases/graphql/samples/location/command/service/tree_update.rb
711
+ - lib/eco/api/usecases/graphql/samples/location/command/track_changed_ids.rb
690
712
  - lib/eco/api/usecases/graphql/samples/location/dsl.rb
713
+ - lib/eco/api/usecases/graphql/samples/location/service.rb
714
+ - lib/eco/api/usecases/graphql/samples/location/service/base.rb
715
+ - lib/eco/api/usecases/graphql/samples/location/service/tree_diff.rb
716
+ - lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible.rb
717
+ - lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/heading.rb
718
+ - lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/inputable.rb
719
+ - lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing.rb
720
+ - lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing/classifications.rb
721
+ - lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing/helpers.rb
722
+ - lib/eco/api/usecases/graphql/samples/location/service/tree_to_list.rb
723
+ - lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter.rb
724
+ - lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/discarded.rb
725
+ - lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/input.rb
726
+ - lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/node_attr_maps.rb
727
+ - lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb
728
+ - lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/output.rb
691
729
  - lib/eco/api/usecases/graphql/utils.rb
692
730
  - lib/eco/api/usecases/graphql/utils/sftp.rb
693
731
  - lib/eco/api/usecases/ooze_cases.rb
@@ -759,8 +797,9 @@ files:
759
797
  - lib/eco/data/fuzzy_match/string_helpers.rb
760
798
  - lib/eco/data/hashes.rb
761
799
  - lib/eco/data/hashes/array_diff.rb
762
- - lib/eco/data/hashes/diff_meta.rb
763
800
  - lib/eco/data/hashes/diff_result.rb
801
+ - lib/eco/data/hashes/diff_result/meta.rb
802
+ - lib/eco/data/hashes/sanke_camel_indifferent_access.rb
764
803
  - lib/eco/data/locations.rb
765
804
  - lib/eco/data/locations/convert.rb
766
805
  - lib/eco/data/locations/dsl.rb
@@ -774,7 +813,9 @@ files:
774
813
  - lib/eco/data/locations/node_diff.rb
775
814
  - lib/eco/data/locations/node_diff/accessors.rb
776
815
  - lib/eco/data/locations/node_diff/nodes_diff.rb
777
- - lib/eco/data/locations/node_diff/selectors.rb
816
+ - lib/eco/data/locations/node_diff/nodes_diff/clustered_treeify.rb
817
+ - lib/eco/data/locations/node_diff/nodes_diff/diffs_tree.rb
818
+ - lib/eco/data/locations/node_diff/nodes_diff/selectors.rb
778
819
  - lib/eco/data/locations/node_level.rb
779
820
  - lib/eco/data/locations/node_level/builder.rb
780
821
  - lib/eco/data/locations/node_level/cleaner.rb
@@ -785,6 +826,9 @@ files:
785
826
  - lib/eco/data/locations/node_plain/parsing.rb
786
827
  - lib/eco/data/locations/node_plain/serial.rb
787
828
  - lib/eco/data/mapper.rb
829
+ - lib/eco/data/strings.rb
830
+ - lib/eco/data/strings/camel_case.rb
831
+ - lib/eco/data/strings/snake_case.rb
788
832
  - lib/eco/language.rb
789
833
  - lib/eco/language/auxiliar_logger.rb
790
834
  - lib/eco/language/basic_logger.rb
@@ -796,6 +840,7 @@ files:
796
840
  - lib/eco/language/match.rb
797
841
  - lib/eco/language/match_modifier.rb
798
842
  - lib/eco/language/methods.rb
843
+ - lib/eco/language/methods/call_detector.rb
799
844
  - lib/eco/language/methods/delegate_missing.rb
800
845
  - lib/eco/language/methods/dsl_able.rb
801
846
  - lib/eco/language/models.rb
@@ -1,52 +0,0 @@
1
- module Eco
2
- module Data
3
- module Hashes
4
- module DiffMeta
5
- class << self
6
- def included(base)
7
- super(base)
8
- base.extend ClassMethods
9
- end
10
- end
11
-
12
- module ClassMethods
13
- # @param value [String, NilClass]
14
- # @return [String] the attribute that is key of the node diff elements.
15
- def key(value = nil)
16
- return @key unless value
17
- @key = value.to_s
18
- end
19
-
20
- # @return [Boolean] is there a `key` attribute defined?
21
- def key?
22
- !!@key
23
- end
24
-
25
- # @param attrs [Array<Symbol>, Array<String>]
26
- # @return [Array<String>] the comparable attributes
27
- def compare(*attrs)
28
- compared_attrs.push(*attrs.map(&:to_s)).uniq!
29
- compared_attrs
30
- end
31
-
32
- # Whether or not the diff calc of a node should be done case sensitive or insensitive.
33
- def case_sensitive(value = nil)
34
- @case_sensitive = false unless instance_variable_defined?(:@case_sensitive)
35
- return @case_sensitive unless value
36
- @case_sensitive = !!value
37
- end
38
-
39
- # @return [Boolean] are comparisons of values done case sensitive?
40
- def case_sensitive?
41
- !!@case_sensitive
42
- end
43
-
44
- # @return [Array<String>] the comparable attributes
45
- def compared_attrs
46
- @compared_attrs ||= []
47
- end
48
- end
49
- end
50
- end
51
- end
52
- end