eco-helpers 2.3.2 → 2.4.2

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: e7446c914bf420a89e5964fea7fe67063f75ff6f26a999c2bff908daf3be7636
4
- data.tar.gz: 3d59cd7ffad8e9e5c0d8ce3e2c032024854b7785f5c2742a912fecfc793a435f
3
+ metadata.gz: d2b034981dcaa5e5ecfb1778df6fed175e4631d1244372c475bd5049e8e97c67
4
+ data.tar.gz: ca64274315a6da975781f3d8198b3a58956e9f665a674392ba03090feb284488
5
5
  SHA512:
6
- metadata.gz: 998823b933ca7795d2681556c9a2ca0c5de23ee342ff77877f79ebda57949f2c3a3b074d80d9780fae3a16ccc9c84fb1dfd4b63a1ada03d060bc6a01d9ee2750
7
- data.tar.gz: 9cff3c674bac74f83de92b2b3847a3b9817f7abaf7abd0436347a2aec87d88e1a2ee2388d6768d8e23f28d7e5de69cd5195df3d52b0b801b8bf6925d9b53f8ca
6
+ metadata.gz: 33d6ba24ecab02c3bb10d11577ed067b7eab05e4c1fa0af17c72405cb16fd135b253a0414d33a14821b0684129e921eee0cb65eec8ac88558e3931c5d3bbcb8c
7
+ data.tar.gz: db51965c0d7b2a607a3cd6a1fbbdac48430be4804367d9746d448141c5fe00e04e835c202e696b42bc68e6c153b511f45c3a11b38ee7c6c1701fbb46d3cf9f23
data/CHANGELOG.md CHANGED
@@ -1,12 +1,26 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
- ## [2.3.3] - 2023-03-xx
4
+ ## [2.4.3] - 2023-03-xx
5
5
 
6
6
  ### Added
7
7
  ### Changed
8
8
  ### Fixed
9
9
 
10
+ ## [2.4.2] - 2023-03-17
11
+
12
+ ### Fixed
13
+ - `Eco::API::Common::People::EntryFactory#entries` _bom_ **encoding** (get back support)
14
+
15
+ ## [2.3.3] - 2023-03-16
16
+
17
+ ### Added
18
+ - Added new option `-input-encoding` to specify the encoding of an input file
19
+
20
+ ### Changed
21
+ - `ecoportal-api` **gem** update
22
+
23
+
10
24
  ## [2.3.2] - 2023-03-10
11
25
 
12
26
  ### Fixed
data/eco-helpers.gemspec CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
14
14
  spec.homepage = "https://www.ecoportal.com"
15
15
  spec.licenses = %w[MIT]
16
16
 
17
- spec.required_ruby_version = '>= 2.5.0'
17
+ spec.required_ruby_version = '>= 2.7.2'
18
18
 
19
19
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
20
20
  f.match(%r{^(test|spec|features)/})
@@ -24,13 +24,13 @@ 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.2.17", "< 2.3"
27
+ spec.add_development_dependency "bundler", ">= 2.4.8", "< 2.5"
28
28
  spec.add_development_dependency "rspec", ">= 3.10.0", "< 3.11"
29
29
  spec.add_development_dependency "rake", ">= 13.0.3", "< 13.1"
30
30
  spec.add_development_dependency "yard", ">= 0.9.26", "< 0.10"
31
31
  spec.add_development_dependency "redcarpet", ">= 3.5.1", "< 3.6"
32
32
 
33
- spec.add_dependency 'ecoportal-api', '>= 0.9.2', '< 0.10'
33
+ spec.add_dependency 'ecoportal-api', '>= 0.9.3', '< 0.10'
34
34
  spec.add_dependency 'ecoportal-api-v2', '>= 1.1.1', '< 1.2'
35
35
  spec.add_dependency 'ecoportal-api-graphql', '>= 0.3.1', '< 0.4'
36
36
  spec.add_dependency 'aws-sdk-s3', '>= 1.83.0', '< 2'
@@ -193,14 +193,16 @@ module Eco
193
193
  logger.error("File does not exist: #{file}")
194
194
  exit(1)
195
195
  end
196
- ext = File.extname(file)
196
+ #ext = File.extname(file)
197
197
  encoding ||= Eco::API::Common::Session::FileManager.encoding(file)
198
- encoding = (encoding != "utf-8")? "#{encoding}|utf-8": encoding
198
+ encoding = (encoding == "bom") ? "#{encoding}|utf-8": encoding
199
+ puts "File encoding: '#{encoding}'" unless !encoding || encoding == 'utf-8'
199
200
  read_with_tolerance(file, encoding: encoding)
200
201
  end
201
202
 
202
203
  def read_with_tolerance(file, encoding:)
203
204
  if content = File.read(file, encoding: encoding)
205
+ content = content.encode("utf-8") unless encoding.include?('utf-8')
204
206
  tolerance = 5
205
207
  content.scrub do |bytes|
206
208
  replacement = '<' + bytes.unpack('H*')[0] + '>'
@@ -220,9 +222,7 @@ module Eco
220
222
  logger.fatal(msg)
221
223
  raise msg
222
224
  end
223
-
224
225
  end
225
-
226
226
  end
227
227
  end
228
228
  end
@@ -2,7 +2,10 @@ module Eco
2
2
  module API
