eco-helpers 2.0.66 → 2.0.67
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/eco-helpers.gemspec +2 -1
- data/lib/eco/api/session/config/api.rb +28 -4
- data/lib/eco/api/session/config/apis.rb +7 -2
- data/lib/eco/api/session/config/sftp.rb +1 -1
- data/lib/eco/api/usecases/graphql/base.rb +26 -0
- data/lib/eco/api/usecases/graphql.rb +10 -0
- data/lib/eco/api/usecases.rb +1 -0
- data/lib/eco/api.rb +1 -0
- data/lib/eco/csv/table.rb +8 -3
- data/lib/eco/csv.rb +2 -17
- data/lib/eco/version.rb +1 -1
- metadata +25 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f70487179ebb87c5d44b0050fda66b5e87ed8a79d8e75c16cc5e5d9be131ec53
|
4
|
+
data.tar.gz: be65600c6f6f2f713322bc3dc2588814643fb2815bc026d8a2d2f757c435736e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c13a4b7998ca745cf3e5d9c44da3fda08ea4109963179887b51b0d1fc1281e3c3213e14734748418a147aa32395a5b2abc0a6229c45d806a290ab06b1eea20da
|
7
|
+
data.tar.gz: 33b060518fea320eb17c0a2cd6fc8bd528b8a7cfdd1779af643300aac53adb77dcbd200a1f70dad4ea28c51801d6427bf19b9ce7d676fddd8187401a68f266bf
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,24 @@
|
|
1
1
|
# Change Log
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
+
## [2.0.67] - 2022-08-11
|
5
|
+
|
6
|
+
### Added
|
7
|
+
- **dependency** to `ecoportal-api-graphql` **gem**
|
8
|
+
- Added integration for `GraphQL`
|
9
|
+
- `session.api(version: :graphql)`
|
10
|
+
- New base case `Eco::API::UseCases::GraphQL::Base` to create `GraphQL` use cases
|
11
|
+
|
12
|
+
### Changed
|
13
|
+
- `Eco::CSV#read` and `Eco::CSV#parse` delegating `nil` row removal to sublcass `Eco::CSV::Table`
|
14
|
+
- **upgraded** dependency on `ecoportal-api-v2`
|
15
|
+
|
16
|
+
### Fixed
|
17
|
+
- `Eco::API::Session::Config::SFTP#remote_folder` to have path separator always as `/`
|
18
|
+
- `Eco::CSV::Table`
|
19
|
+
- to delete rows with all `nil` values
|
20
|
+
- to keep `header` when file comes only with `header` row (with `0` count)
|
21
|
+
|
4
22
|
## [2.0.66] - 2022-08-11
|
5
23
|
|
6
24
|
### Added
|
data/eco-helpers.gemspec
CHANGED
@@ -31,7 +31,8 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.add_development_dependency "redcarpet", ">= 3.5.1", "< 3.6"
|
32
32
|
|
33
33
|
spec.add_dependency 'ecoportal-api', '>= 0.8.5', '< 0.9'
|
34
|
-
spec.add_dependency 'ecoportal-api-v2', '>= 0.8.
|
34
|
+
spec.add_dependency 'ecoportal-api-v2', '>= 0.8.31', '< 0.9'
|
35
|
+
spec.add_dependency 'ecoportal-api-graphql', '>= 0.1.3', '< 0.2'
|
35
36
|
spec.add_dependency 'aws-sdk-s3', '>= 1.83.0', '< 2'
|
36
37
|
spec.add_dependency 'aws-sdk-ses', '>= 1.36.0', '< 2'
|
37
38
|
spec.add_dependency 'dotenv', '>= 2.7.6', '< 2.8'
|
@@ -12,6 +12,8 @@ module Eco
|
|
12
12
|
:v1
|
13
13
|
when :v2, :oozes
|
14
14
|
:v2
|
15
|
+
when :graphql
|
16
|
+
:graphql
|
15
17
|
else # :internal, :v0
|
16
18
|
:v0
|
17
19
|
end
|
@@ -25,13 +27,17 @@ module Eco
|
|
25
27
|
Ecoportal::API::V1
|
26
28
|
when :v2
|
27
29
|
Ecoportal::API::V2
|
30
|
+
when :graphql
|
31
|
+
Ecoportal::API::GraphQL
|
28
32
|
else
|
29
33
|
end
|
30
34
|
end
|
31
35
|
|
32
36
|
end
|
33
37
|
|
34
|
-
def initialize(name, key:, host:, version:,
|
38
|
+
def initialize(name, root:, key:, host:, version:,
|
39
|
+
mode: :local, user_key: nil, external_key: nil,
|
40
|
+
email: nil, pass: nil, org_id: nil)
|
35
41
|
super(nil)
|
36
42
|
@root = root
|
37
43
|
@apis = {}
|
@@ -42,6 +48,9 @@ module Eco
|
|
42
48
|
self["mode"] = mode
|
43
49
|
self["user_key"] = user_key
|
44
50
|
self["external_key"] = external_key
|
51
|
+
self["email"] = email
|
52
|
+
self["pass"] = pass
|
53
|
+
self["org_id"] = org_id
|
45
54
|
end
|
46
55
|
|
47
56
|
# @return [Eco::API::Session::Config] the `root` config
|
@@ -103,6 +112,18 @@ module Eco
|
|
103
112
|
(version == :v0) && self["key"]
|
104
113
|
end
|
105
114
|
|
115
|
+
def org_id
|
116
|
+
self["org_id"]
|
117
|
+
end
|
118
|
+
|
119
|
+
def email
|
120
|
+
self["email"]
|
121
|
+
end
|
122
|
+
|
123
|
+
def pass
|
124
|
+
self["pass"]
|
125
|
+
end
|
126
|
+
|
106
127
|
def host
|
107
128
|
self["host"]
|
108
129
|
end
|
@@ -147,10 +168,12 @@ module Eco
|
|
147
168
|
klass.new(external_key, host: host, logger: logger)
|
148
169
|
when :v2
|
149
170
|
klass.new(user_key: user_key, org_key: external_key, host: host, logger: logger)
|
171
|
+
when :graphql
|
172
|
+
klass.new(org_id: org_id, email: email, pass: pass)
|
150
173
|
end.tap do |api|
|
151
174
|
unless !api || log_connection?
|
152
175
|
@logger.info("Created api#{self.version(version)} connection on '#{name}' enviro, pointing to '#{host}' in '#{mode}' mode")
|
153
|
-
api.logger.level = ::Logger::UNKNOWN
|
176
|
+
api.logger.level = ::Logger::UNKNOWN if api.respond_to?(:logger)
|
154
177
|
end
|
155
178
|
end
|
156
179
|
end
|
@@ -163,14 +186,15 @@ module Eco
|
|
163
186
|
when :v1
|
164
187
|
external_key && host
|
165
188
|
when :v2
|
166
|
-
external_key && user_key
|
189
|
+
org_id && external_key && user_key
|
190
|
+
when :graphql
|
191
|
+
email && pass && org_id
|
167
192
|
end
|
168
193
|
end
|
169
194
|
|
170
195
|
def log_connection?
|
171
196
|
config.logger.log_connection?
|
172
197
|
end
|
173
|
-
|
174
198
|
end
|
175
199
|
end
|
176
200
|
end
|
@@ -26,7 +26,9 @@ module Eco
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
def add(name, key:, host:, version: :internal,
|
29
|
+
def add(name, key:, host:, version: :internal,
|
30
|
+
mode: :local, user_key: nil, external_key: nil,
|
31
|
+
email: nil, pass: nil, org_id: nil)
|
30
32
|
apis[name] = Session::Config::Api.new(
|
31
33
|
name,
|
32
34
|
key: key,
|
@@ -35,7 +37,10 @@ module Eco
|
|
35
37
|
mode: mode,
|
36
38
|
root: self,
|
37
39
|
user_key: user_key,
|
38
|
-
external_key: external_key
|
40
|
+
external_key: external_key,
|
41
|
+
email: email,
|
42
|
+
pass: pass,
|
43
|
+
org_id: org_id
|
39
44
|
)
|
40
45
|
self
|
41
46
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class Eco::API::UseCases::GraphQL::Base < Eco::API::Common::Loaders::UseCase
|
2
|
+
name "graphql-base"
|
3
|
+
type :other
|
4
|
+
|
5
|
+
attr_reader :session, :options, :usecase
|
6
|
+
|
7
|
+
def main(session, options, usecase)
|
8
|
+
options[:end_get] = false
|
9
|
+
@session = session; @options = options; @usecase = usecase
|
10
|
+
process
|
11
|
+
end
|
12
|
+
|
13
|
+
# Write here your script
|
14
|
+
def process
|
15
|
+
raise "You need to inherit from this class ('#{self.class}') and call super with a block"
|
16
|
+
end
|
17
|
+
|
18
|
+
def graphql
|
19
|
+
@graphql ||= session.api(version: :graphql)
|
20
|
+
end
|
21
|
+
|
22
|
+
def exit_error(msg)
|
23
|
+
logger.error(msg)
|
24
|
+
exit(1)
|
25
|
+
end
|
26
|
+
end
|
data/lib/eco/api/usecases.rb
CHANGED
data/lib/eco/api.rb
CHANGED
data/lib/eco/csv/table.rb
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
module Eco
|
2
2
|
class CSV
|
3
3
|
class Table < ::CSV::Table
|
4
|
-
|
5
4
|
# @param input [Array<Row>, Array<Array>, Eco::CSV::Table, ::CSV::Table]
|
6
5
|
# - when `Array<Array>` => all `rows` as arrays where first array is the **header**
|
7
6
|
def initialize(input)
|
8
7
|
super(to_rows_array(input))
|
8
|
+
self.delete_if do |row|
|
9
|
+
values = row.fields
|
10
|
+
values.all?(&:nil?) || values.map(&:to_s).all?(&:empty?)
|
11
|
+
end
|
9
12
|
end
|
10
13
|
|
11
14
|
# @return [Hash] where keys are the groups and the values a `Eco::CSV::Table`
|
@@ -178,8 +181,9 @@ module Eco
|
|
178
181
|
private
|
179
182
|
|
180
183
|
def columns_to_table(columns_array)
|
181
|
-
|
182
|
-
self.class.new(
|
184
|
+
rows_data = columns_array.transpose
|
185
|
+
return self.class.new(rows_data) if rows_data.length > 0
|
186
|
+
raise ArgumentError.new("Expecting 'columns_array' to at least have header. Given: #{columns_array}")
|
183
187
|
end
|
184
188
|
|
185
189
|
def to_rows_array(data)
|
@@ -200,6 +204,7 @@ module Eco
|
|
200
204
|
data
|
201
205
|
when Array
|
202
206
|
headers = data.shift
|
207
|
+
data.push(Array.new(headers.length)) if data.count == 0
|
203
208
|
data.map do |arr_row|
|
204
209
|
::CSV::Row.new(headers, arr_row)
|
205
210
|
end.compact
|
data/lib/eco/csv.rb
CHANGED
@@ -8,34 +8,19 @@ module Eco
|
|
8
8
|
# @return [Eco::CSV::Table]
|
9
9
|
def parse(data, **kargs, &block)
|
10
10
|
kargs = {headers: true, skip_blanks: true}.merge(kargs)
|
11
|
-
|
12
|
-
values = row.to_hash.values
|
13
|
-
values.all?(&:nil?) || values.map(&:to_s).all?(&:empty?)
|
14
|
-
end
|
15
|
-
Eco::CSV::Table.new(out)
|
11
|
+
Eco::CSV::Table.new(super(data, **kargs, &block))
|
16
12
|
end
|
17
13
|
|
18
14
|
# @return [Eco::CSV::Table]
|
19
15
|
def read(file, **kargs)
|
20
16
|
kargs = {headers: true, skip_blanks: true}.merge(kargs)
|
21
|
-
|
22
17
|
args = [file].tap do |arg|
|
23
18
|
encoding = Eco::API::Common::Session::FileManager.encoding(file)
|
24
|
-
#encoding = (encoding != "utf-8")? "#{encoding}|utf-8": encoding
|
25
|
-
#arg.push(encoding)
|
26
19
|
arg.push("rb:bom|utf-8") if encoding == "bom"
|
27
20
|
end
|
28
|
-
|
29
|
-
out = super(*args, **kargs).reject do |row|
|
30
|
-
values = row.to_hash.values
|
31
|
-
values.all?(&:nil?) || values.map(&:to_s).all?(&:empty?)
|
32
|
-
end
|
33
|
-
Eco::CSV::Table.new(out)
|
21
|
+
Eco::CSV::Table.new(super(*args, **kargs))
|
34
22
|
end
|
35
|
-
|
36
23
|
end
|
37
|
-
|
38
|
-
|
39
24
|
end
|
40
25
|
end
|
41
26
|
|
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.0.
|
4
|
+
version: 2.0.67
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oscar Segura
|
@@ -136,7 +136,7 @@ dependencies:
|
|
136
136
|
requirements:
|
137
137
|
- - ">="
|
138
138
|
- !ruby/object:Gem::Version
|
139
|
-
version: 0.8.
|
139
|
+
version: 0.8.31
|
140
140
|
- - "<"
|
141
141
|
- !ruby/object:Gem::Version
|
142
142
|
version: '0.9'
|
@@ -146,10 +146,30 @@ dependencies:
|
|
146
146
|
requirements:
|
147
147
|
- - ">="
|
148
148
|
- !ruby/object:Gem::Version
|
149
|
-
version: 0.8.
|
149
|
+
version: 0.8.31
|
150
150
|
- - "<"
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0.9'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: ecoportal-api-graphql
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 0.1.3
|
160
|
+
- - "<"
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: '0.2'
|
163
|
+
type: :runtime
|
164
|
+
prerelease: false
|
165
|
+
version_requirements: !ruby/object:Gem::Requirement
|
166
|
+
requirements:
|
167
|
+
- - ">="
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: 0.1.3
|
170
|
+
- - "<"
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0.2'
|
153
173
|
- !ruby/object:Gem::Dependency
|
154
174
|
name: aws-sdk-s3
|
155
175
|
requirement: !ruby/object:Gem::Requirement
|
@@ -565,6 +585,8 @@ files:
|
|
565
585
|
- lib/eco/api/usecases/default_cases/update_case.rb
|
566
586
|
- lib/eco/api/usecases/default_cases/update_details_case.rb
|
567
587
|
- lib/eco/api/usecases/default_cases/upsert_case.rb
|
588
|
+
- lib/eco/api/usecases/graphql.rb
|
589
|
+
- lib/eco/api/usecases/graphql/base.rb
|
568
590
|
- lib/eco/api/usecases/ooze_cases.rb
|
569
591
|
- lib/eco/api/usecases/ooze_cases/export_register_case.rb
|
570
592
|
- lib/eco/api/usecases/ooze_samples.rb
|