eco-helpers 1.5.15 → 2.0.6

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: 71bf87e88b7a707a7684879b5462db11da003360d353d513005d169e77eaa033
4
- data.tar.gz: 53fe5d42e0be580d0903ddd72e02b014ca113daafe8b37d073481a769deceb7f
3
+ metadata.gz: 402f80f7e80fd4ecc9a97a9e96a0823ab4e26d63541540e14774db2dbf97ef60
4
+ data.tar.gz: 3d097ed8af5c5e1c0ecacb227b0a77e4f1d6d8bb15e77599a008aa1af361b230
5
5
  SHA512:
6
- metadata.gz: 36db363c1aef9dac9f5fe0ca874c5d6e8dd39c89fbc7326fc66975ac12b5282288d6ba6c1449aea457c9831aacfbfe0529a53490389fc72f1f0ede956e35b9eb
7
- data.tar.gz: 17ca4ae2ce8acde161e94f203eb643d405d33210972eec1bbbc3598f50f7b7015a94f9a81c50d64bafb0a42c9066464d421f6eb491e15a17c531753aa64ff59c
6
+ metadata.gz: c083c3f62d2f29c427f56a2b34b11e4cd238198a95e728e1afeaa4345ccab4c507b798b10427adca14c547161d210d0662d4ece666b67d6464052992d0cade62
7
+ data.tar.gz: 840bf5e3b90b3a9398a2eb2c5dc989e1ad321705d0785d5cb0b89a696756a721b2e66804a7a3fe7adc82f76611a58fba7379131c994312b01c2d576c93339df0
data/CHANGELOG.md CHANGED
@@ -1,7 +1,57 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
- ## [1.5.15] - 2021-02-xx
4
+ ## [2.0.6] - 2021-02-xx
5
+
6
+ ### Added
7
+ ### Changed
8
+ - `Eco::API::Session::Batch:Errors` moved some methods to be private
9
+ ### Fixed
10
+ - `Eco::API::Error` should inherit from `StandardError`, rather than from `Exception`
11
+
12
+ ## [2.0.5] - 2021-02-24
13
+
14
+ ### Added
15
+ ### Changed
16
+ ### Fixed
17
+ - `Eco::API::Common::People::PersonParser#symbol_keys` to use `Array#select`
18
+ - as `Array#filter` was introduced in ruby `2.5.5`
19
+
20
+ ## [2.0.4] - 2021-02-23
21
+
22
+ ### Added
23
+ ### Changed
24
+ - `Eco::API::Common::People::PersonParser#defined_attrs` to include virtual attributes
25
+
26
+ ### Fixed
27
+
28
+ ## [2.0.3] - 2021-02-23
29
+
30
+ ### Added
31
+ - `Eco::API::UseCases::OozeSamples::OozeUpdateCase`: added integration to update page instances (non-templates)
32
+
33
+ ### Changed
34
+ ### Fixed
35
+ - `Eco::API::Policies::DefaultPolicies::UserAccess` complete default policy code.
36
+
37
+ ## [2.0.2] - 2021-02-22
38
+
39
+ ### Added
40
+ ### Changed
41
+ - upgraded dependencies with `ecoportal-api`
42
+
43
+ ### Fixed
44
+
45
+
46
+ ## [2.0.1] - 2021-02-22
47
+
48
+ ### Added
49
+ ### Changed
50
+ - upgraded dependencies with `ecoportal-api-oozes` to `ecoportal-api-v2`
51
+
52
+ ### Fixed
53
+
54
+ ## [1.5.15] - 2021-02-17
5
55
 
6
56
  ### Added
7
57
  - `Eco::API::Common::ClassHelpers` added support for class methods inheritance
data/eco-helpers.gemspec CHANGED
@@ -3,37 +3,39 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  require "./lib/eco/version"
5
5
 