3
3
  class MicroCases
4
4
  # Detects who has left the organization and `yield` s them one by one to the given block
5
- # @note to be used only when the input file is the full DB
5
+ # @note
6
+ # - To be used only when the input file is the full DB
7
+ # - The `Entries#find` method. If the people manager entry does not have `external_id`,
8
+ # but has a matching `email` wiht some input entry (row), it won't be identified as a leaver.
6
9
  # @param entries [Eco::API::Common::People::Entries] the input entries with the data.
7
10
  # @param people [Eco::API::Organization::People] target existing _People_ of the current update.
8
11
  # @param options [Hash] the options.
@@ -154,8 +154,8 @@ module Eco
154
154
  # @see Eco::API::Common::People::EntryFactory#entries
155
155
  # @param (see Eco::API::Common::People::EntryFactory#entries)
156
156
  # @return [Eco::API::Common::People::Entries] collection of entries.
157
- def entries(*args)
158
- entry_factory.entries(*args).tap do |collection|
157
+ def entries(*args, **kargs)
158
+ entry_factory.entries(*args, **kargs).tap do |collection|
159
159
  logger.info("Loaded #{collection.length} input entries.")
160
160
  end
161
161
  end
@@ -55,10 +55,14 @@ ASSETS.cli.config do |cnf|
55
55
  options.deep_merge!(input: {file: {name: file}})
56
56
  options.deep_merge!(input: {file: {format: format}})
57
57
 
58
+ encoding = options.dig(:input, :file, :encoding)
59
+
58
60
  case format
59
61
  when :xml
60
62
  [file].flatten.each {|f| session.config.files.validate(:xml, f)}
61
- input = session.entries(file: file, format: format)
63
+ kargs = {file: file, format: format}
64
+ kargs.merge!(encoding: encoding) if encoding
65
+ input = session.entries(**kargs)
62
66
  when :xls
63
67
  input = session.entries(file: file, format: format)
64
68
  when :json
@@ -66,7 +70,9 @@ ASSETS.cli.config do |cnf|
66
70
  people.merge(JSON.parse(File.read(file)))
67
71
  end
68
72
  else # :csv
69
- input = session.csv_entries(file, check_headers: true)
73
+ kargs = {check_headers: true}
74
+ kargs.merge!(encoding: encoding) if encoding
75
+ input = session.csv_entries(file, **kargs)
70
76
  end
71
77
  end
72
78
  input
@@ -68,6 +68,13 @@ ASSETS.cli.config do |cnf|
68
68
  options.deep_merge!(input: {entries_from: true})
69
69
  end
70
70
 
71
+ desc = "Used to specify the input file encoding"
72
+ options_set.add("-input-encoding", desc) do |options, session|
73
+ if encoding = SCR.get_arg("-input-encoding", with_param: true)
74
+ options.deep_merge!(input: {file: {encoding: encoding}})
75
+ end
76
+ end
77
+
71
78
  desc = "Used to only get the people from the input file. It will also include their current and new supervisors."
72
79
  options_set.add("-get-partial", desc) do |options, session|
73
80
  options.deep_merge!(people: {
data/lib/eco/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Eco
2
- VERSION = "2.3.2"
2
+ VERSION = "2.4.2"
3
3
  end
metadata CHANGED
@@ -1,11 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eco-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.2
4
+ version: 2.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2018-09-05 00:00:00.000000000 Z
@@ -16,20 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 2.2.17
19
+ version: 2.4.8
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '2.3'
22
+ version: '2.5'
23
23
  type: :development
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 2.2.17
29
+ version: 2.4.8
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '2.3'
32
+ version: '2.5'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: rspec
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -116,7 +116,7 @@ dependencies:
116
116
  requirements:
117
117
  - - ">="
118
118
  - !ruby/object:Gem::Version
119
- version: 0.9.2
119
+ version: 0.9.3
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.2
129
+ version: 0.9.3
130
130
  - - "<"
131
131
  - !ruby/object:Gem::Version
132
132
  version: '0.10'
@@ -390,7 +390,7 @@ dependencies:
390
390
  - - "<"
391
391
  - !ruby/object:Gem::Version
392
392
  version: '0.7'
393
- description:
393
+ description:
394
394
  email:
395
395
  - oscar@ecoportal.co.nz
396
396
  executables: []
@@ -675,7 +675,7 @@ homepage: https://www.ecoportal.com
675
675
  licenses:
676
676
  - MIT
677
677
  metadata: {}
678
- post_install_message:
678
+ post_install_message:
679
679
  rdoc_options: []
680
680
  require_paths:
681
681
  - lib
@@ -683,15 +683,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
683
683
  requirements:
684
684
  - - ">="
685
685
  - !ruby/object:Gem::Version
686
- version: 2.5.0
686
+ version: 2.7.2
687
687
  required_rubygems_version: !ruby/object:Gem::Requirement
688
688
  requirements:
689
689
  - - ">="
690
690
  - !ruby/object:Gem::Version
691
691
  version: '0'
692
692
  requirements: []
693
- rubygems_version: 3.0.3
694
- signing_key:
693
+ rubygems_version: 3.1.4
694
+ signing_key:
695
695
  specification_version: 4
696
696
  summary: eco-helpers to manage people api cases
697
697
  test_files: []