eco-helpers 2.0.29 → 2.0.33
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +29 -4
- data/eco-helpers.gemspec +2 -1
- data/lib/eco/api/common/loaders/base.rb +1 -1
- data/lib/eco/api/common/people/default_parsers/xls_parser.rb +18 -3
- data/lib/eco/api/session/batch.rb +1 -0
- data/lib/eco/api/session/batch/job.rb +5 -4
- data/lib/eco/api/usecases/ooze_samples.rb +3 -0
- data/lib/eco/api/usecases/ooze_samples/helpers.rb +13 -0
- data/lib/eco/api/usecases/ooze_samples/helpers/shortcuts.rb +62 -0
- data/lib/eco/api/usecases/ooze_samples/ooze_from_doc_case.rb +51 -0
- data/lib/eco/api/usecases/ooze_samples/ooze_run_base_case.rb +132 -0
- data/lib/eco/api/usecases/ooze_samples/ooze_update_case.rb +38 -107
- data/lib/eco/version.rb +1 -1
- metadata +27 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84ad4121fdba090ce8585df6a999c91a0a1ba5c8fa67d52f6dc4ec5d39da18b9
|
4
|
+
data.tar.gz: 96e540e97b6a54a92e246fd794821002ab015c9199d033bcb22abbc2bd729a69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6a3c9b2920974830e3d9ea1619f9f4e2f8652112d0b0683526888cd9d29c29c61e35afe53d94bd0927ddb4b8bd621827cdf5a8a18830143f6549f7b3d8fc37d
|
7
|
+
data.tar.gz: ceaf87bc2b6190f70c91f9ad09da865ecb064bd1be9f783a75cb91f531a9918ee80a1d583ba74c21ab56ac9863eccd6d6c3321b78988961762335e80036f4ed6
|
data/CHANGELOG.md
CHANGED
@@ -1,11 +1,39 @@
|
|
1
1
|
# Change Log
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
-
## [2.0.
|
4
|
+
## [2.0.33] - 2021-08-xx
|
5
5
|
|
6
6
|
### Added
|
7
|
+
- `Eco::API::UseCases::OozeSamples::OozeFromDocCase` use case to abstract form from doc
|
8
|
+
- `docx` dependency
|
9
|
+
- A couple more of helpers for the Ooze Cases: `#titleize` & `#normalize_string`
|
7
10
|
|
8
11
|
### Changed
|
12
|
+
- `ecoporta-api-v2` **gem** (upgrade dependency)
|
13
|
+
|
14
|
+
### Fixed
|
15
|
+
- `Eco::API::UseCases::OozeSamples::OozeUpdateCase`, helper `with_stage`
|
16
|
+
|
17
|
+
## [2.0.32] - 2021-07-14
|
18
|
+
|
19
|
+
### Fixed
|
20
|
+
- `Eco::API::UseCases::OozeSamples::OozeUpdateCase` prompting user, fixed typo
|
21
|
+
- `Eco::API::Session::Batch::Job`: `include-excluded` again... typo.
|
22
|
+
|
23
|
+
## [2.0.31] - 2021-07-13
|
24
|
+
|
25
|
+
### Fixed
|
26
|
+
- `Eco::API::Session::Batch::Job`: `include-excluded` was triggering a type error.
|
27
|
+
|
28
|
+
## [2.0.30] - 2021-07-08
|
29
|
+
|
30
|
+
### Added
|
31
|
+
* `Eco::API::Common::People::DefaultParsers::XLSParser` uses as default the `fields_map.json` to identify the headers.
|
32
|
+
|
33
|
+
### Fixed
|
34
|
+
* `Eco::API::Common::People::DefaultParsers::XLSParser` should return all `String` values
|
35
|
+
|
36
|
+
## [2.0.29] - 2021-07-08
|
9
37
|
|
10
38
|
### Fixed
|
11
39
|
- `Eco::API::Common::People::PersonEntryAttributeMapper#details_attrs`
|
@@ -75,9 +103,6 @@ All notable changes to this project will be documented in this file.
|
|
75
103
|
* when in `dry-run` it fakes the `id` with a counter
|
76
104
|
- `Eco::API::Common::People::PersonFactory` gets `subordinates` initialized to `0` (when **creating** a `new` person)
|
77
105
|
|
78
|
-
### Fixed
|
79
|
-
|
80
|
-
|
81
106
|
## [2.0.25] - 2021-06-23
|
82
107
|
|
83
108
|
### Added
|
data/eco-helpers.gemspec
CHANGED
@@ -31,7 +31,7 @@ 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.3', '< 0.9'
|
34
|
-
spec.add_dependency 'ecoportal-api-v2', '>= 0.8.
|
34
|
+
spec.add_dependency 'ecoportal-api-v2', '>= 0.8.9', '< 0.9'
|
35
35
|
spec.add_dependency 'aws-sdk-s3', '>= 1.83.0', '< 2'
|
36
36
|
spec.add_dependency 'aws-sdk-ses', '>= 1.36.0', '< 2'
|
37
37
|
spec.add_dependency 'dotenv', '>= 2.7.6', '< 2.8'
|
@@ -42,4 +42,5 @@ Gem::Specification.new do |spec|
|
|
42
42
|
spec.add_dependency 'jaro_winkler', '>= 1.5.4', '< 1.6'
|
43
43
|
spec.add_dependency 'roo', '>= 2.8.3', '< 2.9'
|
44
44
|
spec.add_dependency 'roo-xls', '>= 1.2.0', '< 1.3'
|
45
|
+
spec.add_dependency 'docx', '>= 0.6.2', '< 0.7'
|
45
46
|
end
|
@@ -6,7 +6,12 @@ class Eco::API::Common::People::DefaultParsers::XLSParser < Eco::API::Common::Lo
|
|
6
6
|
|
7
7
|
def parser(file, deps)
|
8
8
|
@file = file
|
9
|
-
rows.tap
|
9
|
+
rows.tap do |rws|
|
10
|
+
@file = nil
|
11
|
+
rws.each do |row|
|
12
|
+
to_string!(row)
|
13
|
+
end
|
14
|
+
end
|
10
15
|
end
|
11
16
|
|
12
17
|
def serializer(array_hash, deps)
|
@@ -15,8 +20,18 @@ class Eco::API::Common::People::DefaultParsers::XLSParser < Eco::API::Common::Lo
|
|
15
20
|
|
16
21
|
private
|
17
22
|
|
23
|
+
def to_string!(row)
|
24
|
+
row.transform_values! do |val|
|
25
|
+
next nil unless val
|
26
|
+
next val if val.is_a?(String)
|
27
|
+
val.to_s
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
|
18
32
|
def headers
|
19
|
-
|
33
|
+
logger.warn("Headers detection is using your fields_map.json file (native behaviour)")
|
34
|
+
session.fields_mapper.list(:external).uniq
|
20
35
|
end
|
21
36
|
|
22
37
|
def sheet_name
|
@@ -34,7 +49,7 @@ class Eco::API::Common::People::DefaultParsers::XLSParser < Eco::API::Common::Lo
|
|
34
49
|
|
35
50
|
def rows(target = headers)
|
36
51
|
begin
|
37
|
-
spreadheet.parse(header_search: target)
|
52
|
+
spreadheet.parse(header_search: target, clean: true)
|
38
53
|
rescue Roo::HeaderRowNotFoundError => e
|
39
54
|
missing = JSON.parse(e.message)
|
40
55
|
logger.warn("The input file is missing these headers: #{missing}")
|
@@ -139,6 +139,7 @@ module Eco
|
|
139
139
|
explanation = "Batch TimeOut. You have #{retries_left} retries left."
|
140
140
|
prompt_user(" Do you want to retry (y/N)?", default: "Y", explanation: explanation, timeout: 10) do |response|
|
141
141
|
if response.upcase.start_with?("Y")
|
142
|
+
puts "\nOkay... let's retry!"
|
142
143
|
offer_retry_on(error_type, retries_left - 1, &block)
|
143
144
|
else
|
144
145
|
raise
|
@@ -252,13 +252,14 @@ module Eco
|
|
252
252
|
# - filter out excluded entries from the api update
|
253
253
|
def api_included(full_queue)
|
254
254
|
return full_queue if type == :create
|
255
|
-
return full_queue unless
|
256
|
-
|
257
|
-
|
255
|
+
return full_queue unless excluded_callback = session.config.people.api_excluded
|
256
|
+
excluded = options.dig(:include, :excluded)
|
257
|
+
if excluded.is_a?(Hash) && excluded[:only]
|
258
|
+
full_queue.select {|entry| excluded_callback.call(entry, session, options, self)}
|
258
259
|
elsif options.dig(:include, :excluded)
|
259
260
|
full_queue
|
260
261
|
else
|
261
|
-
full_queue.select {|entry| !
|
262
|
+
full_queue.select {|entry| !excluded_callback.call(entry, session, options, self)}
|
262
263
|
end
|
263
264
|
end
|
264
265
|
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Eco
|
2
|
+
module API
|
3
|
+
class UseCases
|
4
|
+
class OozeSamples
|
5
|
+
module Helpers
|
6
|
+
module Shortcuts
|
7
|
+
|
8
|
+
# Offers multiple ways to compare two strings
|
9
|
+
def same_string?(value1, value2, exact: false)
|
10
|
+
case
|
11
|
+
when value1.is_a?(String) && value2.is_a?(String)
|
12
|
+
if exact
|
13
|
+
value1 == value2
|
14
|
+
else
|
15
|
+
value1.to_s.strip.downcase == value2.to_s.strip.downcase
|
16
|
+
end
|
17
|
+
when value1.is_a?(Regexp) && value2.is_a?(String)
|
18
|
+
value2 =~ value1
|
19
|
+
when value1.is_a?(String) && value2.is_a?(Regexp)
|
20
|
+
value1 =~ value2
|
21
|
+
else
|
22
|
+
value1 == value2
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def titleize(str)
|
27
|
+
return nil unless str
|
28
|
+
return str if str.strip.empty?
|
29
|
+
str.split(/\s+/).map do |part|
|
30
|
+
part[0] = part[0].upcase
|
31
|
+
part[1..-1] = part[1..-1].downcase
|
32
|
+
part
|
33
|
+
end.join(" ")
|
34
|
+
end
|
35
|
+
|
36
|
+
def normalize_string(str)
|
37
|
+
return nil unless str
|
38
|
+
str.gsub(/[^[:print:]]/, '')
|
39
|
+
.gsub(/[[:space:]]+/, ' ')
|
40
|
+
.gsub(/[[:space:]]$/, '')
|
41
|
+
.gsub(/[-\u2011\u2012\u2013]/, '-').yield_self do |str|
|
42
|
+
str = yield(str) if block_given?
|
43
|
+
str
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def clean_question(str)
|
48
|
+
return nil unless str
|
49
|
+
normalize_string(str) do |str|
|
50
|
+
str.gsub(/\r\n/, ' ').yield_self do |str|
|
51
|
+
str = yield(str) if block_given?
|
52
|
+
str
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'docx'
|
2
|
+
# Use case to abstract FORM from word document
|
3
|
+
class Eco::API::UseCases::OozeSamples::OozeFromDocCase < Eco::API::UseCases::OozeSamples::OozeUpdateCase
|
4
|
+
name "ooze-forms-case"
|
5
|
+
type :other
|
6
|
+
|
7
|
+
def main(session, options, usecase)
|
8
|
+
raise "You need to inherit from this class and call super with a block" unless block_given?
|
9
|
+
super(session, options, usecase) do
|
10
|
+
yield
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def with_column(num = 0)
|
17
|
+
with_tables do |table, i|
|
18
|
+
raise "Column num (#{num}) is to big. Table '#{i}' only has #{table.column_count} columns." if table.column_count < num
|
19
|
+
table.columns[num].cells.each_with_index do |cell_row, j|
|
20
|
+
txt = normalize_string(cell_row.text)
|
21
|
+
yield(txt, i, j, table, cell_row)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def with_tables
|
27
|
+
raise "There are no tables in the doc" unless table_count > 0
|
28
|
+
i = 0
|
29
|
+
doc.tables.each do |table|
|
30
|
+
yield(table, i) if block_given?
|
31
|
+
i += 1
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def table_count
|
36
|
+
doc.tables.count
|
37
|
+
end
|
38
|
+
|
39
|
+
def tables?
|
40
|
+
table_count > 0
|
41
|
+
end
|
42
|
+
|
43
|
+
def doc
|
44
|
+
@doc ||= Docx::Document.open(input_file)
|
45
|
+
end
|
46
|
+
|
47
|
+
def input_file
|
48
|
+
options.dig(:source, :file)
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,132 @@
|
|
1
|
+
class Eco::API::UseCases::OozeSamples::OozeRunBaseCase < Eco::API::Common::Loaders::UseCase
|
2
|
+
name "ooze-run-base"
|
3
|
+
type :other
|
4
|
+
|
5
|
+
attr_reader :session, :options, :usecase
|
6
|
+
|
7
|
+
SAVE_PATCH = "ooze_patch_update.json"
|
8
|
+
|
9
|
+
def main(session, options, usecase)
|
10
|
+
raise "You need to inherit from this class and call super with a block" unless block_given?
|
11
|
+
@session = session; @options = options; @usecase = usecase
|
12
|
+
yield
|
13
|
+
end_script!
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def end_script!
|
19
|
+
exit_if_no_changes!
|
20
|
+
backup_patch!
|
21
|
+
launch_request unless options[:simulate]
|
22
|
+
exit(0)
|
23
|
+
end
|
24
|
+
|
25
|
+
def ooze_id
|
26
|
+
options.dig(:source, :ooze_id)
|
27
|
+
end
|
28
|
+
|
29
|
+
def stage_id
|
30
|
+
options.dig(:source, :stage_id)
|
31
|
+
end
|
32
|
+
|
33
|
+
def target
|
34
|
+
@target ||= ooze
|
35
|
+
end
|
36
|
+
|
37
|
+
def new_target(object)
|
38
|
+
if @target && patch_doc["page"]
|
39
|
+
logger.warn "You you are switching to a new target #{object_reference(object)} after doing unsaved changes to #{object_reference(@target)}"
|
40
|
+
end
|
41
|
+
@target = object
|
42
|
+
end
|
43
|
+
|
44
|
+
def stage(id_name = stage_id)
|
45
|
+
if stg = ooze.stages[id_name] || ooze.stages.get_by_name(id_name)
|
46
|
+
return apiv2.pages.get(ooze_id, stage_id: stg.id).tap do |stage|
|
47
|
+
if stage
|
48
|
+
new_target(stage)
|
49
|
+
logger.info("Got #{object_reference(stage)} from #{object_reference(ooze)}")
|
50
|
+
else
|
51
|
+
logger.error("Could not get stage '#{id_name}' in ooze '#{ooze_id}'")
|
52
|
+
exit(1)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
raise "Stage '#{id_name}' doesn't exist in ooze '#{ooze_id}'"
|
57
|
+
end
|
58
|
+
|
59
|
+
def ooze
|
60
|
+
@ooze ||= apiv2.pages.get(ooze_id, stage_id: stage_id).tap do |ooze|
|
61
|
+
if ooze
|
62
|
+
new_target(ooze)
|
63
|
+
logger.info("Got #{object_reference(ooze)}")
|
64
|
+
else
|
65
|
+
logger.error("Could not get ooze '#{ooze_id}'")
|
66
|
+
exit(1)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def launch_request
|
72
|
+
prompt_to_confirm!
|
73
|
+
|
74
|
+
apiv2.pages.update(target).tap do |response|
|
75
|
+
if response.success?
|
76
|
+
logger.info("All went OK")
|
77
|
+
else
|
78
|
+
logger.error(response.body)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def exit_if_no_changes!
|
84
|
+
unless changes = !!patch_doc["page"]
|
85
|
+
logger.warn "No Changes!!"
|
86
|
+
exit(0)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def apiv2
|
91
|
+
@apiv2 ||= session.api(version: :oozes)
|
92
|
+
end
|
93
|
+
|
94
|
+
def patch_doc
|
95
|
+
apiv2.pages.get_body(target)
|
96
|
+
end
|
97
|
+
|
98
|
+
def backup_patch!
|
99
|
+
# store the request
|
100
|
+
File.open(SAVE_PATCH, "w") do |file|
|
101
|
+
#file << (patch_doc || {}).to_json
|
102
|
+
file << JSON.pretty_generate(patch_doc || {})
|
103
|
+
end
|
104
|
+
puts "Saved patch at: #{File.expand_path(SAVE_PATCH)}"
|
105
|
+
end
|
106
|
+
|
107
|
+
def object_reference(obj)
|
108
|
+
return "No reference" unless obj
|
109
|
+
"".tap do |ref|
|
110
|
+
case obj
|
111
|
+
when Ecoportal::API::V2::Page::Stage
|
112
|
+
ref << "Stage "
|
113
|
+
when Ecoportal::API::V2::Pages::PageStage
|
114
|
+
ref << "StagePage "
|
115
|
+
when Ecoportal::API::V2::Page
|
116
|
+
ref << "Page "
|
117
|
+
end
|
118
|
+
ref << "'#{obj.name}' " if obj.respond_to?(:name)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def prompt_to_confirm!
|
123
|
+
micro.prompt_user("Do you want to proceed (y/N)?", default: "Y") do |response|
|
124
|
+
exit(1) unless response.upcase.start_with?("Y")
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
def logger
|
129
|
+
session.logger
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
@@ -1,132 +1,63 @@
|
|
1
|
-
class Eco::API::UseCases::OozeSamples::OozeUpdateCase < Eco::API::
|
1
|
+
class Eco::API::UseCases::OozeSamples::OozeUpdateCase < Eco::API::UseCases::OozeSamples::OozeRunBaseCase
|
2
2
|
name "single-ooze-case"
|
3
3
|
type :other
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
SAVE_PATCH = "ooze_patch_update.json"
|
5
|
+
include Eco::API::UseCases::OozeSamples::Helpers
|
8
6
|
|
9
7
|
def main(session, options, usecase)
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
|
17
|
-
def end_script!
|
18
|
-
exit_if_no_changes!
|
19
|
-
backup_patch!
|
20
|
-
launch_request unless options[:simulate]
|
21
|
-
exit(0)
|
22
|
-
end
|
23
|
-
|
24
|
-
def ooze_id
|
25
|
-
options.dig(:source, :ooze_id)
|
26
|
-
end
|
27
|
-
|
28
|
-
def stage_id
|
29
|
-
options.dig(:source, :stage_id)
|
30
|
-
end
|
31
|
-
|
32
|
-
def stage(id_name = stage_id)
|
33
|
-
if stg = ooze.stages[id_name] || ooze.stages.get_by_name(id_name)
|
34
|
-
return apiv2.pages.get(ooze_id, stage_id: stg.id).tap do |stage|
|
35
|
-
if stage
|
36
|
-
new_target(stage)
|
37
|
-
logger.info("Got #{object_reference(stage)} from #{object_reference(ooze)}")
|
38
|
-
else
|
39
|
-
logger.error("Could not get stage '#{id_name}' in ooze '#{ooze_id}'")
|
40
|
-
exit(1)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
raise "Stage '#{id_name}' doesn't exist in ooze '#{ooze_id}'"
|
45
|
-
end
|
46
|
-
|
47
|
-
def ooze
|
48
|
-
@ooze ||= apiv2.pages.get(ooze_id).tap do |ooze|
|
49
|
-
if ooze
|
50
|
-
new_target(ooze)
|
51
|
-
logger.info("Got #{object_reference(ooze)}")
|
52
|
-
else
|
53
|
-
logger.error("Could not get ooze '#{ooze_id}'")
|
54
|
-
exit(1)
|
55
|
-
end
|
8
|
+
raise "You need to inherit from this class and call super with a block" unless block_given?
|
9
|
+
super(session, options, usecase) do
|
10
|
+
yield
|
56
11
|
end
|
57
12
|
end
|
58
13
|
|
59
|
-
|
60
|
-
prompt_to_confirm!
|
14
|
+
private
|
61
15
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
16
|
+
def with_fields(type: nil, label: nil)
|
17
|
+
flds = target.components
|
18
|
+
flds = flds.get_by_type(type) if type
|
19
|
+
flds = flds.select do |fld|
|
20
|
+
value = (label == :unnamed) ? nil : label
|
21
|
+
!label || same_string?(fld.label, value)
|
22
|
+
end.each do |field|
|
23
|
+
yield(field) if block_given?
|
68
24
|
end
|
69
25
|
end
|
70
26
|
|
71
|
-
def
|
72
|
-
|
73
|
-
|
74
|
-
|
27
|
+
def with_sections(type: nil, heading: nil)
|
28
|
+
secs = target.sections
|
29
|
+
secs = secs.get_by_type(type) if type
|
30
|
+
secs = secs.select do |sec|
|
31
|
+
value = (heading == :unnamed) ? nil : heading
|
32
|
+
!heading || same_string?(sec.heading, value)
|
33
|
+
end.each do |sec|
|
34
|
+
yield(sec) if block_given?
|
75
35
|
end
|
76
36
|
end
|
77
37
|
|
78
|
-
def
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
def target
|
83
|
-
@target
|
84
|
-
end
|
85
|
-
|
86
|
-
def new_target(object)
|
87
|
-
if @target && patch_doc["page"]
|
88
|
-
logger.warn "You you are switching to a new target #{object_reference(object)} after doing unsaved changes to #{object_reference(@target)}"
|
38
|
+
def with_stage(name:)
|
39
|
+
if stage = target.stages.get_by_name(name)
|
40
|
+
yield(stage) if block_given?
|
89
41
|
end
|
90
|
-
|
42
|
+
stage
|
91
43
|
end
|
92
44
|
|
93
|
-
def
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
when Ecoportal::API::V2::Pages::PageStage
|
100
|
-
ref << "StagePage "
|
101
|
-
when Ecoportal::API::V2::Page
|
102
|
-
ref << "Page "
|
103
|
-
end
|
104
|
-
ref << "'#{obj.name}' " if obj.respond_to?(:name)
|
45
|
+
def add_field(name, type, section, after: nil, side: :left)
|
46
|
+
raise "You need to specify a section for a new field. Given: #{section.class}" unless section.is_a?(Ecoportal::API::V2::Page::Section)
|
47
|
+
target.components.add(label: name, type: type) do |field|
|
48
|
+
section.add_component(field, after: after, side: side)
|
49
|
+
end.tap do |field|
|
50
|
+
yield(field) if block_given?
|
105
51
|
end
|
106
52
|
end
|
107
53
|
|
108
|
-
|
109
|
-
|
110
|
-
|
54
|
+
def to_field(value)
|
55
|
+
fld = nil
|
56
|
+
fld ||= value if value.is_a?(Ecoportal::API::V2::Page::Component)
|
57
|
+
fld ||= target.components.get_by_id(value)
|
58
|
+
fld ||= target.components.select {|fld| same_name?(fld.label, value)}
|
59
|
+
#fld ||= value.reference if value.is_a?(Ecoportal::API::V2::Page::Force::Binding)
|
111
60
|
end
|
112
61
|
|
113
|
-
def backup_patch!
|
114
|
-
# store the request
|
115
|
-
File.open(SAVE_PATCH, "w") do |file|
|
116
|
-
#file << (patch_doc || {}).to_json
|
117
|
-
file << JSON.pretty_generate(patch_doc || {})
|
118
|
-
end
|
119
|
-
puts "Saved patch at: #{File.expand_path(SAVE_PATCH)}"
|
120
|
-
end
|
121
|
-
|
122
|
-
def logger
|
123
|
-
session.logger
|
124
|
-
end
|
125
|
-
|
126
|
-
def prompt_to_confirm!
|
127
|
-
prompt_user("Do you want to proceed (y/N)?", default: "Y") do |response|
|
128
|
-
exit(1) unless response.upcase.start_with?("Y")
|
129
|
-
end
|
130
|
-
end
|
131
62
|
|
132
63
|
end
|
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.33
|
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.9
|
140
140
|
- - "<"
|
141
141
|
- !ruby/object:Gem::Version
|
142
142
|
version: '0.9'
|
@@ -146,7 +146,7 @@ dependencies:
|
|
146
146
|
requirements:
|
147
147
|
- - ">="
|
148
148
|
- !ruby/object:Gem::Version
|
149
|
-
version: 0.8.
|
149
|
+
version: 0.8.9
|
150
150
|
- - "<"
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0.9'
|
@@ -350,6 +350,26 @@ dependencies:
|
|
350
350
|
- - "<"
|
351
351
|
- !ruby/object:Gem::Version
|
352
352
|
version: '1.3'
|
353
|
+
- !ruby/object:Gem::Dependency
|
354
|
+
name: docx
|
355
|
+
requirement: !ruby/object:Gem::Requirement
|
356
|
+
requirements:
|
357
|
+
- - ">="
|
358
|
+
- !ruby/object:Gem::Version
|
359
|
+
version: 0.6.2
|
360
|
+
- - "<"
|
361
|
+
- !ruby/object:Gem::Version
|
362
|
+
version: '0.7'
|
363
|
+
type: :runtime
|
364
|
+
prerelease: false
|
365
|
+
version_requirements: !ruby/object:Gem::Requirement
|
366
|
+
requirements:
|
367
|
+
- - ">="
|
368
|
+
- !ruby/object:Gem::Version
|
369
|
+
version: 0.6.2
|
370
|
+
- - "<"
|
371
|
+
- !ruby/object:Gem::Version
|
372
|
+
version: '0.7'
|
353
373
|
description:
|
354
374
|
email:
|
355
375
|
- oscar@ecoportal.co.nz
|
@@ -537,6 +557,10 @@ files:
|
|
537
557
|
- lib/eco/api/usecases/default_cases/update_details_case.rb
|
538
558
|
- lib/eco/api/usecases/default_cases/upsert_case.rb
|
539
559
|
- lib/eco/api/usecases/ooze_samples.rb
|
560
|
+
- lib/eco/api/usecases/ooze_samples/helpers.rb
|
561
|
+
- lib/eco/api/usecases/ooze_samples/helpers/shortcuts.rb
|
562
|
+
- lib/eco/api/usecases/ooze_samples/ooze_from_doc_case.rb
|
563
|
+
- lib/eco/api/usecases/ooze_samples/ooze_run_base_case.rb
|
540
564
|
- lib/eco/api/usecases/ooze_samples/ooze_update_case.rb
|
541
565
|
- lib/eco/api/usecases/use_case.rb
|
542
566
|
- lib/eco/api/usecases/use_case_chain.rb
|