6
- Gem::Specification.new do |s|
7
- s.name = "eco-helpers"
8
- s.version = Eco::VERSION
9
- s.platform = Gem::Platform::RUBY
10
- s.authors = ["Oscar Segura"]
11
- s.email = ["oscar@ecoportal.co.nz"]
12
- s.date = %q{2018-09-05}
13
- s.summary = %q{eco-helpers to manage people api cases}
14
- s.homepage = "https://www.ecoportal.com"
15
- s.licenses = %w[MIT]
16
- s.required_ruby_version = '>= 2.4.4'
17
-
18
- s.files = `git ls-files -z`.split("\x0").reject do |f|
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "eco-helpers"
8
+ spec.version = Eco::VERSION
9
+ spec.platform = Gem::Platform::RUBY
10
+ spec.authors = ["Oscar Segura"]
11
+ spec.email = ["oscar@ecoportal.co.nz"]
12
+ spec.date = %q{2018-09-05}
13
+ spec.summary = %q{eco-helpers to manage people api cases}
14
+ spec.homepage = "https://www.ecoportal.com"
15
+ spec.licenses = %w[MIT]
16
+
17
+ spec.required_ruby_version = '>= 2.4.4'
18
+
19
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
19
20
  f.match(%r{^(test|spec|features)/})
20
21
  end
21
22
 
22
- #s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
23
- #s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
24
- s.require_paths = ["lib"]
25
-
26
- s.add_development_dependency "bundler", ">= 2.1.3", "< 2.2"
27
- s.add_development_dependency "rspec", ">= 3.9", "< 4"
28
- s.add_development_dependency "rake", ">= 12.3.0", "< 13"
29
- s.add_development_dependency "yard", ">= 0.9.18", "< 0.10"
30
- s.add_development_dependency "redcarpet", ">= 3.5.0", "< 3.6"
31
-
32
- s.add_dependency 'ecoportal-api', '>= 0.7.4', '< 0.8'
33
- s.add_dependency 'ecoportal-api-oozes', '>= 0.7.3', '< 0.8'
34
- s.add_dependency 'aws-sdk-s3', '>= 1.64.0', '< 2'
35
- s.add_dependency 'aws-sdk-ses', '>= 1.29.0', '< 2'
36
- s.add_dependency 'dotenv', '>= 2.7.0', '< 2.8'
37
- s.add_dependency 'net-sftp', '>= 2.1.2', '< 2.2'
23
+ #spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
24
+ #spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
25
+ spec.require_paths = ["lib"]
26
+
27
+ spec.add_development_dependency "bundler", ">= 2.2.11", "< 2.3"
28
+ spec.add_development_dependency "rspec", ">= 3.10.0", "< 3.11"
29
+ spec.add_development_dependency "rake", ">= 13.0.3", "< 13.1"
30
+ spec.add_development_dependency "yard", ">= 0.9.26", "< 0.10"
31
+ spec.add_development_dependency "redcarpet", ">= 3.5.1", "< 3.6"
32
+
33
+ spec.add_dependency 'ecoportal-api', '>= 0.8.2', '< 0.9'
34
+ #spec.add_dependency 'ecoportal-api', '>= 0.7.5', '< 0.8'
35
+ spec.add_dependency 'ecoportal-api-v2', '>= 0.8.6', '< 0.9'
36
+ spec.add_dependency 'aws-sdk-s3', '>= 1.83.0', '< 2'
37
+ spec.add_dependency 'aws-sdk-ses', '>= 1.36.0', '< 2'
38
+ spec.add_dependency 'dotenv', '>= 2.7.6', '< 2.8'
39
+ spec.add_dependency 'net-sftp', '>= 3.0.0', '< 3.1'
38
40
 
39
41
  end
data/lib/eco/api.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'ecoportal/api'
2
- require 'ecoportal/api-oozes'
2
+ require 'ecoportal/api-v2'
3
3
 
4
4
  module Eco
5
5
  module API
@@ -99,9 +99,16 @@ module Eco
99
99
  # - the list is sorted according `CORE_ATTRS` + `ACCOUNT_ATTRS` + schema attrs
100
100
  # @return [Array<String>] list of all attribute defined parsers.
101
101
  def defined_attrs
102
- defined = @parsers.keys
103
- defined = (all_attrs || defined) && defined
104
- defined - (defined - all_attrs)
102
+ defined = @parsers.keys
103
+ defined = (all_attrs | defined) & defined
104
+ defined - symbol_keys
105
+ end
106
+
107
+ # Symbol keys are type or import parsers (that do not belong to the model)
108
+ # @note this was introduced to boost virtual fields to treat in different phases of the parsing process
109
+ # @return [Array<Symbol>] all the parsers defined as Symbol
110
+ def symbol_keys
111
+ @parsers.keys.select {|k| k.is_a?(Symbol)}
105
112
  end
106
113
 
107
114
  # Returns a list of all the internal attributes of the model that have a parser defined & that should be active.
data/lib/eco/api/error.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  module Eco
2
2
  module API
