eco-helpers 3.2.7 → 3.2.9
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -1
- data/lib/eco/api/organization/tag_tree.rb +5 -1
- data/lib/eco/api/session/config.rb +36 -5
- data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing.rb +6 -0
- data/lib/eco/data/mapper.rb +5 -1
- data/lib/eco/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ffa9adf82dfa0cb6d91960757491fc7d39f163b9a98a2ec16e04a9247db32078
|
4
|
+
data.tar.gz: 122a747df40c99ae3fdb9b7bc2788f64b0fbc605acee56a26c5bf2c4d9e763e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2ec933ca14583f749295a0efb312dbb1c883308493bd97c3d8d34a19cbd542d113b7f31b1941a9056aef62c566060c840a57dea381fc320d8e4441a40a04326
|
7
|
+
data.tar.gz: 777252e0b15115ae33b904bb425c204f6db77b4c3c5f47274ad9ce39a16bb76e24f06f57c8a6777243706a1af2d104289cca0987ceeb4753a0c2bfb51ce19a3e
|
data/CHANGELOG.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
|
5
|
-
## [3.2.
|
5
|
+
## [3.2.10] - 2025-10-xx
|
6
6
|
|
7
7
|
### Added
|
8
8
|
|
@@ -10,6 +10,23 @@ All notable changes to this project will be documented in this file.
|
|
10
10
|
|
11
11
|
### Fixed
|
12
12
|
|
13
|
+
## [3.2.9] - 2025-10-16
|
14
|
+
|
15
|
+
### Added
|
16
|
+
|
17
|
+
- `Organization::TagTree`: **aliased** from `tag` to `id` related methods.
|
18
|
+
- `Session::Config#locations_mapper`, named **argument** `valid_internal_values`. To optionally validate the current mappings.
|
19
|
+
|
20
|
+
### Changed
|
21
|
+
|
22
|
+
- `Session::Config#locations_mapper` **changed** `insensitive` from **default** `false` to `true`.
|
23
|
+
|
24
|
+
## [3.2.8] - 2025-10-14
|
25
|
+
|
26
|
+
### Added
|
27
|
+
|
28
|
+
- Compatibility with native RS CSV feature **headers**: support `classification_ids`.
|
29
|
+
|
13
30
|
## [3.2.7] - 2025-09-09
|
14
31
|
|
15
32
|
### Added
|
@@ -289,12 +289,14 @@ module Eco
|
|
289
289
|
end.keys
|
290
290
|
end
|
291
291
|
end
|
292
|
+
alias_method :ids, :tags
|
292
293
|
|
293
294
|
# Gets all but the upper level tags of the current node tree.
|
294
295
|
# @return [Array<String>]
|
295
296
|
def subtags
|
296
297
|
tags - tags(depth: depth)
|
297
298
|
end
|
299
|
+
alias_method :subids, :subtags
|
298
300
|
|
299
301
|
# Verifies if a tag exists in the subtree(s).
|
300
302
|
# @param key [String] tag to verify.
|
@@ -302,6 +304,7 @@ module Eco
|
|
302
304
|
def subtag?(key)
|
303
305
|
subtags.include?(key&.upcase)
|
304
306
|
end
|
307
|
+
alias_method :subid?, :subtag?
|
305
308
|
|
306
309
|
# Returns all the tags with no children
|
307
310
|
# @return [Array<String>]
|
@@ -327,6 +330,7 @@ module Eco
|
|
327
330
|
def tag?(key)
|
328
331
|
@hash_tags.key?(key&.upcase)
|
329
332
|
end
|
333
|
+
alias_method :id?, :tag?
|
330
334
|
|
331
335
|
# Finds a subtree node.
|
332
336
|
# @param key [String] parent node of subtree.
|
@@ -499,7 +503,7 @@ module Eco
|
|
499
503
|
end.compact
|
500
504
|
end
|
501
505
|
|
502
|
-
def as_boolean(value)
|
506
|
+
def as_boolean(value) # rubocop:disable Naming/PredicateMethod
|
503
507
|
return false if value.nil? || value == false
|
504
508
|
return true if value == true
|
505
509
|
return false if value.to_s.strip.empty?
|
@@ -54,6 +54,8 @@ module Eco
|
|
54
54
|
|
55
55
|
# @!group Logger
|
56
56
|
|
57
|
+
# @note this is the configuration of the logger.
|
58
|
+
# Not the logger itself.
|
57
59
|
# @return [Eco::API::Session::Config::Logger]
|
58
60
|
def logger
|
59
61
|
self['logger'] ||= Eco::API::Session::Config::Logger.new(config: self)
|
@@ -82,6 +84,7 @@ module Eco
|
|
82
84
|
|
83
85
|
# @!group Session and API
|
84
86
|
|
87
|
+
# @note this is where `session` is created.
|
85
88
|
# @return [Eco::API::Session] the `session` linked to this `config`
|
86
89
|
def session
|
87
90
|
@session ||= Eco::API::Session.new(self)
|
@@ -252,17 +255,22 @@ module Eco
|
|
252
255
|
alias_method :locations_map_file, :location_codes
|
253
256
|
|
254
257
|
# @param internal [Symbol] either `:first` (default) or `:last`
|
255
|
-
# @param insensitive [Boolean] default `
|
256
|
-
# case sensitive.
|
258
|
+
# @param insensitive [Boolean] default `true`. Whether lookups are
|
259
|
+
# case insensitive (`true`) or case sensitive (`false`).
|
260
|
+
# @param valid_internal_values [Array<String>] when provided,
|
261
|
+
# it will check and warn on internal values that aren't expected.
|
257
262
|
# @param maps_file [String] the location maps file (default: `locations_map_file`).
|
258
263
|
# - Via `file_manager` it will try to spot the most recently changed.
|
259
264
|
# - The lookup to spot the **path** of the file, tries first as a **relative**
|
260
265
|
# path from `env/config/...`. If it fails, it tries it as an absolute path.
|
261
266
|
# @return [Eco::Data::Mapper, NilClass]
|
262
|
-
def locations_mapper(
|
267
|
+
def locations_mapper(
|
268
|
+
valid_internal_values: :no_validation,
|
269
|
+
**kargs
|
270
|
+
)
|
263
271
|
kargs = {
|
264
272
|
internal: :first,
|
265
|
-
insensitive:
|
273
|
+
insensitive: true,
|
266
274
|
maps_file: nil
|
267
275
|
}.merge(kargs)
|
268
276
|
|
@@ -279,7 +287,30 @@ module Eco
|
|
279
287
|
file_manager.load_json(kargs[:maps_file]),
|
280
288
|
internal: kargs[:internal],
|
281
289
|
insensitive: kargs[:insensitive]
|
282
|
-
)
|
290
|
+
).tap do |mapper|
|
291
|
+
next unless valid_internal_values.is_a?(Array)
|
292
|
+
|
293
|
+
valid_internal_values = valid_internal_values.compact
|
294
|
+
valid_internal_values = valid_internal_values.map(&:upcase) if kargs[:insensitive]
|
295
|
+
|
296
|
+
unexpected = mapper.list(:internal).each_with_object([]) do |value, out|
|
297
|
+
out << value unless valid_internal_values.include?(value.upcase)
|
298
|
+
end
|
299
|
+
|
300
|
+
next unless unexpected.any?
|
301
|
+
|
302
|
+
unexpected = unexpected.uniq.sort.map do |internal|
|
303
|
+
"#{internal} (mapped from '#{mapper.to_external(internal)}')"
|
304
|
+
end
|
305
|
+
|
306
|
+
session.log(:warn) {
|
307
|
+
msg = "The location mappings file has mappings to "
|
308
|
+
msg << "non active or unknown location node IDs:"
|
309
|
+
msg << "\n * "
|
310
|
+
msg << unexpected.join("\n * ")
|
311
|
+
msg
|
312
|
+
}
|
313
|
+
end
|
283
314
|
end
|
284
315
|
|
285
316
|
def tagtree=(file)
|
@@ -22,6 +22,12 @@ module Eco::API::UseCases::GraphQL::Samples::Location::Service
|
|
22
22
|
msg << "Given: #{csv.class}"
|
23
23
|
raise ArgumentError, msg unless csv.is_a?(Eco::CSV::Table)
|
24
24
|
|
25
|
+
csv = csv.transform_headers do |name|
|
26
|
+
name = name.to_s.strip.downcase
|
27
|
+
name = 'classifications' if name == 'classification_ids'
|
28
|
+
name
|
29
|
+
end
|
30
|
+
|
25
31
|
csv.each do |row|
|
26
32
|
row_transform&.call(row)
|
27
33
|
transform_classifications(row)
|
data/lib/eco/data/mapper.rb
CHANGED
@@ -2,7 +2,11 @@ module Eco
|
|
2
2
|
module Data
|
3
3
|
class Mapper
|
4
4
|
# it expects [[v1a, v1b], [v2a, v2b] ...]
|
5
|
-
def initialize(
|
5
|
+
def initialize(
|
6
|
+
array_of_arrays = [],
|
7
|
+
internal: :last,
|
8
|
+
insensitive: false
|
9
|
+
)
|
6
10
|
@internal_order = internal
|
7
11
|
@source = array_of_arrays
|
8
12
|
@insensitive = insensitive
|
data/lib/eco/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eco-helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oscar Segura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|