eco-helpers 1.3.2 → 1.3.3
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 64ffc42a60247e70fba74a45b4cdef667d9df2060e5dade03312631e41b0a91a
|
4
|
+
data.tar.gz: 94dcaa78623fe11bde331bb71deb52664a87f50b397bc21b37ee91aedea0df95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: acf65af431eb33a3b6ba5d864b9dedf2b2cb45469354933011807d6ed8598a2b73254a07f6eaf8531c025608458e7ef211b31a324847879a93278c4029bdc322
|
7
|
+
data.tar.gz: f8975080afd8acfa445e00af5665eb2d4f8ed9bb4aecbd29038a417842012ffd52c3ad53bd7197924d285ef4f27b233e09e95723ecda308f81148eac945ca867
|
@@ -184,7 +184,7 @@ module Eco
|
|
184
184
|
if tree_file = org["tagtree"]
|
185
185
|
tree = []
|
186
186
|
tree = file_manager.load_json(tree_file) unless !tree_file
|
187
|
-
@tagtree
|
187
|
+
@tagtree = Eco::API::Organization::TagTree.new(tree, enviro: enviro)
|
188
188
|
end
|
189
189
|
end
|
190
190
|
|
@@ -14,6 +14,7 @@ module Eco
|
|
14
14
|
ResetLandingPageCase.new(self).process
|
15
15
|
ToCsvCase.new(self).process
|
16
16
|
ToCsvDetailedCase.new(self).process
|
17
|
+
CodesToTagsCase.new(self).process
|
17
18
|
EmailAsIdCase.new(self).process
|
18
19
|
NewIdCase.new(self).process
|
19
20
|
NewEmailCase.new(self).process
|
@@ -43,6 +44,7 @@ end
|
|
43
44
|
require_relative 'default_cases/reset_landing_page_case'
|
44
45
|
require_relative 'default_cases/to_csv_case'
|
45
46
|
require_relative 'default_cases/to_csv_detailed_case'
|
47
|
+
require_relative 'default_cases/codes_to_tags_case'
|
46
48
|
require_relative 'default_cases/email_as_id_case'
|
47
49
|
require_relative 'default_cases/new_id_case'
|
48
50
|
require_relative 'default_cases/new_email_case'
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Eco
|
2
|
+
module API
|
3
|
+
class UseCases
|
4
|
+
class DefaultCases
|
5
|
+
class CodesToTagsCase < DefaultCase
|
6
|
+
|
7
|
+
def process
|
8
|
+
@cases.define("codes-to-tags-from", type: :other) do |session, options, usecase|
|
9
|
+
raise "You have not defined a tagtree for the organisation" unless session.tagtree
|
10
|
+
|
11
|
+
unless mapper = session.config.location_codes && session.config.locations_mapper
|
12
|
+
raise "No filter_tags parser, nor location mappings are present"
|
13
|
+
end
|
14
|
+
|
15
|
+
to_tag = Proc.new do |code|
|
16
|
+
if mapper.external?(code)
|
17
|
+
mapper.to_internal(code)
|
18
|
+
elsif session.tagtree.tag?(code)
|
19
|
+
code.upcase
|
20
|
+
else
|
21
|
+
session.logger.warn("Unknown Location Code: '#{code}'")
|
22
|
+
nil
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
codes_column = options.dig(:other, :file, :codes_column)
|
27
|
+
input_file = options.dig(:other, :file, :name)
|
28
|
+
output_file = "mapped_#{File.basename(input_file).gsub(/\s/, "")}"
|
29
|
+
|
30
|
+
csv_table = Eco::CSV.read(input_file)
|
31
|
+
|
32
|
+
csv_table.add_column("ecoPortalTag").tap do |csv_table|
|
33
|
+
csv_table.each do |row|
|
34
|
+
row["ecoPortalTag"] = to_tag.call(row[codes_column])
|
35
|
+
end
|
36
|
+
|
37
|
+
File.open(output_file, "w") {|fd| fd << csv_table.to_csv}
|
38
|
+
end
|
39
|
+
exit
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -10,6 +10,14 @@ ASSETS.cli.config do |cnf|
|
|
10
10
|
session.usecases.case(case_name)
|
11
11
|
end
|
12
12
|
|
13
|
+
cases.add("-codes-to-tags-from", :other, case_name: "codes-to-tags-from") do |session, options|
|
14
|
+
file = SCR.get_file("-codes-to-tags-from", required: true, should_exist: true)
|
15
|
+
options.deep_merge!(other: {file: {name: file, format: :csv}})
|
16
|
+
|
17
|
+
col_codes = SCR.get_arg("-column", with_param: true)
|
18
|
+
options.deep_merge!(other: {file: {codes_column: col_codes}})
|
19
|
+
end
|
20
|
+
|
13
21
|
cases.add("-reset-landing-page", :transform, case_name: "reset-landing-page")
|
14
22
|
cases.add("-email-as-id", :transform, case_name: "email-as-id")
|
15
23
|
cases.add("-new-id-from", :sync, case_name: "new-id")
|
@@ -25,6 +33,7 @@ ASSETS.cli.config do |cnf|
|
|
25
33
|
session.logger.error(msg)
|
26
34
|
exit(1)
|
27
35
|
end
|
36
|
+
|
28
37
|
options.deep_merge!(super: {old: old_id})
|
29
38
|
|
30
39
|
unless new_id = SCR.get_arg("-new-super", with_param: true)
|
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: 1.3.
|
4
|
+
version: 1.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oscar Segura
|
@@ -82,22 +82,22 @@ dependencies:
|
|
82
82
|
name: redcarpet
|
83
83
|
requirement: !ruby/object:Gem::Requirement
|
84
84
|
requirements:
|
85
|
-
- - "~>"
|
86
|
-
- !ruby/object:Gem::Version
|
87
|
-
version: '3.5'
|
88
85
|
- - ">="
|
89
86
|
- !ruby/object:Gem::Version
|
90
87
|
version: 3.5.0
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '3.5'
|
91
91
|
type: :development
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
|
-
- - "~>"
|
96
|
-
- !ruby/object:Gem::Version
|
97
|
-
version: '3.5'
|
98
95
|
- - ">="
|
99
96
|
- !ruby/object:Gem::Version
|
100
97
|
version: 3.5.0
|
98
|
+
- - "~>"
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '3.5'
|
101
101
|
- !ruby/object:Gem::Dependency
|
102
102
|
name: ecoportal-api
|
103
103
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,42 +142,42 @@ dependencies:
|
|
142
142
|
name: aws-sdk-ses
|
143
143
|
requirement: !ruby/object:Gem::Requirement
|
144
144
|
requirements:
|
145
|
-
- - "~>"
|
146
|
-
- !ruby/object:Gem::Version
|
147
|
-
version: '1.14'
|
148
145
|
- - ">="
|
149
146
|
- !ruby/object:Gem::Version
|
150
147
|
version: 1.14.0
|
148
|
+
- - "~>"
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '1.14'
|
151
151
|
type: :runtime
|
152
152
|
prerelease: false
|
153
153
|
version_requirements: !ruby/object:Gem::Requirement
|
154
154
|
requirements:
|
155
|
-
- - "~>"
|
156
|
-
- !ruby/object:Gem::Version
|
157
|
-
version: '1.14'
|
158
155
|
- - ">="
|
159
156
|
- !ruby/object:Gem::Version
|
160
157
|
version: 1.14.0
|
158
|
+
- - "~>"
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '1.14'
|
161
161
|
- !ruby/object:Gem::Dependency
|
162
162
|
name: dotenv
|
163
163
|
requirement: !ruby/object:Gem::Requirement
|
164
164
|
requirements:
|
165
|
-
- - "~>"
|
166
|
-
- !ruby/object:Gem::Version
|
167
|
-
version: '2.6'
|
168
165
|
- - ">="
|
169
166
|
- !ruby/object:Gem::Version
|
170
167
|
version: 2.6.0
|
168
|
+
- - "~>"
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: '2.6'
|
171
171
|
type: :runtime
|
172
172
|
prerelease: false
|
173
173
|
version_requirements: !ruby/object:Gem::Requirement
|
174
174
|
requirements:
|
175
|
-
- - "~>"
|
176
|
-
- !ruby/object:Gem::Version
|
177
|
-
version: '2.6'
|
178
175
|
- - ">="
|
179
176
|
- !ruby/object:Gem::Version
|
180
177
|
version: 2.6.0
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '2.6'
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
182
|
name: net-sftp
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -300,6 +300,7 @@ files:
|
|
300
300
|
- lib/eco/api/usecases/default_case.rb
|
301
301
|
- lib/eco/api/usecases/default_cases.rb
|
302
302
|
- lib/eco/api/usecases/default_cases/change_email_case.rb
|
303
|
+
- lib/eco/api/usecases/default_cases/codes_to_tags_case.rb
|
303
304
|
- lib/eco/api/usecases/default_cases/create_case.rb
|
304
305
|
- lib/eco/api/usecases/default_cases/create_details_case.rb
|
305
306
|
- lib/eco/api/usecases/default_cases/create_details_with_supervisor_case.rb
|
@@ -387,8 +388,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
387
388
|
- !ruby/object:Gem::Version
|
388
389
|
version: '0'
|
389
390
|
requirements: []
|
390
|
-
|
391
|
-
rubygems_version: 2.7.6.2
|
391
|
+
rubygems_version: 3.0.3
|
392
392
|
signing_key:
|
393
393
|
specification_version: 4
|
394
394
|
summary: eco-helpers to manage people api cases
|