3
3
  # To identify api server errors
4
- class Error < Exception
5
- class UnknownErrorClass < Exception
4
+ class Error < StandardError
5
+ class UnknownErrorClass < StandardError
6
6
  def initialize(msg = nil, klass:)
7
7
  msg ||= "Unkown api error class #{klass}"
8
8
  super(msg)
@@ -1,18 +1,18 @@
1
1
  class Eco::API::Policies::DefaultPolicies::UserAccess < Eco::API::Common::Loaders::Policy
2
2
  name "default-user-access"
3
3
 
4
- attr_reader :session, :options
4
+ attr_reader :session, :options, :job
5
5
  attr_accessor :account_removed_count
6
6
 
7
7
  def main(people, session, options, policy, job)
8
- @session = session; @options = options
8
+ @session = session; @options = options; @job = job
9
9
 
10
10
  self.account_removed_count = 0
11
11
 
12
12
  people.each do |person|
13
- remove_account_when_no_email!(person) if person.email.to_s.empty?
14
- person.account.policy_group_ids = [defid] if no_policy_group_ids?(person)
15
- refresh_abilities!(person.account)
13
+ remove_account_when_no_email!(person) if person.email.to_s.empty?
14
+ person.account.policy_group_ids = defid if no_policy_group_ids?(person)
15
+ refresh_abilities!(person)
16
16
  end
17
17
 
18
18
  warn_account_removal!
@@ -22,14 +22,14 @@ class Eco::API::Policies::DefaultPolicies::UserAccess < Eco::API::Common::Loader
22
22
 
23
23
  def warn_account_removal!
24
24
  if account_removed_count > 0
25
- msg = "Removed account to #{account_removed_count} people"
25
+ msg = "(DefaultPolicy on job '#{job.name}') Removed account to #{account_removed_count} people"
26
26
  session.logger.warn(msg)
27
27
  end
28
28
  end
29
29
 
30
30
  def remove_account_when_no_email!(person)
31
31
  if person.account
32
- account_removed_count += 1 if had_account?(person)
32
+ self.account_removed_count += 1 if had_account?(person)
33
33
  person.account = nil
34
34
  end
35
35
  end
@@ -40,23 +40,11 @@ class Eco::API::Policies::DefaultPolicies::UserAccess < Eco::API::Common::Loader
40
40
  return !!person.original_doc["account"]
41
41
  end
42
42
 
43
- def provision_basic_level!(person)
44
- if account = person.account
45
-
46
- unless options.dig(:exclude, :abilities)
47
- account.permissions_custom = session.new_preset(person)
48
-
49
- if no_abilities?(person)
50
- account.permissions_custom = min_abilities
51
- end
52
- end
53
-
54
- end
55
- end
56
-
57
- def refresh_abilities!(account)
58
- return nil unless account
59
-
43
+ def refresh_abilities!(person)
44
+ return nil if options.dig(:exclude, :abilities)
45
+ return nil unless account = person.account
46
+ account.permissions_custom = session.new_preset(person)
47
+ account.permissions_custom = min_abilities if no_abilities?(person)
60
48
  end
61
49
 
62
50
  def no_policy_group_ids?(person)
@@ -64,8 +52,8 @@ class Eco::API::Policies::DefaultPolicies::UserAccess < Eco::API::Common::Loader
64
52
  end
65
53
 
66
54
  def no_abilities?(person)
67
- person.account.permissions_custom &&
68
- person.account.permissions_custom.values.all?(&:nil?)
55
+ return true unless account = person.account
56
+ account.permissions_custom && account.permissions_custom.values.all?(&:nil?)
69
57
  end
70
58
 
71
59
  def min_abilities
@@ -86,7 +74,7 @@ class Eco::API::Policies::DefaultPolicies::UserAccess < Eco::API::Common::Loader
86
74
  end
87
75
 
88
76
  def defid
89
- @defid ||= policy_groups.to_id(default_group)
77
+ @defid ||= policy_groups.to_id([default_group]).compact
90
78
  end
91
79
 
92
80
  def default_group
@@ -88,10 +88,7 @@ module Eco
88
88
 
89
89
  def get(params: {}, silent: false)
90
90
  fatal "cannot batch get without api connnection, please provide a valid api connection!" unless people_api = api&.people
91
-
92
91
  params = {per_page: DEFAULT_BATCH_BLOCK}.merge(params)
93
- client = people_api.client
94
-
95
92
  return people_api.get_all(params: params, silent: silent)
