eco-helpers 2.4.7 → 2.4.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0ab1e50c5ccc57fd84bd6b21b40a9d455455e3457c89248f7bf60177fe82293a
4
- data.tar.gz: 169a31ded9574a5fd8a135a0cfe3f388fe71c48e87f7f67969e12036ba40ab3f
3
+ metadata.gz: 5f4b841b95f31b7f25c9b5fd33c949bedbc46f2850c0c68b863818f3c75105b1
4
+ data.tar.gz: 4ec1d5c2859303fa6943974d19d07c7a4391f4d76fe2a01682510a26e9f92016
5
5
  SHA512:
6
- metadata.gz: 7de4657000ee0181e9c7dcea3536365c5a66fc26d5b25999715129ce4ebed459ba67042de42736b96879b617aba2adc063f92403f0ff063cac13fd5301562191
7
- data.tar.gz: e9518629a51f623b07d795eedad394682b53bc23edf1389cb2185f34519ccaed8cf2c746eba8c8ae0c4e12b41068b7444f2f6f263e3a30cd5ab91aa45be09185
6
+ metadata.gz: 84a0e4e6191ec10cf37088afce2fff53f9450b4d14f5d8c6206b152d4a0b4758127e5b8df0e3807c99c7dc99263de434fa92787baa778de9322ef56704ea9acd
7
+ data.tar.gz: 26b7d8b4e627c8638dd2b392063a25f4f7a633ea13ee3fe6f71bfccff81a3160cee957abc905d1f07e9f6c9e029a507e85b2f256120729fe5096fb2ea83c5018
data/CHANGELOG.md CHANGED
@@ -1,12 +1,37 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
- ## [2.4.8] - 2023-04-xx
4
+ ## [2.4.10] - 2023-04-xx
5
5
 
6
6
  ### Added
7
7
  ### Changed
8
8
  ### Fixed
9
9
 
10
+ ## [2.4.9] - 2023-04-17
11
+
12
+ ### Added
13
+ - `Eco::API::UseCases#source_object` to retrieve the original use case definition object
14
+ - This allows the `Eco::API::UseCases::UseCase` object to access the object that defined the usecase and initialize `@session`.
15
+ - It now can know what `type` of use case created the `@callback`
16
+ - Next steps with this may be play a bit with the `aritity` of the `@callback` block, allow parsers to skip the serializer definition (so the default one runs), etc.
17
+ - `Eco::API::Common::Loaders::Base` the above feature allowed to initialize the `@options`, and therefore...
18
+ - `#options` method **added** (based on `@options` instance var)
19
+
20
+ ### Changed
21
+ - `Eco::API::Common::Loaders::Base`
22
+ - `#session` method is based on `@session` instance var, which allows to override without having to redefine `session` (`attr_reader :session` is no longer necessary)
23
+ - Softened max version of **gem** dependencies
24
+ - Upgraded self-managed **gem** dependencies
25
+
26
+ ### Fixed
27
+ - `Eco::API::Common::ClassAutoLoader::autoload_children`
28
+ - Skip `singleton_classes`
29
+
30
+ ## [2.4.8] - 2023-04-03
31
+
32
+ ### Added
33
+ - `Eco::API::Organization::TagTree#ancestors` returns the ancestor nodes.
34
+
10
35
  ## [2.4.7] - 2023-04-03
11
36
 
12
37
  ### Added
data/eco-helpers.gemspec CHANGED
@@ -24,24 +24,24 @@ Gem::Specification.new do |spec|
24
24
  #spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
25
25
  spec.require_paths = ["lib"]
26
26
 
27
- spec.add_development_dependency "bundler", ">= 2.4.8", "< 2.5"
28
- spec.add_development_dependency "rspec", ">= 3.10.0", "< 3.11"
29
- spec.add_development_dependency "rake", ">= 13.0.3", "< 13.1"
30
- spec.add_development_dependency "yard", ">= 0.9.26", "< 0.10"
31
- spec.add_development_dependency "redcarpet", ">= 3.5.1", "< 3.6"
27
+ spec.add_development_dependency "bundler", ">= 2.4.8", "< 3"
28
+ spec.add_development_dependency "rspec", ">= 3.10.0", "< 4"
29
+ spec.add_development_dependency "rake", ">= 13.0.3", "< 14"
30
+ spec.add_development_dependency "yard", ">= 0.9.26", "< 1"
31
+ spec.add_development_dependency "redcarpet", ">= 3.5.1", "< 4"
32
32
 
