eco-helpers 3.2.1 → 3.2.2

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 (27) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +21 -1
  3. data/eco-helpers.gemspec +2 -2
  4. data/lib/eco/api/common/people/person_entry.rb +5 -0
  5. data/lib/eco/api/microcases/people/manage/cache.rb +21 -16
  6. data/lib/eco/api/microcases/people/manage/filename.rb +29 -0
  7. data/lib/eco/api/microcases/people/manage/load.rb +6 -48
  8. data/lib/eco/api/microcases/people/manage/load_cache.rb +29 -0
  9. data/lib/eco/api/microcases/people/manage/refresh.rb +5 -3
  10. data/lib/eco/api/microcases/people/manage.rb +4 -0
  11. data/lib/eco/api/session/batch/searcher.rb +3 -3
  12. data/lib/eco/api/session/config/people.rb +23 -20
  13. data/lib/eco/api/usecases/samples/drivers/cli/sftp_cli.rb +1 -1
  14. data/lib/eco/api/usecases/samples/drivers/sftp_sample.rb +4 -1
  15. data/lib/eco/api/usecases/samples/drivers/url_pull_sample.rb +12 -9
  16. data/lib/eco/api/usecases/samples/people/filters/cli/require_id_cli.rb +5 -0
  17. data/lib/eco/api/usecases/samples/people/filters/cli/require_min_entries_cli.rb +5 -0
  18. data/lib/eco/api/usecases/samples/people/filters/require_id_sample.rb +61 -0
  19. data/lib/eco/api/usecases/samples/people/filters/require_min_entries_sample.rb +20 -0
  20. data/lib/eco/api/usecases/samples/people/filters.rb +7 -0
  21. data/lib/eco/api/usecases/samples/people.rb +12 -0
  22. data/lib/eco/api/usecases/samples.rb +1 -0
  23. data/lib/eco/cli_default/options.rb +5 -0
  24. data/lib/eco/data/locations/node_base/tag_validations.rb +2 -2
  25. data/lib/eco/data/locations/node_diff/nodes_diff/diffs_tree.rb +10 -3
  26. data/lib/eco/version.rb +1 -1
  27. metadata +18 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ea80ab87a718ddf4e177e212b1f4a5234c96554d67d4781579314d1e58ea821e
4
- data.tar.gz: 835aec5ee8d25e186f3327e97b5ca382a3556c85a8f34bed4e4e3f09b2d201c0
3
+ metadata.gz: 415f7627b23706adc59420467cd7491f5990c267109a11f9128fa8dac908631c
4
+ data.tar.gz: 8f04152b0e476c656c83fe752b091e83e042a322d0cdbb69e26bb8650c812f07
5
5
  SHA512:
6
- metadata.gz: 16cd391227194d4e929292ebe775f061f1ba58f592523ff28b32d2d7e92da638c94c0b36fdf2f55f2c38195517f6def5441e8ae15a6a3a516f02b5357540a69b
7
- data.tar.gz: 4bad0d9fa30a1be333b69aa485808961a3ae39259fb42d616457b8cd2b501b808daf60526cf0d4f17540f42036b084b82f40aeae36dd25894df46735b5f1f91e
6
+ metadata.gz: 9cb01334ae6ae73d528f5841c568ee3f13305cabf5051d5ef2bee3775d9dac5d6618a16436f62fa28ff9c06ba628ca1c04897e528ba3a367db8a8805affc4f44
7
+ data.tar.gz: 6e9fe1d5c9cbda796692302ad551702c446ee73a44bdd83cb3e04a59de0ef3474e878d071d6977cd68fc7f0d19256a334a2c014c62ec79b63c918ad5d6463c48
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.2] - 2025-05-xx
5
+ ## [3.3.1] - 2025-06-xx
6
6
 
7
7
  ### Added
8
8
 
@@ -10,6 +10,26 @@ All notable changes to this project will be documented in this file.
10
10
 
11
11
  ### Fixed
12
12
 