96
93
  end
97
94
 
@@ -8,6 +8,8 @@ module Eco
8
8
  # @attr_reader status [Eco::API::Session::Batch::Status] `batch status` this `Errors` object is associated to.
9
9
  attr_reader :status
10
10
 
11
+ ErrorCache = Struct.new(:type, :err, :entry)
12
+
11
13
  # @param status [Eco::API::Session::Batch::Status] `batch status` this `Errors` object is associated to.
12
14
  def initialize(status:)
13
15
  "Expected Batch::Status as root. Given: #{status.class}" unless status.is_a?(Eco::API::Session::Batch::Status)
@@ -55,29 +57,6 @@ module Eco
55
57
  entries.length
56
58
  end
57
59
 
58
- # Input entries that got **error** response from the _Server_.
59
- # @raise [Exception] if there are elements of the final `queue` that did not get response
60
- # @note discards those that did not get _response_ from the Server (so those that were not queried)
61
- # - please, observe that this can only happen if there were repeated entries in the `source_queue`
62
- # @return [Array<Hash>, Array<Ecoportal::API::V1::Person>, Array<Ecoportal::API::Internal::Person>]
63
- def entries
64
- queue.each_with_index.map do |query, i|
65
- unless response = status[i]
66
- msg = "Error: query with no response. You might have duplicated entries in your queue.\n"
67
- msg += "Queue length: #{queue.length}; Queue elements class: #{queue.first.class}\n"
68
- msg += "Query with no response. Person: #{person_ref(query)}\n"
69
- queue.map do |entry|
70
- if [:id, :external_id, :email].any? {|attr| (v = get_attr(entry, attr)) && v == get_attr(query, attr)}
71
- msg += "It could be this peson entry (idx: #{to_index(entry)}): #{person_ref(entry)}\n"
72
- end
73
- end
74
- raise msg
75
- end
76
-
77
- response.success?? nil : query
78
- end.compact
79
- end
80
-
81
60
  # For all the `entries` with errors generates a `Hash` object
82
61
  # @return [Array<Hash>] where each `Hash` has
83
62
  # 1. `:type` -> the error type
@@ -88,11 +67,11 @@ module Eco
88
67
  if body = status[entry].body
89
68
  if errs = body["errors"]
90
69
  errs.each do |msg|
91
- arr.push({
92
- type: klass = Eco::API::Error.get_type(msg),
93
- err: klass.new(err_msg: msg, entry: entry, session: session),
94
- entry: entry
95
- })
70
+ arr.push(ErrorCache.new(
71
+ klass = Eco::API::Error.get_type(msg),
72
+ klass.new(err_msg: msg, entry: entry, session: session),
73
+ entry
74
+ ))
96
75
  end
97
76
  end
98
77
  end
@@ -103,45 +82,16 @@ module Eco
103
82
  # @return [Hash] where each `key` is a `type` **error** and each value is
104
83
  # an `Array` of `entries` that got that error
105
84
  def by_type
106
- errors.group_by do |h|
107
- h[:type]
85
+ errors.group_by do |e|
86
+ e.type
108
87
  end.transform_values do |arr|
109
- arr.map {|h| h[:entry]}
88
+ arr.map {|e| e.entry}
110
89
  end
111
90
  end
112
91
  # @!endgroup
113
92
 
114
93
  # @!group Messaging methods
115
94
 
116
- # Generates a `String` specifying the error for the entry `key`.
117
- # @param key [Integer, Ecoportal::API::V1::Person]
118
- # @return [String] the error description.
119
- def str(key)
120
- msg = ""
121
- unless status.success?(key)
122
- i = to_index(key)
123
- entry = queue.to_a[i]
124
- response = status[i]
125
- msg = "Error #{response.status}: #{response.body}\n"
126
- msg += "-- Failed to batch #{method}. Person: #{person_ref(entry)}"
127
- end
128
- msg
129
- end
130
-
131
- # Sorts the entries that got server error by error `type` and generates the error messages.
132
- # @return [Array<String>] the errors messages.
133
- def strs
134
- by_type.values.flatten(1).each_with_object([]) do |query, msgs|
135
- msgs.push(str(query))
136
- end
137
- end
138
-
139
- def print_one(key)
140
- unless status.success?(key)
141
- logger.error(str(key))
142
- end
143
- end
144
-
145
95
  def message
146
96
  msgs = strs