33
- spec.add_dependency 'ecoportal-api', '>= 0.9.3', '< 0.10'
34
- spec.add_dependency 'ecoportal-api-v2', '>= 1.1.1', '< 1.2'
35
- spec.add_dependency 'ecoportal-api-graphql', '>= 0.3.5', '< 0.4'
33
+ spec.add_dependency 'ecoportal-api', '>= 0.9.4', '< 0.10'
34
+ spec.add_dependency 'ecoportal-api-v2', '>= 1.1.2', '< 1.2'
35
+ spec.add_dependency 'ecoportal-api-graphql', '>= 0.3.6', '< 0.4'
36
36
  spec.add_dependency 'aws-sdk-s3', '>= 1.83.0', '< 2'
37
37
  spec.add_dependency 'aws-sdk-ses', '>= 1.36.0', '< 2'
38
- spec.add_dependency 'dotenv', '>= 2.7.6', '< 2.8'
39
- spec.add_dependency 'net-sftp', '>= 3.0.0', '< 3.1'
40
- spec.add_dependency 'hashdiff', '>= 1.0.1', '< 1.1'
41
- spec.add_dependency 'fuzzy_match', '>= 2.1.0', '< 2.2'
42
- spec.add_dependency 'amatch', '>= 0.4.0', '< 0.5'
43
- spec.add_dependency 'jaro_winkler', '>= 1.5.4', '< 1.6'
44
- spec.add_dependency 'roo', '>= 2.8.3', '< 2.9'
45
- spec.add_dependency 'roo-xls', '>= 1.2.0', '< 1.3'
46
- spec.add_dependency 'docx', '>= 0.6.2', '< 0.7'
38
+ spec.add_dependency 'dotenv', '>= 2.7.6', '< 3'
39
+ spec.add_dependency 'net-sftp', '>= 3.0.0', '< 4'
40
+ spec.add_dependency 'hashdiff', '>= 1.0.1', '< 1.1'
41
+ spec.add_dependency 'fuzzy_match', '>= 2.1.0', '< 2.2'
42
+ spec.add_dependency 'amatch', '>= 0.4.0', '< 0.5'
43
+ spec.add_dependency 'jaro_winkler', '>= 1.5.4', '< 1.6'
44
+ spec.add_dependency 'roo', '>= 2.8.3', '< 2.9'
45
+ spec.add_dependency 'roo-xls', '>= 1.2.0', '< 1.3'
46
+ spec.add_dependency 'docx', '>= 0.6.2', '< 0.7'
47
47
  end
@@ -80,8 +80,14 @@ module Eco
80
80
  return false if pending_children.empty?
81
81
  @loading_children = true
82
82
  pending_children.each do |klass|
83
- @child = klass.new(object)
84
- autoloaded_children.push(klass)
83
+ begin
84
+ @child = klass.new(object)
85
+ rescue TypeError => e
86
+ # Can't create from this class (must be the singleton class)
87
+ # Just ignore
88
+ ensure
89
+ autoloaded_children.push(klass)
90
+ end
85
91
  end
86
92
  @loading_children = false
87
93
  true
@@ -102,7 +108,6 @@ module Eco
102
108
  def new_classes
103
109
  ObjectSpace.each_object(::Class).to_a - known_classes
104
110
  end
105
-
106
111
  end
107
112
  end
108
113
  end
@@ -36,7 +36,11 @@ module Eco
36
36
  private
37
37
 
38
38
  def session
39
- ASSETS.session
39
+ @session ||= ASSETS.session
40
+ end
41
+
42
+ def options
43
+ @options ||= {}
40
44
  end
41
45
 
42
46
  def config
@@ -11,7 +11,7 @@ module Eco
11
11
  # @return [RequiredAttrs]
12
12
  def required_attrs
13
13
  @required_attrs ||= @dependencies[:required_attrs]