13
+ ## [3.2.2] - 2025-06-11
14
+
15
+ ### Added
16
+
17
+ - `PersonEntry#[]` accessor (onto `final_entry`)
18
+ - **Samples**:
19
+ - `require-id`
20
+ - `require-min-entries`
21
+
22
+ ### Changed
23
+
24
+ - upgraded gem dependencies
25
+ - `Session::Batch::Searcher` silence low level messages.
26
+ - And better feedback on search.
27
+ - **Refactored** `Microcases` people get/cache/load helpers to reach a **unique access point** per functionality.
28
+
29
+ ### Fixed
30
+
31
+ - The upgrade of the `ecoportal-api-graphql` **gem** fixes a bug introduced by a native release.
32
+
13
33
  ## [3.2.1] - 2025-05-17
14
34
 
15
35
  ### Changed
data/eco-helpers.gemspec CHANGED
@@ -42,8 +42,8 @@ Gem::Specification.new do |spec|
42
42
  spec.add_dependency 'docx', '>= 0.8.0', '< 0.9'
43
43
  spec.add_dependency 'dotenv', '~> 3'
44
44
  spec.add_dependency 'ecoportal-api', '~> 0.10', '>= 0.10.11'
45
- spec.add_dependency 'ecoportal-api-graphql', '~> 1.2', '>= 1.2.1'
46
- spec.add_dependency 'ecoportal-api-v2', '~> 3.2', '>= 3.2.1'
45
+ spec.add_dependency 'ecoportal-api-graphql', '~> 1.3', '>= 1.3.1'
46
+ spec.add_dependency 'ecoportal-api-v2', '~> 3.3', '>= 3.3.1'
47
47
  spec.add_dependency 'ed25519', '~> 1.2'
48
48
  spec.add_dependency 'fast_excel', '>= 0.5.0', '< 0.6'
49
49
  spec.add_dependency 'fuzzy_match', '>= 2.1.0', '< 2.2'
@@ -98,6 +98,11 @@ module Eco
98
98
  end
99
99
  end
100
100
 
101
+ # Value on the final entry
102
+ def [](key)
103
+ final_entry[key]
104
+ end
105
+
101
106
  # @note completely serialized entry.
102
107
  # @return [Hash] entry `Hash` with **external** attribute names, and values and types thereof.
103
108
  def external_entry # rubocop:disable Style/TrivialAccessors
@@ -4,29 +4,34 @@ module Eco
4
4
  module People
5
5
  module Manage
6
6
  module Cache
7
- # Helper to locally cache the people manager.
7
+ # Helper to locally cache the people manager (download via API).
8
8
  # @param filename [String] the name of the file where the data should be cached.
9
9
  # @return [Eco::API::Organization::People] the `People` object with the data.
10
- def people_cache(filename = enviro.config.people.cache)
11
- log(:info) { 'Going to get all the people via API' }
10
+ def people_cache(filename = enviro.config.people.cache, modifier: [:save])
11
+ modifier = [modifier].flatten
12
12
 
13
- start = Time.now
14
- people = session.batch.get_people
15
- secs = (Time.now - start).round(3)
16
- cnt = people.count
17
- per_sec = (cnt.to_f / secs).round(2)
13
+ log(:info) { 'Going to get all the people via API' }
18
14
 
19
- log(:info) {
20
- "Loaded #{cnt} people in #{secs} seconds (#{per_sec} people/sec)"
21
- }
15
+ start = Time.now
16
+ session.batch.get_people.tap do |people|
17
+ secs = (Time.now - start).round(3)
18
+ cnt = people.count
19
+ per_sec = (cnt.to_f / secs).round(2)
22
20
 
23
- file = file_manager.save_json(people, filename, :timestamp)
21
+ log(:info) {
22
+ "Loaded #{cnt} people in #{secs} seconds (#{per_sec} people/sec)"
23
+ }
24
24
 
25
- log(:info) {
26
- "#{people.length} people loaded and saved locally to #{file}."
27
- }
25
+ if modifier.include?(:save)
26
+ file = file_manager.save_json(people, filename, :timestamp)
28
27
 
29
- Eco::API::Organization::People.new(people)
28
+ log(:info) {
29
+ "#{people.length} people loaded and saved locally to #{file}."
30
+ }
31
+ end
32
+ end.then do |people|
33
+ Eco::API::Organization::People.new(people)
34
+ end
30
35
  end