147
97
  if msgs.length > 0
@@ -163,6 +113,29 @@ module Eco
163
113
 
164
114
  private
165
115
 
116
+ # Input entries that got **error** response from the _Server_.
117
+ # @raise [Exception] if there are elements of the final `queue` that did not get response
118
+ # @note discards those that did not get _response_ from the Server (so those that were not queried)
119
+ # - please, observe that this can only happen if there were repeated entries in the `source_queue`
120
+ # @return [Array<Hash>, Array<Ecoportal::API::V1::Person>, Array<Ecoportal::API::Internal::Person>]
121
+ def entries
122
+ queue.filter.with_index do |query, i|
123
+ unless response = status[i]
124
+ msg = "Error: query with no response. You might have duplicated entries in your queue.\n"
125
+ msg += "Queue length: #{queue.length}; Queue elements class: #{queue.first.class}\n"
126
+ msg += "Query with no response. Person: #{person_ref(query)}\n"
127
+ queue.map do |entry|
128
+ if [:id, :external_id, :email].any? {|attr| (v = get_attr(entry, attr)) && v == get_attr(query, attr)}
129
+ msg += "It could be this peson entry (idx: #{to_index(entry)}): #{person_ref(entry)}\n"
130
+ end
131
+ end
132
+ raise msg
133
+ end
134
+
135
+ !response.success?
136
+ end
137
+ end
138
+
166
139
  def person_ref(entry)
167
140
  row_str = (row = get_row(entry)) ? "(row: #{row}) " : nil
168
141
  "#{row_str}(id: '#{get_attr(entry, :id)}') '#{get_attr(entry, :name)}' ('#{get_attr(entry, :external_id)}': '#{get_attr(entry, :email)}')"
@@ -185,6 +158,35 @@ module Eco
185
158
  end
186
159
  end
187
160
 
161
+ # Sorts the entries that got server error by error `type` and generates the error messages.
162
+ # @return [Array<String>] the errors messages.
163
+ def strs
164
+ by_type.values.flatten(1).each_with_object([]) do |query, msgs|
165
+ msgs.push(str(query))
166
+ end
167
+ end
168
+
169
+ # Generates a `String` specifying the error for the entry `key`.
170
+ # @param key [Integer, Ecoportal::API::V1::Person]
171
+ # @return [String] the error description.
172
+ def str(key)
173
+ msg = ""
174
+ unless status.success?(key)
175
+ i = to_index(key)
176
+ entry = queue.to_a[i]
177
+ response = status[i]
178
+ msg = "Error #{response.status}: #{response.body}\n"
179
+ msg += "-- Failed to batch #{method}. Person: #{person_ref(entry)}"
180
+ end
181
+ msg
182
+ end
183
+
184
+ def print_one(key)
185
+ unless status.success?(key)
186
+ logger.error(str(key))
187
+ end
188
+ end
189
+
188
190
  end
189
191
  end
190
192
  end
@@ -212,6 +212,13 @@ module Eco
212
212
 
213
213
  private
214
214
 
215
+ def subjobs_summary
216
+ return "" unless subjobs.count > 0
217
+ [].tap do |msg|
218
+ subjobs.map {|subjob| msg << subjob.summary}
219
+ end.join("\n")
220
+ end
221
+
215
222
  def as_update(*args)
216
223
  feedback.as_update(*args)
217
224
  end
@@ -310,13 +317,6 @@ module Eco
310
317
  end
311
318
  end
312
319
 
313
- def subjobs_summary
314
- return "" unless subjobs.count > 0
315
- [].tap do |msg|
316
- subjobs.map {|subjob| msg << subjob.summary}
317
- end.join("\n")
318
- end
319
-
320
320
  end
321
321
  end
322
322
  end
@@ -122,7 +122,9 @@ module Eco
122
122
  def valid_index(index: nil, entry: nil)
123
123
  index ||= @hash[entry]
124
124
  unless index && index < @queue.length
125
- fatal "You must provide either the index on the final 'queue' or the original entry object of the batch"
125
+ msg = "You must provide either the index on the final 'queue' or the original entry object of the batch. "
126
+ msg += "Given, index=#{index.class}, entry:#{entry.class}"
127
+ fatal msg
126
128
  end
127
129
  index
128
130
  end
@@ -195,6 +195,7 @@ module Eco
195
195
  # @yieldreturn [Eco::API::UseCases::BaseIO] the `io` input/output object carried througout all the _workflow_
