eco-helpers 2.7.9 → 2.7.11

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 41e63439f7a3d89c5e3c9e10be328b9487ecffe4dde6a83a6fd6f9a561d924a8
4
- data.tar.gz: bafc6c443ce57b2611c177b00eca9aca0fd06718712511eb2b93762ff957179b
3
+ metadata.gz: e3c92964baf09be5673e74f4a1762d03ce0efe159e7d6a2bc6da3839ac99f4f0
4
+ data.tar.gz: 26525ccfbdbb06f348d293a50a02de644f7a0a32f3f5285537c75d8d14fe3601
5
5
  SHA512:
6
- metadata.gz: '0094ce51df0b47838a44b679fe82a4acacfc64953edeea38ef2c51b6efeb08f0629f019751b319542dddcac5e77838786cdd1b7333b16babb0bf02ad4e197fb3'
7
- data.tar.gz: ee5243547b98cdeabba4cf1fdbbd8759b0f24d1e5ea4f4e42b998569ebe0c00bf3d5139ef2c28886bfa96efe6cd7e65344245b4eb6d7c9bb0a08964d075ddd12
6
+ metadata.gz: 7620a74731fbfc7d17d1b21f7930df4753003a919fa9d79550083002f454c57716cceab6afec8738d9a37e5b2cd749cd42541f0913286d66c1387b7b88b27c5e
7
+ data.tar.gz: 1db57df2c9a4b8e5863580524d34e655c92d5e4ddd15e6a8cacbe8b9e9e8af73ae2d3fb05fd1f4dc6de119c2ee5e20b3971b234c073910153aec5137807ef37b
data/CHANGELOG.md CHANGED
@@ -1,11 +1,26 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
- ## [2.7.10] - 2024-05-xx
4
+
5
+ ## [2.7.11] - 2024-05-xx
5
6
 
6
7
  ### Added
8
+ ### Changed\
9
+ - `Eco::API::Common::Session::SFTP#download`
10
+ - It now returns the local filename(s) of the downloaded files.
11
+ - `Eco::API::UseCases::GraphQL::Utils#sftp_download_files`
12
+ - It now returns the local filename(s) of the downloaded files.
13
+
14
+ ### Fixed
15
+
16
+ ## [2.7.10] - 2024-05-20
17
+
7
18
  ### Changed
19
+ - Temporarily silent warnings on tracking id changes (apparently the tracking locations tree is not up to date with latest version and gives false warnings)
20
+ - Upgrade SFTP access
21
+
8
22
  ### Fixed
23
+ - Remove enviro from tagtree download
9
24
 
10
25
  ## [2.7.9] - 2024-05-16
11
26
 
data/eco-helpers.gemspec CHANGED
@@ -33,6 +33,8 @@ Gem::Specification.new do |spec|
33
33
  spec.add_dependency 'ecoportal-api', '>= 0.9.8', '< 0.10'
34
34
  spec.add_dependency 'ecoportal-api-v2', '>= 1.1.8', '< 1.2'
35
35
  spec.add_dependency 'ecoportal-api-graphql', '>= 0.3.18', '< 0.4'
36
+ spec.add_dependency 'ed25519', '>= 1.2'
37
+ spec.add_dependency 'bcrypt_pbkdf', '>= 1.0'
36
38
  spec.add_dependency 'aws-sdk-s3', '>= 1.142.0', '< 2'
37
39
  spec.add_dependency 'aws-sdk-ses', '>= 1.58.0', '< 2'
38
40
  spec.add_dependency 'dotenv', '>= 2.8.1', '< 3'
@@ -74,15 +74,19 @@ module Eco
74
74
  # @see Net::SFTP::Operations::Download
75
75
  # @param files [String, Array<String>] full path to remote file(s) to be downloaded
76
76
  # @param local_folder [String] local destination folder (`"."` if not specified)
77
- def download(files, local_folder: nil)
77
+ # @return [Array<String>] list of created files
78
+ def download(files, local_folder: nil, &block)
78
79
  puts "Creating local files:"
80
+ created_files = []
79
81
  [files].flatten.compact.map do |fullname|
80
82
  basename = windows_basename(fullname)
81
83
  dest_fullname = File.join(local_folder || ".", basename)
82
84
  puts " • #{dest_fullname}"
85
+ created_files << dest_fullname
83
86
  sftp_session.download(fullname, dest_fullname)
84
87
  end.each(&:wait)
85
88
  # run SSH event loop while dw.active?
89
+ created_files.tap { created_files.each(&block) }
86
90
  end
87
91
 
88
92
  # Upload a file to the specific `remote_folder`
@@ -40,11 +40,13 @@ module Eco
40
40
  # @param tagtree [String] representation of the tagtree in json.