31
36
  end
32
37
  end
@@ -0,0 +1,29 @@
1
+ module Eco
2
+ module API
3
+ class MicroCases
4
+ module People
5
+ module Manage
6
+ module Filename
7
+ private
8
+
9
+ # Spot the source data file.
10
+ def people_filename(filename = enviro.config.people.cache, newest: false)
11
+ if newest
12
+ # search input file based on pattern (in case the name has a timestamp)
13
+ file_manager.dir.newest_file(file: filename).tap do |file|
14
+ next unless file
15
+
16
+ log(:info) {
17
+ "previous file found: #{file}"
18
+ }
19
+ end
20
+ else
21
+ file_manager.dir.file(filename, should_exist: true)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -22,19 +22,10 @@ module Eco
22
22
  modifier = [modifier].flatten
23
23
  load_file = %i[file newest].any? {|flag| modifier.include?(flag)}
24
24
 
25
- case
26
- when filename && load_file
27
- file = people_load_filename(filename, newest: modifier.include?(:newest))
25
+ if filename && load_file
26
+ load_cache(filename, newest: modifier.include?(:newest)).tap do |people|
27
+ next if people.is_a?(Eco::API::Organization::People)
28
28
 
29
- if file
30
- file_manager.load_json(file).tap do |people|
31
- next unless people.is_a?(Array)
32
-
33
- log(:info) {
34
- "#{people&.length} people loaded from file #{file}"
35
- }
36
- end
37
- else
38
29
  log(:error) {
39
30
  "could not find the file #{file_manager.dir.file(filename)}"
40
31
  }
@@ -43,43 +34,10 @@ module Eco
43
34
 
44
35
  people_load(modifier: modifier - %i[newest file])
45
36
  end
46
- when modifier.include?(:api)
47
- log(:info) { 'Going to get all the people via API (load)' }
48
-
49
- start = Time.now
50
- session.batch.get_people.tap do |people|
51
- secs = (Time.now - start).round(3)
52
- cnt = people.count
53
- per_sec = (cnt.to_f / secs).round(2)
54
-
55
- log(:info) {
56
- "Loaded #{cnt} people in #{secs} seconds (#{per_sec} people/sec)"
57
- }
58
-
59
- if modifier.include?(:save) && people && people.length.positive?
60
- file = file_manager.save_json(people, filename, :timestamp)
61
- log(:info) { "#{people.length} people saved to file #{file}." }
62
- end
63
- end
37
+ elsif modifier.include?(:api)
38
+ people_cache(filename, modifier: modifier)
64
39
  end.then do |people|
65
- Eco::API::Organization::People.new(people)
66
- end
67
- end
68
-
69
- private
70
-
71
- def people_load_filename(filename, newest: false)
72
- if newest
73
- # search input file based on pattern (in case the name has a timestamp)
74
- file_manager.dir.newest_file(file: filename).tap do |file|
75
- next unless file
76
-
77
- log(:info) {
78
- "previous file found: #{file}"
79
- }
80
- end
81
- else
82
- file_manager.dir.file(filename, should_exist: true)
40
+ Eco::API::Organization::People.new(people.to_a)
83
41
  end
84
42
  end
85
43
  end
@@ -0,0 +1,29 @@
1
+ module Eco
2
+ module API
3
+ class MicroCases
4
+ module People
5
+ module Manage
6
+ module LoadCache
7
+ private
8
+
9
+ # Finds the source data file and loads it.
10
+ # @return [Eco::API::Organization::People] the `People` object with the data.
11
+ def load_cache(filename = enviro.config.people.cache, newest: false)
12
+ return unless (file = people_filename(filename, newest: newest))
13
+
14
+ file_manager.load_json(file).then do |people|
15
+ next unless people.is_a?(Array)
16
+
17
+ log(:info) {
18
+ "#{people&.length} people loaded from file #{file}"
19
+ }
20
+
21
+ Eco::API::Organization::People.new(people)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -5,16 +5,18 @@ module Eco
5
5
  module Manage
6
6
  module Refresh