14
- #@required_attrs ||= RequiredAttrs.new(attr, :unkown, [attr])
14
+ #@required_attrs ||= RequiredAttrs.new(attr, :unknown, [attr])
15
15
  end
16
16
 
17
17
  # @see Eco::Language::Models::ParserSerializer#def_parser
@@ -174,7 +174,7 @@ module Eco
174
174
 
175
175
  # Helper to define and associate a parser/serializer to a type or attribute.
176
176
  # @raise [Exception] if trying to define a parser/serializer for:
177
- # - an unkown attribute (`String`)
177
+ # - an unknown attribute (`String`)
178
178
  # - an unrecognized type or format (`Symbol`)
179
179
  # @param attr [String] type (`Symbol`) or attribute (`String`) to define the parser/serializer to.
180
180
  # @param dependencies [Hash] dependencies to be used when calling the parser/serializer.
@@ -57,8 +57,8 @@ module Eco
57
57
  return log(:fatal, *args, &block)
58
58
  end
59
59
 
60
- def unkown(msg, &block)
61
- return log(:unkown, *args, &block)
60
+ def unknown(msg, &block)
61
+ return log(:unknown, *args, &block)
62
62
  end
63
63
 
64
64
  def << (msg)
data/lib/eco/api/error.rb CHANGED
@@ -4,7 +4,7 @@ module Eco
4
4
  class Error < StandardError
5
5
  class UnknownErrorClass < StandardError
6
6
  def initialize(msg = nil, klass:)
7
- msg ||= "Unkown api error class #{klass}"
7
+ msg ||= "Unknown api error class #{klass}"
8
8
  super(msg)
9
9
  end
10
10
  end
@@ -60,19 +60,19 @@ module Eco
60
60
  @str_err = "Invalid ObjectId."
61
61
  @match = /'(.*?)' is an invalid ObjectId./
62
62
  end
63
- class UnkownField < Eco::API::Error
63
+ class UnknownField < Eco::API::Error
64
64
  @str_err = "Unknown field."
65
65
  @match = /(.+?) is an unknown field/
66
66
 
67
- class UnkownCoreField < UnkownField
67
+ class UnknownCoreField < UnknownField
68
68
  @str_err = "Unknown core field."
69
69
  @match = /(.+?) is an unknown field/
70
70
  end
71
- class UnkownAccountField < UnkownField
71
+ class UnknownAccountField < UnknownField
72
72
  @str_err = "Unknown account field."
73
73
  @match = /account \> (.+?) is an unknown field/
74
74
  end
75
- class UnkownDetailsField < UnkownField
75
+ class UnknownDetailsField < UnknownField
76
76
  @str_err = "Unknown details field."
77
77
  @match = /details \> (.+?) is an unknown field/
78
78
  end
@@ -84,7 +84,7 @@ module Eco
84
84
 
85
85
  # All actual nodes of this tree
86
86
  # @note order is that of the parent to child relationships
87
- # @return [Array[]]
87
+ # @return [Array<TagTree>]
88
88
  def all_nodes(&block)
89
89
  [].tap do |out_nodes|
90
90
  unless top?
@@ -97,6 +97,18 @@ module Eco
97
97
  end
98
98
  end
99
99
 
100
+ # All the acenstor nodes of the current node
101
+ # @note it does not include the current node
102
+ # @return [Array<TagTree>] ancestors sorted from top to bottom.
103
+ def ancestors
104
+ [].tap do |ans|
105
+ unless parent.top?
106
+ ans << parent
107
+ ans.concat(parent.ancestors)
108
+ end
109
+ end
110
+ end
111
+
100
112
  # @return [Array] with the differences
101
113
  def diff(tagtree, differences: {}, level: 0, **options)
102
114
  require 'hashdiff'
@@ -114,8 +126,11 @@ module Eco
114
126
  nodes_json
115
127
  else
116
128
  {
117
- "id" => tag,
118
- "nodes" => nodes_json
129
+ "id" => tag,
130
+ "archived" => archived,
131
+ "archived_token" => archived_token,
132
+ "weight" => weight,
133
+ "nodes" => nodes_json
119
134
  }
120
135
  end
121
136
  end
@@ -17,6 +17,11 @@ module Eco
17
17
  @times_launched = 0
18
18
  end
19
19
 