41
41
  def initialize(
42
42
  tagtree = [],
43
- name: nil, id: nil,
44
- depth: -1, path: [],
45
- parent: nil, _weight: nil # rubocop:disable Lint/UnderscorePrefixedVariableName
43
+ name: nil,
44
+ id: nil,
45
+ depth: -1,
46
+ path: [],
47
+ parent: nil,
48
+ _weight: nil # rubocop:disable Lint/UnderscorePrefixedVariableName
46
49
  )
47
-
48
50
  @source = parse_source_input(tagtree)
49
51
 
50
52
  msg = "You are trying to initialize a TagTree with a null tagtree"
@@ -21,12 +21,16 @@ module Eco
21
21
  # 1. If there's a file tagtree.json file, it uses it
22
22
  # 2. If no file, retrieves `structure_id` (config)
23
23
  # @param include_archived [Boolean] whether or not it should include archived nodes.
24
+ # @param [recache] used for re-caching
24
25
  # @return [Eco::API::Organization::TagTree]
25
- def scope_tree(enviro: nil, include_archived: true, raise_on_missing: true) # rubocop:disable Lint/UnusedMethodArgument
26
- return @tagtree if instance_variable_defined?(:@tagtree) && @tagtree.enviro == enviro
26
+ def scope_tree(
27
+ include_archived: true,
28
+ recache: false,
29
+ raise_on_missing: true # rubocop:disable Lint/UnusedMethodArgument
30
+ )
31
+ return @tagtree if instance_variable_defined?(:@tagtree) && !recache
27
32
 
28
33
  kargs = {
29
- enviro: enviro,
30
34
  includeArchivedNodes: include_archived
31
35
  }
32
36
 
@@ -48,16 +52,16 @@ module Eco
48
52
 
49
53
  # Among all the locations structures it selects the one with more location nodes
50
54
  # If `id` is provided, it only retrieves this locations structure.
51
- # @param [enviro] used for re-caching
52
- def live_tree(id: nil, enviro: nil, include_archived: false, **kargs, &block) # rubocop:disable Metrics/AbcSize
55
+ # @param [recache] used for re-caching
56
+ def live_tree( # rubocop:disable Metrics/AbcSize
57
+ id: nil,
58
+ include_archived: false,
59
+ **kargs,
60
+ &block
61
+ )
53
62
  existing_cache = !@live_tree.nil?
54
63
  first_load = !existing_cache
55
-
56
- target_change = existing_cache && id && @live_tree.id != id
57
- enviro_change = existing_cache && enviro && @live_tree.enviro != enviro
58
-
59
- switching_target = existing_cache && (target_change || enviro_change)
60
- _refresh_cache = existing_cache && !switching_target
64
+ switching_target = existing_cache && id && @live_tree.id != id
61
65
 