7
7
  # Helper to obtain all the elements of `people` anew from the _People Manager_.
8
+ # @note it does NOT save to a local file.
8
9
  # @note
9
- # 1. This helper is normally used to run consecutive usecases, where data needs refresh.
10
+ # 1. This helper is normally used to run consecutive usecases,
11
+ # where data needs refresh.
10
12
  # 2. It only includes new people if they are not dirty (they do not have pending updates)
11
13
  # - This contingency wouldn't be necessary if the server worked perfectly.
12
14
  # @param people [Eco::API::Organization::People] the people that needs refresh.
13
15
  # @param include_created [Boolean] include people created during this session? (will check `:create` batch jobs).
14
16
  # @return [Eco::API::Organization::People] the `People` object with the data.
15
17
  def people_refresh(people:, include_created: true) # rubocop:disable Metrics/AbcSize
16
- people = people.newFrom people.select do |person|
17
- !person.new? || !person.dirty?
18
+ people = people.newFrom people.reject do |person|
19
+ person.new? && person.dirty?
18
20
  end
19
21
 
20
22
  ini = people.length
@@ -1,3 +1,5 @@
1
+ require_relative 'manage/filename'
2
+ require_relative 'manage/load_cache'
1
3
  require_relative 'manage/cache'
2
4
  require_relative 'manage/load'
3
5
  require_relative 'manage/search'
@@ -8,6 +10,8 @@ module Eco
8
10
  class MicroCases
9
11
  module People
10
12
  module Manage
13
+ include Filename
14
+ include LoadCache
11
15
  include Cache
12
16
  include Load
13
17
  include Search
@@ -56,7 +56,7 @@ module Eco
56
56
  entries.each_with_index do |entry, i|
57
57
  if (i % 10).zero?
58
58
  percent = i * 100 / entries.length
59
- print "Searching: #{percent.round}% (#{i}/#{entries.length} entries)\r"
59
+ print "Searching in results: #{percent.round}% (#{i}/#{entries.length} entries)\r"
60
60
  $stdout.flush
61
61
  end
62
62
 
@@ -75,7 +75,7 @@ module Eco
75
75
  unless email.empty?
76
76
  people_matching = get(
77
77
  params: params.merge(q: email),
78
- silent: silent,
78
+ silent: true,
79
79
  options: options
80
80
  ).select do |person|
81
81
  person.email == email
@@ -94,7 +94,7 @@ module Eco
94
94
 
95
95
  private
96
96
 
97
- def get(params: {}, silent: false, options: self.options)
97
+ def get(params: {}, silent: true, options: self.options)
98
98
  msg = 'cannot batch get without api connnection, '
99
99
  msg << 'please provide a valid api connection!'
100
100
  fatal msg unless (people_api = api&.people)
@@ -3,69 +3,72 @@ module Eco
3
3
  class Session
4
4
  class Config
5
5
  class People < BaseConfig
6
-
7
6
  def cache=(file)
8
- self["cache"] = file
7
+ self['cache'] = file
9
8
  end
10
9
 
11
10
  def cache
12
- self["cache"] ||= "cache/people.json"
11
+ self['cache'] ||= 'cache/people.json'
13
12
  end
14
13
 
15
14
  def partial_cache
16
- if file = self.cache
17
- File.join(File.dirname(file),
18
- File.basename(file, File.extname(file)) + "_partial" + File.extname(file)
19
- )
20
- end
15
+ return unless (file = self.cache)
16
+
17
+ extension = File.extname(file)
18
+ basename = File.basename(file, extension)
19
+
20
+ File.join(
21
+ File.dirname(file),
22
+ "#{basename}_partial#{extension}"
23
+ )
21
24
  end
22
25
 
23
26
  # specifies if people search should be strict or not
24
27
  def strict_search=(value)
25
- self["strict_search"] = !!value
28
+ self['strict_search'] = !!value
26
29
  end
27
30
 
28
31
  def strict_search?
29
- self["strict_search"]
32
+ self['strict_search']
30
33
  end
31
34
 
32
35
  # api queried logs
33
36
  def requests_folder=(folder)