20
+ def source_object
21
+ return nil unless callback_from_loader?
22
+ callback_self
23
+ end
24
+
20
25
  def chainer
21
26
  # TODO: root is a Eco::API::UseCases that will not point to this new case.
22
27
  # => Moreover, the name and type will be the same as self
@@ -42,6 +47,7 @@ module Eco
42
47
  UseCaseIO.new(**kargs).tap do |uio|
43
48
  @options = uio.options
44
49
  uio.session.logger.debug("#{self.class}: going to process '#{name}'")
50
+ set_session_n_options(session: uio.session, options: uio.options) if callback_from_loader?
45
51
  uio.output = @callback.call(*uio.params)
46
52
  @times_launched += 1
47
53
  end
@@ -53,8 +59,28 @@ module Eco
53
59
  @callback
54
60
  end
55
61
 
56
- end
62
+ def callback_self
63
+ eval("self", @callback.binding)
64
+ end
57
65
 
66
+ def callback_from_loader?
67
+ callback_self.is_a?(Eco::API::Common::Loaders::Base)
68
+ end
69
+
70
+ # Set the instance variables `@session` and `@options`
71
+ # in the use case definition
72
+ # @note this only works when the use case was defined
73
+ # via an children class of `Eco::API::Common::Loaders::Base`
74
+ def set_session_n_options(session:, options: @options)
75
+ return false unless callback_from_loader?
76
+ callback_self.instance_eval do
77
+ # `self` is the use case itself (when used the Loader)
78
+ @session = session
79
+ @options = options
80
+ end
81
+ true
82
+ end
83
+ end
58
84
  end
59
85
  end
60
86
  end
@@ -2,9 +2,9 @@ module Eco
2
2
  module API
3
3
  class UseCases
4
4
 
5
- class UnkownCase < StandardError
5
+ class UnknownCase < StandardError
6
6
  def initialize(msg = nil, case_name: nil, type: nil)
7
- msg ||= "Unkown case"
7
+ msg ||= "Unknown case"
8
8
  msg += ". Case name '#{case_name}'" if case_name
9
9
  msg += ". Case type '#{type}'" if type
10
10
  super(msg)
@@ -112,9 +112,9 @@ module Eco
112
112
  if type && target_case = to_h[key(name, type)]
113
113
  return target_case
114
114
  elsif type
115
- raise UseCases::UnkownCase.new(case_name: name, type: type)
115
+ raise UseCases::UnknownCase.new(case_name: name, type: type)
116
116
  end
117
- raise UseCases::UnkownCase.new(case_name: name, type: type) unless cases = by_name[name]
117
+ raise UseCases::UnknownCase.new(case_name: name, type: type) unless cases = by_name[name]
118
118
  raise UseCases::AmbiguousCaseReference.new(case_name: name) if cases.length > 1
119
119
  cases.first
120
120
  end
@@ -46,7 +46,7 @@ module Eco
46
46
  end
47
47
  end
48
48
 
49
- def any_unkown?(exclude: [])
49
+ def any_unknown?(exclude: [])
50
50
  unknown(exclude: exclude).length > 0
51
51
  end
52
52
 
data/lib/eco/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Eco
2
- VERSION = "2.4.7"
2
+ VERSION = "2.4.9"
3
3
  end
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.4.7
4
+ version: 2.4.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: 2.4.8
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '2.5'
22
+ version: '3'
23
23
  type: :development
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: 2.4.8
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '2.5'
32
+ version: '3'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: rspec
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -39,7 +39,7 @@ dependencies:
39
39
  version: 3.10.0
40
40
  - - "<"
41
41
  - !ruby/object:Gem::Version
42
- version: '3.11'
42
+ version: '4'
43
43
  type: :development
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -49,7 +49,7 @@ dependencies:
49
49
  version: 3.10.0
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
- version: '3.11'
52
+ version: '4'
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: rake
55
55
  requirement: !ruby/object:Gem::Requirement
@@ -59,7 +59,7 @@ dependencies:
59
59
  version: 13.0.3
60
60
  - - "<"
61
61
  - !ruby/object:Gem::Version
62
- version: '13.1'
62
+ version: '14'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
@@ -69,7 +69,7 @@ dependencies:
69
69
  version: 13.0.3