62
66
  kargs = {
63
67
  includeArchivedNodes: include_archived
@@ -248,10 +248,17 @@ module Eco
248
248
  # @note it does NOT include archived nodes by default.
249
249
  # - This is for legacy (most usecases don't)
250
250
  # @param include_archived [Boolean] whether or not it should include archived nodes.
251
+ # @param [recache] used for re-caching
251
252
  # @return [Eco::API::Organization::TagTree]
252
- def tagtree(enviro: nil, include_archived: false, raise_on_missing: true)
253
+ def tagtree(
254
+ include_archived: false,
255
+ recache: false,
256
+ raise_on_missing: true
257
+ )
253
258
  kargs = {
254
- enviro: enviro, include_archived: include_archived, raise_on_missing: raise_on_missing
259
+ recache: recache,
260
+ include_archived: include_archived,
261
+ raise_on_missing: raise_on_missing
255
262
  }
256
263
  @tagtree ||= tagtree_config.scope_tree(**kargs)
257
264
  end
@@ -259,8 +266,8 @@ module Eco
259
266
  # It obtains the first of the live tagtree in the org
260
267
  # @note it requires graphql connection configuration parameters
261
268
  # @return [Eco::API::Organization::TagTree]
262
- def live_tree(id: nil, enviro: nil, **kargs, &block)
263
- tagtree_config.live_tree(id: id, enviro: enviro, **kargs, &block)
269
+ def live_tree(id: nil, **kargs, &block)
270
+ tagtree_config.live_tree(id: id, **kargs, &block)
264
271
  end
265
272
 
266
273
  # Retrieves all the location structures of the organisation
@@ -58,19 +58,26 @@ module Eco
58
58
  # @see Eco::API::Session::Config#tagtree
59
59
  # @see Eco::API::Session#live_trees
60
60
  # @return [Eco::API::Organization::TagTree]
61
- def tagtree(live: false, merge: false, include_archived: false, **kargs, &block)
61
+ def tagtree(
62
+ live: false,
63
+ merge: false,
64
+ include_archived: false,
65
+ recache: false,
66
+ **kargs,
67
+ &block
68
+ )
62
69
  if live && api?(version: :graphql)
63
70
  return live_tree(include_archived: include_archived, **kargs, &block) unless merge
64
71
  live_trees(include_archived: include_archived, **kargs, &block).inject(&:merge)
65
72
  else
66
- config.tagtree(enviro: enviro)
73
+ config.tagtree(recache: recache)
67
74
  end
68
75
  end
69
76
 
70
77
  # @see Eco::API::Session::Config#live_tree
71
78
  # @return [Eco::API::Organization::TagTree]
72
79
  def live_tree(id: nil, include_archived: false, **kargs, &block)
73
- config.live_tree(id: id, include_archived: include_archived, enviro: enviro, **kargs, &block)
80
+ config.live_tree(id: id, include_archived: include_archived, **kargs, &block)
74
81
  end
75
82
 
76
83
  # @see Eco::API::Session::Config#live_tree
@@ -57,12 +57,12 @@ class Eco::API::UseCases::GraphQL::Samples::Location
57
57
 
58
58
  tags_remap_table << [[prev_id], [new_id]]
59
59
 
60
- next unless ref_tree.is_a?(Eco::API::Organization::TagTree)
61
- next unless ref_tree.tag?(new_id)
60
+ # next unless ref_tree.is_a?(Eco::API::Organization::TagTree)
61
+ # next unless ref_tree.tag?(new_id)
62
62
 
63
- msg = "Node '#{prev_id}' was updated to '#{new_id}', "
64
- msg << "but in current structure '#{new_id}' is not present"
65
- log(:warn) { msg }
63
+ # msg = "Node '#{prev_id}' was updated to '#{new_id}', "
64
+ # msg << "but in current structure '#{new_id}' is not present"
65
+ # log(:warn) { msg }
66
66
  end
67
67
  end
68
68
 
@@ -19,20 +19,20 @@ module Eco::API::UseCases::GraphQL::Utils
19
19
  end
20
20
  end
21
21
 
22
- def sftp_download_files(subfolder: remote_subfolder, pattern: nil, local_folder: self.local_folder)
23
- with_remote_files(subfolder: subfolder, pattern: pattern).tap do |files|
24
- next if files.empty?
25
- file_names = files.map {|file| to_remote_path(file.name, subfolder: subfolder)}
26
-
27
- log(:info) {
28
- msg = "Getting the following files into the local folder '#{local_folder}':\n"
29
- msg << " "
30
- msg << file_names.join("\n • ")
31
- msg
32
- }
33
-
34
- sftp.download(file_names, local_folder: local_folder)
35
- end
22
+ def sftp_download_files(subfolder: remote_subfolder, pattern: nil, local_folder: self.local_folder, &block)
23
+ remote_files = with_remote_files(subfolder: subfolder, pattern: pattern)
24
+ return [] if remote_files.empty?
25
+
26
+ file_names = remote_files.map {|file| to_remote_path(file.name, subfolder: subfolder)}
27
+
28
+ log(:info) {
29
+ msg = "Getting the following files into the local folder '#{local_folder}':\n"
30
+ msg << " • "
31
+ msg << file_names.join("\n • ")
32
+ msg
33
+ }
34
+
35
+ sftp.download(file_names, local_folder: local_folder, &block)
36
36
  end
37
37
 
38
38
  def sftp_move_file(source, dest)
data/lib/eco/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Eco
2
- VERSION = '2.7.9'.freeze
2
+ VERSION = '2.7.11'.freeze
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.7.9
4
+ version: 2.7.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura
@@ -170,6 +170,34 @@ dependencies:
170
170
  - - "<"
171
171
  - !ruby/object:Gem::Version
172
172
  version: '0.4'
173
+ - !ruby/object:Gem::Dependency
174
+ name: ed25519
175
+ requirement: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ version: '1.2'
180
+ type: :runtime
181
+ prerelease: false
182
+ version_requirements: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ - - ">="
185
+ - !ruby/object:Gem::Version
186
+ version: '1.2'
187
+ - !ruby/object:Gem::Dependency
188
+ name: bcrypt_pbkdf
189
+ requirement: !ruby/object:Gem::Requirement
190
+ requirements:
191
+ - - ">="
192
+ - !ruby/object:Gem::Version
193
+ version: '1.0'
194
+ type: :runtime
195
+ prerelease: false
196
+ version_requirements: !ruby/object:Gem::Requirement
197
+ requirements:
198
+ - - ">="
199
+ - !ruby/object:Gem::Version
200
+ version: '1.0'
173
201
  - !ruby/object:Gem::Dependency
174
202
  name: aws-sdk-s3
175
203
  requirement: !ruby/object:Gem::Requirement