34
- self["requests_folder"] = folder
37
+ self['requests_folder'] = folder
35
38
  end
36
39
 
37
40
  def requests_folder
38
- self["requests_folder"] ||= "requests"
41
+ self['requests_folder'] ||= 'requests'
39
42
  end
40
43
 
41
44
  # people to exclude from update feeds
42
45
  def discarded_file=(file)
43
- self["discarded_file"] = file
46
+ self['discarded_file'] = file
44
47
  end
45
48
 
46
49
  def discarded_file
47
- self["discarded_file"]
50
+ self['discarded_file']
48
51
  end
49
52
 
50
53
  # with given a person what is the criteria of exclusion
51
54
  def api_excluded(&block)
52
- return self["api_excluded"] unless block_given?
53
- self["api_excluded"] = block
55
+ return self['api_excluded'] unless block_given?
56
+
57
+ self['api_excluded'] = block
54
58
  end
55
59
 
56
60
  # internal-external fields map
57
61
  def fields_mapper=(file)
58
- self["fields_mapper"] = file
62
+ self['fields_mapper'] = file
59
63
  end
60
64
 
61
65
  def fields_mapper
62
- self["fields_mapper"]
66
+ self['fields_mapper']
63
67
  end
64
68
 
65
69
  # person model
66
70
  attr_key :default_usergroup, :default_schema, :default_login_method
67
71
 
68
-
69
72
  def default_usergroup?
70
73
  !!default_usergroup
71
74
  end
@@ -80,7 +83,7 @@ module Eco
80
83
 
81
84
  # @return [Hash] with defined pairs format `key` and Person parsers.
82
85
  def parsers
83
- self["parsers"] ||= {}
86
+ self['parsers'] ||= {}
84
87
  end
85
88
 
86
89
  # The person parser/serializer for a given format (default `csv`).
@@ -1,4 +1,4 @@
1
- class Eco::API::UseCases::Samples::Drivers::Sftp
1
+ class Eco::API::UseCases::Samples::Drivers::Sftp
2
2
  class Cli < Eco::API::UseCases::Cli
3
3
  desc 'SFTP case: manages remote files that match a file pattern'
4
4
 
@@ -28,7 +28,10 @@ class Eco::API::UseCases::Samples::Drivers::Sftp < Eco::API::Common::Loaders::Us
28
28
 
29
29
  def list_folder
30
30
  puts "Listing remote folder: '#{remote_folder}' (host: #{sftp.host}):"
31
- with_remote_files(pattern: file_pattern) {|file| puts file.longname}
31
+
32
+ with_remote_files(pattern: file_pattern) do |file|
33
+ puts file.longname
34
+ end
32
35
  end
33
36
 
34
37
  def get_files
@@ -38,6 +38,7 @@ class Eco::API::UseCases::Samples::Drivers::UrlPull < Eco::API::Common::Loaders:
38
38
  base_request(uri, **kargs) do |request|
39
39
  http_start(uri) do |http|
40
40
  puts "Pulling from url: #{uri}"
41
+
41
42
  return http.request(request)
42
43
  end
43
44
  end
@@ -73,6 +74,7 @@ class Eco::API::UseCases::Samples::Drivers::UrlPull < Eco::API::Common::Loaders:
73
74
  def base_request(uri, user: nil, pass: '')
74
75
  Net::HTTP::Get.new(uri).tap do |request|
75
76
  request.basic_auth(user, pass) unless user.nil?
77
+
76
78
  yield(request)
77
79
  end
78
80
  end
@@ -91,6 +93,7 @@ class Eco::API::UseCases::Samples::Drivers::UrlPull < Eco::API::Common::Loaders:
91
93
 
92
94
  def target_url(required: true)
93
95
  fpc = target_url_const
96
+
94
97
  return fpc if fpc
95
98
  return unless required
96
99
 
@@ -99,15 +102,15 @@ class Eco::API::UseCases::Samples::Drivers::UrlPull < Eco::API::Common::Loaders:
99
102
  end
100
103
 
101
104
  def target_url_const