70
70
  - - "<"
71
71
  - !ruby/object:Gem::Version
72
- version: '13.1'
72
+ version: '14'
73
73
  - !ruby/object:Gem::Dependency
74
74
  name: yard
75
75
  requirement: !ruby/object:Gem::Requirement
@@ -79,7 +79,7 @@ dependencies:
79
79
  version: 0.9.26
80
80
  - - "<"
81
81
  - !ruby/object:Gem::Version
82
- version: '0.10'
82
+ version: '1'
83
83
  type: :development
84
84
  prerelease: false
85
85
  version_requirements: !ruby/object:Gem::Requirement
@@ -89,7 +89,7 @@ dependencies:
89
89
  version: 0.9.26
90
90
  - - "<"
91
91
  - !ruby/object:Gem::Version
92
- version: '0.10'
92
+ version: '1'
93
93
  - !ruby/object:Gem::Dependency
94
94
  name: redcarpet
95
95
  requirement: !ruby/object:Gem::Requirement
@@ -99,7 +99,7 @@ dependencies:
99
99
  version: 3.5.1
100
100
  - - "<"
101
101
  - !ruby/object:Gem::Version
102
- version: '3.6'
102
+ version: '4'
103
103
  type: :development
104
104
  prerelease: false
105
105
  version_requirements: !ruby/object:Gem::Requirement
@@ -109,14 +109,14 @@ dependencies:
109
109
  version: 3.5.1
110
110
  - - "<"
111
111
  - !ruby/object:Gem::Version
112
- version: '3.6'
112
+ version: '4'
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: ecoportal-api
115
115
  requirement: !ruby/object:Gem::Requirement
116
116
  requirements:
117
117
  - - ">="
118
118
  - !ruby/object:Gem::Version
119
- version: 0.9.3
119
+ version: 0.9.4
120
120
  - - "<"
121
121
  - !ruby/object:Gem::Version
122
122
  version: '0.10'
@@ -126,7 +126,7 @@ dependencies:
126
126
  requirements:
127
127
  - - ">="
128
128
  - !ruby/object:Gem::Version
129
- version: 0.9.3
129
+ version: 0.9.4
130
130
  - - "<"
131
131
  - !ruby/object:Gem::Version
132
132
  version: '0.10'
@@ -136,7 +136,7 @@ dependencies:
136
136
  requirements:
137
137
  - - ">="
138
138
  - !ruby/object:Gem::Version
139
- version: 1.1.1
139
+ version: 1.1.2
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.1
149
+ version: 1.1.2
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.5
159
+ version: 0.3.6
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.5
169
+ version: 0.3.6
170
170
  - - "<"
171
171
  - !ruby/object:Gem::Version
172
172
  version: '0.4'
@@ -219,7 +219,7 @@ dependencies:
219
219
  version: 2.7.6
220
220
  - - "<"
221
221
  - !ruby/object:Gem::Version
222
- version: '2.8'
222
+ version: '3'
223
223
  type: :runtime
224
224
  prerelease: false
225
225
  version_requirements: !ruby/object:Gem::Requirement
@@ -229,7 +229,7 @@ dependencies:
229
229
  version: 2.7.6
230
230
  - - "<"
231
231
  - !ruby/object:Gem::Version
232
- version: '2.8'
232
+ version: '3'
233
233
  - !ruby/object:Gem::Dependency
234
234
  name: net-sftp
235
235
  requirement: !ruby/object:Gem::Requirement
@@ -239,7 +239,7 @@ dependencies:
239
239
  version: 3.0.0
240
240
  - - "<"
241
241
  - !ruby/object:Gem::Version
242
- version: '3.1'
242
+ version: '4'
243
243
  type: :runtime
244
244
  prerelease: false
245
245
  version_requirements: !ruby/object:Gem::Requirement
@@ -249,7 +249,7 @@ dependencies:
249
249
  version: 3.0.0
250
250
  - - "<"
251
251
  - !ruby/object:Gem::Version
252
- version: '3.1'
252
+ version: '4'
253
253
  - !ruby/object:Gem::Dependency
254
254
  name: hashdiff
255
255
  requirement: !ruby/object:Gem::Requirement