196
196
  # @return [Eco::API::Session::Config::Workflow] the current stage object (to ease chainig).
197
197
  def run(key = nil, io:, &block)
198
+ raise "Missing BaseIO object" unless io.is_a?(Eco::API::UseCases::BaseIO)
198
199
  begin
199
200
  if key
200
201
  io = stage(key).run(io: io, &block)
@@ -25,10 +25,30 @@ class Eco::API::UseCases::OozeSamples::OozeUpdateCase < Eco::API::Common::Loader
25
25
  options.dig(:source, :ooze_id)
26
26
  end
27
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
+
28
47
  def ooze
29
48
  @ooze ||= apiv2.pages.get(ooze_id).tap do |ooze|
30
49
  if ooze
31
- logger.info("Got ooze '#{ooze_id}': '#{ooze.name}'")
50
+ new_target(ooze)
51
+ logger.info("Got #{object_reference(ooze)}")
32
52
  else
33
53
  logger.error("Could not get ooze '#{ooze_id}'")
34
54
  exit(1)
@@ -39,7 +59,7 @@ class Eco::API::UseCases::OozeSamples::OozeUpdateCase < Eco::API::Common::Loader
39
59
  def launch_request
40
60
  prompt_to_confirm!
41
61
 
42
- apiv2.pages.update(ooze).tap do |response|
62
+ apiv2.pages.update(target).tap do |response|
43
63
  if response.success?
44
64
  logger.info("All went OK")
45
65
  else
@@ -59,9 +79,35 @@ class Eco::API::UseCases::OozeSamples::OozeUpdateCase < Eco::API::Common::Loader
59
79
  @apiv2 ||= session.api(version: :oozes)
60
80
  end
61
81
 
62
- def patch_doc(renew: false)
63
- return @patch_doc if @patch_doc && !renew
64
- @patch_doc = apiv2.pages.get_body(ooze)
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)}"
89
+ end
90
+ @target = object
91
+ end
92
+
93
+ def object_reference(obj)
94
+ return "No reference" unless obj
95
+ "".tap do |ref|
96
+ case obj
97
+ when Ecoportal::API::V2::Page::Stage
98
+ ref << "Stage "
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)
105
+ end
106
+ end
107
+
108
+
109
+ def patch_doc
110
+ apiv2.pages.get_body(target)
65
111
  end
66
112
 
67
113
  def backup_patch!
data/lib/eco/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Eco
2
- VERSION = "1.5.15"
2
+ VERSION = "2.0.6"
3
3
  end
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.5.15
4
+ version: 2.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura
@@ -16,67 +16,67 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 2.1.3
19
+ version: 2.2.11
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '2.2'
22
+ version: '2.3'
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.1.3
29
+ version: 2.2.11
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '2.2'
32
+ version: '2.3'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: rspec
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: '3.9'
39
+ version: 3.10.0
40
40
  - - "<"
41
41
  - !ruby/object:Gem::Version
42
- version: '4'
42
+ version: '3.11'
43
43
  type: :development
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: '3.9'
49
+ version: 3.10.0
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
- version: '4'
52
+ version: '3.11'
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: rake
55
55
  requirement: !ruby/object:Gem::Requirement
56
56
  requirements:
57
57
  - - ">="
58
58
  - !ruby/object:Gem::Version
59
- version: 12.3.0
59
+ version: 13.0.3
60
60
  - - "<"
61
61
  - !ruby/object:Gem::Version
62
- version: '13'
62
+ version: '13.1'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - ">="
68
68
  - !ruby/object:Gem::Version
69
- version: 12.3.0
69
+ version: 13.0.3
70
70
  - - "<"
71
71
  - !ruby/object:Gem::Version
72
- version: '13'
72
+ version: '13.1'
73
73
  - !ruby/object:Gem::Dependency
74
74
  name: yard
75
75
  requirement: !ruby/object:Gem::Requirement
76
76
  requirements:
77
77
  - - ">="
78
78
  - !ruby/object:Gem::Version
79
- version: 0.9.18
79
+ version: 0.9.26
80
80
  - - "<"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0.10'
@@ -86,7 +86,7 @@ dependencies:
86
86
  requirements:
87
87
  - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: 0.9.18
89
+ version: 0.9.26
90
90
  - - "<"
91
91
  - !ruby/object:Gem::Version
92
92
  version: '0.10'
@@ -96,7 +96,7 @@ dependencies:
96
96
  requirements:
97
97
  - - ">="
98
98
  - !ruby/object:Gem::Version
99
- version: 3.5.0
99
+ version: 3.5.1
100
100
  - - "<"
101
101
  - !ruby/object:Gem::Version
102
102
  version: '3.6'
@@ -106,7 +106,7 @@ dependencies:
106
106
  requirements:
107
107
  - - ">="
108
108
  - !ruby/object:Gem::Version
109
- version: 3.5.0
109
+ version: 3.5.1
110
110
  - - "<"
111
111
  - !ruby/object:Gem::Version
112
112
  version: '3.6'
@@ -116,47 +116,47 @@ dependencies:
116
116
  requirements:
117
117
  - - ">="
118
118
  - !ruby/object:Gem::Version
119
- version: 0.7.4
119
+ version: 0.8.2
120
120
  - - "<"
121
121
  - !ruby/object:Gem::Version
122
- version: '0.8'
122
+ version: '0.9'
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.7.4
129
+ version: 0.8.2
130
130
  - - "<"
131
131
  - !ruby/object:Gem::Version
132
- version: '0.8'
132
+ version: '0.9'
133
133
  - !ruby/object:Gem::Dependency
134
- name: ecoportal-api-oozes
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: 0.7.3
139
+ version: 0.8.6
140
140
  - - "<"
141
141
  - !ruby/object:Gem::Version
142
- version: '0.8'
142
+ version: '0.9'
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: 0.7.3
149
+ version: 0.8.6
150
150
  - - "<"
151
151
  - !ruby/object:Gem::Version
152
- version: '0.8'
152
+ version: '0.9'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: aws-sdk-s3
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - ">="
158
158
  - !ruby/object:Gem::Version
159
- version: 1.64.0
159
+ version: 1.83.0
160
160
  - - "<"
161
161
  - !ruby/object:Gem::Version
162
162
  version: '2'
@@ -166,7 +166,7 @@ dependencies:
166
166
  requirements:
167
167
  - - ">="
168
168
  - !ruby/object:Gem::Version
169
- version: 1.64.0
169
+ version: 1.83.0
170
170
  - - "<"
171
171
  - !ruby/object:Gem::Version
172
172
  version: '2'
@@ -176,7 +176,7 @@ dependencies:
176
176
  requirements:
177
177
  - - ">="
178
178
  - !ruby/object:Gem::Version
179
- version: 1.29.0
179
+ version: 1.36.0
180
180
  - - "<"
181
181
  - !ruby/object:Gem::Version
182
182
  version: '2'
@@ -186,7 +186,7 @@ dependencies:
186
186
  requirements:
187
187
  - - ">="
188
188
  - !ruby/object:Gem::Version
189
- version: 1.29.0
189
+ version: 1.36.0
190
190
  - - "<"
191
191
  - !ruby/object:Gem::Version
192
192
  version: '2'
@@ -196,7 +196,7 @@ dependencies:
196
196
  requirements:
197
197
  - - ">="
198
198
  - !ruby/object:Gem::Version
199
- version: 2.7.0
199
+ version: 2.7.6
200
200
  - - "<"
201
201
  - !ruby/object:Gem::Version
202
202
  version: '2.8'
@@ -206,7 +206,7 @@ dependencies:
206
206
  requirements:
207
207
  - - ">="
208
208
  - !ruby/object:Gem::Version
209
- version: 2.7.0
209
+ version: 2.7.6
210
210
  - - "<"
211
211
  - !ruby/object:Gem::Version
212
212
  version: '2.8'
@@ -216,20 +216,20 @@ dependencies:
216
216
  requirements:
217
217
  - - ">="
218
218
  - !ruby/object:Gem::Version
219
- version: 2.1.2
219
+ version: 3.0.0
220
220
  - - "<"
221
221
  - !ruby/object:Gem::Version
222
- version: '2.2'
222
+ version: '3.1'
223
223
  type: :runtime
224
224
  prerelease: false
225
225
  version_requirements: !ruby/object:Gem::Requirement
226
226
  requirements:
227
227
  - - ">="
228
228
  - !ruby/object:Gem::Version
229
- version: 2.1.2
229
+ version: 3.0.0
230
230
  - - "<"
231
231
  - !ruby/object:Gem::Version
232
- version: '2.2'
232
+ version: '3.1'
233
233
  description:
234
234
  email:
235
235
  - oscar@ecoportal.co.nz