102
- if (fpc = options.dig(:url_pull, :target_url_const))
103
- msg = "(#{self.class}) Invalid file pattern const referral: #{fpc}"
104
- raise WrongConst, msg unless fpc.match(CONST_REFERRAL)
105
-
106
- begin
107
- self.eval(fpc)
108
- rescue NameError
109
- self.class.const_get(fpc)
110
- end
105
+ return unless (fpc = options.dig(:url_pull, :target_url_const))
106
+
107
+ msg = "(#{self.class}) Invalid file pattern const referral: #{fpc}"
108
+ raise WrongConst, msg unless fpc.match(CONST_REFERRAL)
109
+
110
+ begin
111
+ self.eval(fpc)
112
+ rescue NameError
113
+ self.class.const_get(fpc)
111
114
  end
112
115
  rescue NameError
113
116
  raise WrongConst, "(#{self.class}) Unknown constant: #{fpc}"
@@ -0,0 +1,5 @@
1
+ class Eco::API::UseCases::Samples::People::Filters::RequireId
2
+ class Cli < Eco::API::UseCases::Cli
3
+ desc 'Import case to discard entries that do NOT have a unique identifier (external_id)'
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class Eco::API::UseCases::Samples::People::Filters::RequireMinEntries
2
+ class Cli < Eco::API::UseCases::Cli
3
+ desc 'Import case to halt if MIN_COUNT is NOT met'
4
+ end
5
+ end
@@ -0,0 +1,61 @@
1
+ class Eco::API::UseCases::Samples::People::Filters::RequireId < Eco::API::Custom::UseCase
2
+ require_relative 'cli/require_id_cli'
3
+
4
+ name 'require-id'
5
+ type :import
6
+
7
+ GENERATE_FILE = true
8
+ OUT_FOLDER = 'sftp'.freeze
9
+ OUT_TIME_FORMAT = '%Y%m%dT%H%M%S'.freeze
10
+ OUT_FILENAME = 'no_id'.freeze
11
+
12
+ def main(*_args)
13
+ output = input
14
+
15
+ # Filter out the ones that we could not build ids for
16
+ no_id = input.newFrom(input.reject {|e| id?(e)})
17
+
18
+ unless no_id.empty?
19
+ log(:warn) {
20
+ "Excluding #{no_id.length} entries with no external_id."
21
+ }
22
+
23
+ no_id.export(output_filename) if generate_file?
24
+
25
+ output = input.newFrom(input.select {|e| id?(e)})
26
+ end
27
+
28
+ output.tap do
29
+ next unless output.empty?
30
+
31
+ msg = 'Empty entries after excluding entries with no external_id. '
32
+ msg << 'Aborting...'
33
+ abort msg
34
+ end
35
+ end
36
+
37
+ private
38
+
39
+ def id?(entry)
40
+ return true unless entry.id.to_s.strip.empty?
41
+ return true unless entry.external_id.to_s.strip.empty?
42
+
43
+ false
44
+ end
45
+
46
+ def generate_file?
47
+ self.class::GENERATE_FILE
48
+ end
49
+
50
+ def output_filename(name = self.class::OUT_FILENAME)
51
+ File.join(output_folder, "#{timestamp}_#{config.active_enviro}_#{name}.csv")
52
+ end
53
+
54
+ def output_folder
55
+ File.join(config.active_enviro, self.class::OUT_FOLDER)
56
+ end
57
+
58
+ def timestamp(date = Time.now)
59
+ date.strftime(self.class::OUT_TIME_FORMAT)
60
+ end
61
+ end
@@ -0,0 +1,20 @@
1
+ class Eco::API::UseCases::Samples::People::Filters::RequireMinEntries < Eco::API::Custom::UseCase
2
+ require_relative 'cli/require_min_entries_cli'
3
+
4
+ name 'require-min-entries'
5
+ type :import
6
+
7
+ MIN_COUNT = 200
8
+
9
+ def main(*_args)
10
+ return input if options.dig(:workflow, :ad_hoc)
11
+
12
+ input.tap do |entries|
13
+ next if entries.count >= self.class::MIN_COUNT
14
+
15
+ msg = "There are only #{entries.count} valid entries in the file "
16
+ msg << "(min required: #{self.class::MIN_COUNT}). Aborting..."
17
+ abort(msg)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,7 @@
1
+ module Eco::API::UseCases::Samples::People
2
+ module Filters
3
+ end
4
+ end
5
+
6
+ require_relative 'filters/require_id_sample'
7
+ require_relative 'filters/require_min_entries_sample'
@@ -0,0 +1,12 @@
1
+ module Eco
2
+ module API
3
+ class UseCases
4
+ class Samples
5
+ module People
6
+ end
7
+ end
8
+ end
9
+ end
10
+ end
11
+
12
+ require_relative 'people/filters'
@@ -8,3 +8,4 @@ module Eco
8
8
  end
