eco-helpers 2.2.5 → 2.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +28 -1
- data/eco-helpers.gemspec +3 -3
- data/lib/eco/api/common/people/entry_factory.rb +1 -3
- data/lib/eco/api/common/version_patches/ecoportal_api/external_person.rb +0 -11
- data/lib/eco/api/common/version_patches/ecoportal_api.rb +0 -3
- data/lib/eco/api/microcases/with_each_leaver.rb +4 -1
- data/lib/eco/api/session/config/tagtree.rb +4 -1
- data/lib/eco/api/session.rb +2 -2
- data/lib/eco/cli/config/default/input.rb +8 -2
- data/lib/eco/cli/config/default/options.rb +7 -0
- data/lib/eco/version.rb +1 -1
- metadata +13 -16
- data/lib/eco/api/common/version_patches/ecoportal_api/client.rb +0 -9
- data/lib/eco/api/common/version_patches/ecoportal_api/external_details.rb +0 -15
- data/lib/eco/api/common/version_patches/ecoportal_api/internal_person.rb +0 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4cf51ce07b09a2eaa798de0b8524206de5a91160bd3d5df2af980c8985bfbdda
|
4
|
+
data.tar.gz: a203cc025f972e1b35c605450f42556911b913d43f8b860ff8e6f346eb93fb91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff86775ef30897999f6e109cb7a442fb0d8eaeae789715a91f62483d56c181a553f99a8d6c6aa7ce406da0577bfe1b0c90a02fcc918dbde7d8cecba398df032a
|
7
|
+
data.tar.gz: a16c1de5d41090ad98adcd8540da800a5bb0857c7f15bbc9c88898d0885d2f9ae9392a1b699c4d26e8378d9799d750a509230924076ffc1570a2418b08bfffb0
|
data/CHANGELOG.md
CHANGED
@@ -1,12 +1,39 @@
|
|
1
1
|
# Change Log
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
-
## [2.
|
4
|
+
## [2.3.4] - 2023-03-xx
|
5
5
|
|
6
6
|
### Added
|
7
|
+
- Added new option `-input-encoding` to specify the encoding of an input file
|
8
|
+
|
7
9
|
### Changed
|
10
|
+
- `ecoportal-api` **gem** update
|
11
|
+
|
8
12
|
### Fixed
|
9
13
|
|
14
|
+
## [2.3.3] - 2023-03-16
|
15
|
+
|
16
|
+
### Added
|
17
|
+
- Added new option `-input-encoding` to specify the encoding of an input file
|
18
|
+
|
19
|
+
### Changed
|
20
|
+
- `ecoportal-api` **gem** update
|
21
|
+
|
22
|
+
|
23
|
+
## [2.3.2] - 2023-03-10
|
24
|
+
|
25
|
+
### Fixed
|
26
|
+
- upgraded core library gems:
|
27
|
+
- `ecoportal-api`
|
28
|
+
|
29
|
+
## [2.3.1] - 2023-03-09
|
30
|
+
|
31
|
+
### Changed
|
32
|
+
- upgraded core library gems:
|
33
|
+
- `ecoportal-api`
|
34
|
+
- `ecoportal-api-v2`
|
35
|
+
- `ecoportal-api-graphql`
|
36
|
+
|
10
37
|
## [2.2.5] - 2023-03-07
|
11
38
|
|
12
39
|
### Fixed
|
data/eco-helpers.gemspec
CHANGED
@@ -30,9 +30,9 @@ Gem::Specification.new do |spec|
|
|
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.
|
34
|
-
spec.add_dependency 'ecoportal-api-v2', '>= 1.
|
35
|
-
spec.add_dependency 'ecoportal-api-graphql', '>= 0.
|
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.1', '< 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
38
|
spec.add_dependency 'dotenv', '>= 2.7.6', '< 2.8'
|
@@ -195,12 +195,12 @@ module Eco
|
|
195
195
|
end
|
196
196
|
ext = File.extname(file)
|
197
197
|
encoding ||= Eco::API::Common::Session::FileManager.encoding(file)
|
198
|
-
encoding = (encoding != "utf-8")? "#{encoding}|utf-8": encoding
|
199
198
|
read_with_tolerance(file, encoding: encoding)
|
200
199
|
end
|
201
200
|
|
202
201
|
def read_with_tolerance(file, encoding:)
|
203
202
|
if content = File.read(file, encoding: encoding)
|
203
|
+
content = content.encode("utf-8")
|
204
204
|
tolerance = 5
|
205
205
|
content.scrub do |bytes|
|
206
206
|
replacement = '<' + bytes.unpack('H*')[0] + '>'
|
@@ -220,9 +220,7 @@ module Eco
|
|
220
220
|
logger.fatal(msg)
|
221
221
|
raise msg
|
222
222
|
end
|
223
|
-
|
224
223
|
end
|
225
|
-
|
226
224
|
end
|
227
225
|
end
|
228
226
|
end
|
@@ -3,17 +3,6 @@ module Ecoportal
|
|
3
3
|
class V1
|
4
4
|
# @attr entry [Eco::API::Common::People::PersonEntry, Hash] the input entry plain hash data used to update/create this person.
|
5
5
|
class Person
|
6
|
-
class << self
|
7
|
-
def redef_without_warning(const, value)
|
8
|
-
self.class.send(:remove_const, const) if self.class.const_defined?(const)
|
9
|
-
self.class.const_set(const, value)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
redef_without_warning('VALID_TAG_REGEX', /^[A-Za-z0-9 &_'\/.-]+$/)
|
14
|
-
|
15
|
-
passthrough :contractor_organization_id
|
16
|
-
|
17
6
|
attr_accessor :entry
|
18
7
|
|
19
8
|
def identify(section = :person)
|
@@ -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
|
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.
|
@@ -28,7 +28,10 @@ module Eco
|
|
28
28
|
end.max do |a,b|
|
29
29
|
a.count <=> b.count
|
30
30
|
end.tap do |tree|
|
31
|
-
|
31
|
+
if tree
|
32
|
+
msg ="Using LIVE LOCATIONS Structure: '#{tree.name}' (#{tree.count} nodes)"
|
33
|
+
session_logger.info(msg)
|
34
|
+
end
|
32
35
|
end
|
33
36
|
end
|
34
37
|
|
data/lib/eco/api/session.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
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
|
+
version: 2.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oscar Segura
|
@@ -116,60 +116,60 @@ dependencies:
|
|
116
116
|
requirements:
|
117
117
|
- - ">="
|
118
118
|
- !ruby/object:Gem::Version
|
119
|
-
version: 0.
|
119
|
+
version: 0.9.3
|
120
120
|
- - "<"
|
121
121
|
- !ruby/object:Gem::Version
|
122
|
-
version: '0.
|
122
|
+
version: '0.10'
|
123
123
|
type: :runtime
|
124
124
|
prerelease: false
|
125
125
|
version_requirements: !ruby/object:Gem::Requirement
|
126
126
|
requirements:
|
127
127
|
- - ">="
|
128
128
|
- !ruby/object:Gem::Version
|
129
|
-
version: 0.
|
129
|
+
version: 0.9.3
|
130
130
|
- - "<"
|
131
131
|
- !ruby/object:Gem::Version
|
132
|
-
version: '0.
|
132
|
+
version: '0.10'
|
133
133
|
- !ruby/object:Gem::Dependency
|
134
134
|
name: ecoportal-api-v2
|
135
135
|
requirement: !ruby/object:Gem::Requirement
|
136
136
|
requirements:
|
137
137
|
- - ">="
|
138
138
|
- !ruby/object:Gem::Version
|
139
|
-
version: 1.
|
139
|
+
version: 1.1.1
|
140
140
|
- - "<"
|
141
141
|
- !ruby/object:Gem::Version
|
142
|
-
version: '1.
|
142
|
+
version: '1.2'
|
143
143
|
type: :runtime
|
144
144
|
prerelease: false
|
145
145
|
version_requirements: !ruby/object:Gem::Requirement
|
146
146
|
requirements:
|
147
147
|
- - ">="
|
148
148
|
- !ruby/object:Gem::Version
|
149
|
-
version: 1.
|
149
|
+
version: 1.1.1
|
150
150
|
- - "<"
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: '1.
|
152
|
+
version: '1.2'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: ecoportal-api-graphql
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
157
|
- - ">="
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: 0.
|
159
|
+
version: 0.3.1
|
160
160
|
- - "<"
|
161
161
|
- !ruby/object:Gem::Version
|
162
|
-
version: '0.
|
162
|
+
version: '0.4'
|
163
163
|
type: :runtime
|
164
164
|
prerelease: false
|
165
165
|
version_requirements: !ruby/object:Gem::Requirement
|
166
166
|
requirements:
|
167
167
|
- - ">="
|
168
168
|
- !ruby/object:Gem::Version
|
169
|
-
version: 0.
|
169
|
+
version: 0.3.1
|
170
170
|
- - "<"
|
171
171
|
- !ruby/object:Gem::Version
|
172
|
-
version: '0.
|
172
|
+
version: '0.4'
|
173
173
|
- !ruby/object:Gem::Dependency
|
174
174
|
name: aws-sdk-s3
|
175
175
|
requirement: !ruby/object:Gem::Requirement
|
@@ -457,10 +457,7 @@ files:
|
|
457
457
|
- lib/eco/api/common/session/sftp.rb
|
458
458
|
- lib/eco/api/common/version_patches.rb
|
459
459
|
- lib/eco/api/common/version_patches/ecoportal_api.rb
|
460
|
-
- lib/eco/api/common/version_patches/ecoportal_api/client.rb
|
461
|
-
- lib/eco/api/common/version_patches/ecoportal_api/external_details.rb
|
462
460
|
- lib/eco/api/common/version_patches/ecoportal_api/external_person.rb
|
463
|
-
- lib/eco/api/common/version_patches/ecoportal_api/internal_person.rb
|
464
461
|
- lib/eco/api/common/version_patches/exception.rb
|
465
462
|
- lib/eco/api/common/version_patches/hash.rb
|
466
463
|
- lib/eco/api/common/version_patches/hash/deep_merge.rb
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module Ecoportal
|
2
|
-
module API
|
3
|
-
class V1
|
4
|
-
class PersonDetails
|
5
|
-
# Checks if an `id` or `alt_id` exists
|
6
|
-
# @param id [String] the `id` or the `alt_id` of the target field.
|
7
|
-
# @return [Boolean] `true` if it exists, `false` otherwise
|
8
|
-
def key?(id)
|
9
|
-
@fields_by_id or index_fields
|
10
|
-
@fields_by_id.key?(id) || @fields_by_alt_id.key?(id)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
module Ecoportal
|
2
|
-
module API
|
3
|
-
class Internal
|
4
|
-
class Person
|
5
|
-
|
6
|
-
def new?(doc = :initial)
|
7
|
-
ref_doc = (doc == :original) ? original_doc : initial_doc
|
8
|
-
!ref_doc["details"] && !ref_doc["account"]
|
9
|
-
end
|
10
|
-
|
11
|
-
# @return [Boolean] if the account has been added, compared to `doc`
|
12
|
-
def account_added?(doc = :initial)
|
13
|
-
ref_doc = (doc == :original) ? original_doc : initial_doc
|
14
|
-
account && !ref_doc["account"]
|
15
|
-
end
|
16
|
-
|
17
|
-
# It replaces `doc` by `new_doc`
|
18
|
-
# @return [Hash] `doc` before change
|
19
|
-
def replace_doc!(new_doc)
|
20
|
-
raise UnlinkedModel.new(from: "#{self.class}#replace_doc", key: _key) unless linked?
|
21
|
-
@doc.tap do
|
22
|
-
@doc = new_doc
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
# It replaces `original_doc` by `new_doc`
|
27
|
-
# @return [Hash] `original_doc` before change
|
28
|
-
def replace_original_doc!(new_doc)
|
29
|
-
raise UnlinkedModel.new(from: "#{self.class}#replace_original_doc", key: _key) unless linked?
|
30
|
-
@original_doc.tap do
|
31
|
-
@original_doc = new_doc
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|