9
9
 
10
10
  require_relative 'samples/drivers'
11
+ require_relative 'samples/people'
@@ -145,6 +145,11 @@ ASSETS.cli.config do |cnf| # rubocop:disable Metrics/BlockLength
145
145
  end
146
146
  end
147
147
 
148
+ desc = 'It allows to skip the filtering of entries during the workflow.'
149
+ options_set.add('-skip-pre-filter', desc) do |options, session|
150
+ options.deep_merge!(workflow: {ad_hoc: true})
151
+ end
152
+
148
153
  # PEOPLE FETCH
149
154
 
150
155
  desc = 'Do not load any people for this run.'
@@ -2,14 +2,14 @@ module Eco::Data::Locations::NodeBase
2
2
  module TagValidations
3
3
  include Eco::Language::AuxiliarLogger
4
4
 
5
- ALLOWED_CHARACTERS = "A-Za-z0-9 &_'\/.-"
5
+ ALLOWED_CHARACTERS = "A-Za-z0-9 &_'\/.-".freeze
6
6
  VALID_TAG_REGEX = /^[#{ALLOWED_CHARACTERS}]+$/
7
7
  INVALID_TAG_REGEX = /[^#{ALLOWED_CHARACTERS}]+/
8
8
  VALID_TAG_CHARS = /[#{ALLOWED_CHARACTERS}]+/
9
9
  DOUBLE_BLANKS = /\s\s+/
10
10
 
11
11
  def clean_id(str, notify: true, ref: '')
12
- blanks_x2 = has_double_blanks?(str)
12
+ blanks_x2 = has_double_blanks?(str) # dubocop:disable Naming/VariableNumber
13
13
  partial = replace_not_allowed(str)
14
14
  remove_double_blanks(partial).tap do |result|
15
15
  next unless notify
@@ -3,6 +3,7 @@ class Eco::Data::Locations::NodeDiff::NodesDiff
3
3
  class DiffsTree
4
4
  class CyclicHierarchy < StandardError
5
5
  end
6
+
6
7
  class CyclicAncestorsChain < CyclicHierarchy
7
8
  end
8
9
 
@@ -37,12 +38,15 @@ class Eco::Data::Locations::NodeDiff::NodesDiff
37
38
  # supports building partial trees (clusters), where some parents
38
39
  # may not have presence.
39
40
  def parent_id
40
- return nil unless parent
41
+ return unless parent
42
+
41
43
  parent.id
42
44
  end
43
45
 
44
46
  def add_child(child_tree)
45
- raise ArgumentError, "Expecting #{self.class}. Given: #{child_tree.class}" unless child_tree.is_a?(self.class)
47
+ msg = "Expecting #{self.class}. Given: #{child_tree.class}"
48
+ raise ArgumentError, msg unless child_tree.is_a?(self.class)
49
+
46
50
  prevent_cyclic_chain(child_tree)
47
51
  children.push(child_tree)
48
52
  child_tree.link_parent(self)
@@ -69,8 +73,11 @@ class Eco::Data::Locations::NodeDiff::NodesDiff
69
73
  protected
70
74
 
71
75
  def link_parent(parent_node)
72
- raise ArgumentError, "Expecting #{self.class}. Given: #{parent_node.class}" unless parent_node.is_a?(self.class)
76
+ msg = "Expecting #{self.class}. Given: #{parent_node.class}"
77
+ raise ArgumentError, msg unless parent_node.is_a?(self.class)
78
+
73
79
  return (@parent = parent_node) unless parent
80
+
74
81
  msg = "Node '#{id}' already has a parent (#{parent.id}). "
75
82
  msg << "Can't make it child of '#{parent_node.id}' as well."
76
83
  raise CyclicHierarchy, msg
data/lib/eco/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Eco
2
- VERSION = '3.2.1'.freeze
2
+ VERSION = '3.2.2'.freeze
3
3
  end
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.1
4
+ version: 3.2.2
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-05-16 00:00:00.000000000 Z
11
+ date: 2025-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug
@@ -260,40 +260,40 @@ dependencies:
260
260
  requirements:
261
261
  - - "~>"
262
262
  - !ruby/object:Gem::Version
263
- version: '1.2'
263
+ version: '1.3'
264
264
  - - ">="
265
265
  - !ruby/object:Gem::Version
266
- version: 1.2.1
266
+ version: 1.3.1
267
267
  type: :runtime
268
268
  prerelease: false
269
269
  version_requirements: !ruby/object:Gem::Requirement
270
270
  requirements:
271
271
  - - "~>"
272
272
  - !ruby/object:Gem::Version
273
- version: '1.2'
273
+ version: '1.3'
274
274
  - - ">="
275
275
  - !ruby/object:Gem::Version
276
- version: 1.2.1
276
+ version: 1.3.1
277
277
  - !ruby/object:Gem::Dependency
278
278
  name: ecoportal-api-v2
279
279
  requirement: !ruby/object:Gem::Requirement
280
280
  requirements:
281
281
  - - "~>"
282
282
  - !ruby/object:Gem::Version
283
- version: '3.2'
283
+ version: '3.3'
284
284
  - - ">="
285
285
  - !ruby/object:Gem::Version
286
- version: 3.2.1
286
+ version: 3.3.1
287
287
  type: :runtime
288
288
  prerelease: false
289
289
  version_requirements: !ruby/object:Gem::Requirement
290
290
  requirements:
291
291
  - - "~>"
292
292
  - !ruby/object:Gem::Version
293
- version: '3.2'
293
+ version: '3.3'
294
294
  - - ">="
295
295
  - !ruby/object:Gem::Version
296
- version: 3.2.1
296
+ version: 3.3.1
297
297
  - !ruby/object:Gem::Dependency
298
298
  name: ed25519
299
299
  requirement: !ruby/object:Gem::Requirement
@@ -667,7 +667,9 @@ files:
667
667
  - lib/eco/api/microcases/people/macro/take_email.rb
668
668
  - lib/eco/api/microcases/people/manage.rb
669
669
  - lib/eco/api/microcases/people/manage/cache.rb
670
+ - lib/eco/api/microcases/people/manage/filename.rb
670
671
  - lib/eco/api/microcases/people/manage/load.rb
672
+ - lib/eco/api/microcases/people/manage/load_cache.rb
671
673
  - lib/eco/api/microcases/people/manage/refresh.rb
672
674
  - lib/eco/api/microcases/people/manage/search.rb
673
675
  - lib/eco/api/microcases/people/preserve.rb
@@ -919,6 +921,12 @@ files:
919
921
  - lib/eco/api/usecases/samples/drivers/cli/url_pull_cli.rb
920
922
  - lib/eco/api/usecases/samples/drivers/sftp_sample.rb
921
923
  - lib/eco/api/usecases/samples/drivers/url_pull_sample.rb
924
+ - lib/eco/api/usecases/samples/people.rb
925
+ - lib/eco/api/usecases/samples/people/filters.rb
926
+ - lib/eco/api/usecases/samples/people/filters/cli/require_id_cli.rb
927
+ - lib/eco/api/usecases/samples/people/filters/cli/require_min_entries_cli.rb
928
+ - lib/eco/api/usecases/samples/people/filters/require_id_sample.rb
929
+ - lib/eco/api/usecases/samples/people/filters/require_min_entries_sample.rb
922
930
  - lib/eco/api/usecases/service.rb
923
931
  - lib/eco/api/usecases/service/sftp.rb
924
932
  - lib/eco/api/usecases/service/sftp/with_target_config.rb