eco-helpers 0.7.2 → 0.8.1

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: e4f70377026306ed8ee7e6bb8629bb765b92ea310b41a75dddb586cc398d5f5b
4
- data.tar.gz: 2a25b0c4114c3b68943308e7475989a93cf8055ac59f9ff0e00173b02f2b3386
3
+ metadata.gz: 6d073b7d0bba9ae161a99451c11c4416c49d8a0693ebbe6110d46e8fd898141c
4
+ data.tar.gz: 748e56af552eb2556a8aa6d7770afeac04a15ff8481362efedb6ef431eb8c340
5
5
  SHA512:
6
- metadata.gz: 62c5f462a9121215a5a7d45a084084b088c314544cba21dabeb0e15a4c386288b6b136a3c7bc7436f9974d84a5c3418df93803409d6637f17dde0bac8024ae27
7
- data.tar.gz: 3e16c7ed28eeb72da9783cbbda1c4e44c3452aee7ee0eeb1c41855189f0d53f1d96dcf3caf68fc3e9eeefbd42ee9c5c63c84ee51e8b0c8e9e6c50d9d9bdcc8cb
6
+ metadata.gz: 10926532189b83b07bc128e4d96d3b23982f3b85553b8bd1e554a9503bf60b752f30ecf14a8f38f912d5428cd76fd59268b00881e6bda477811da9c07aac8ad7
7
+ data.tar.gz: bd33ffa5bf16699087c90a441d74546541e5b33c1cf58e6db5da840f9a4271a15aef5ab826060e891ea4808d700a8c221a61a765cd4ff50c86b85943007f26b6
data/eco-helpers.gemspec CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |s|
28
28
  s.add_development_dependency "yard", "~> 0.9", ">= 0.9.18"
29
29
  s.add_development_dependency "redcarpet", "~> 3.4", ">= 3.4.0"
30
30
 
31
- s.add_dependency 'ecoportal-api', '~> 0.4', '>= 0.4.2'
31
+ s.add_dependency 'ecoportal-api', '~> 0.4', '>= 0.4.3'
32
32
  s.add_dependency 'thor', '~> 0', '>= 0.20'
33
33
  s.add_dependency 'nokogiri', '~> 1.6', '>= 1.6.8'
34
34
  s.add_dependency 'aws-sdk-s3', '~> 1.30', '>= 1.30.1'
data/lib/eco-helpers.rb CHANGED
@@ -13,3 +13,4 @@ require_relative 'eco/data'
13
13
  require_relative 'eco/api'
14
14
  require_relative 'eco/tester'
15
15
  require_relative 'eco/cli'
16
+ require_relative 'eco/assets'
@@ -13,7 +13,7 @@ module Eco
13
13
  @enviro = enviro
14
14
  init = @enviro.config if @enviro && init.empty?
15
15
  @timestamp_pattern = init.files.timestamp_pattern || DEFAULT_TIMESTAMP_PATTERN
16
- self.dir_path = init.files.working_directory || Dir.pwd
16
+ self.dir_path = init.working_directory || Dir.pwd
17
17
  end
18
18
 
19
19
  def dir_path=(value)
@@ -57,7 +57,7 @@ module Eco
57
57
 
58
58
  if !pers && !strict && !email.to_s.strip.empty?
59
59
  candidates = @by_non_users_email[email&.downcase.strip] || []
60
- raise "Too many non-user candidates (#{candiates.length}) with email '#{email}'" if candidates.length > 1
60
+ raise "Too many non-user candidates (#{candidates.length}) with email '#{email}'" if candidates.length > 1
61
61
  pers = candidates.first
62
62
  end
63
63
 
@@ -19,7 +19,7 @@ module Eco
19
19
  @task = Task.new(enviro)
20
20
  @job_groups = JobGroups.new(enviro)
21
21
 
22
- @use_cases = Eco::API::UseCases::DefaultCases.new.merge(config.usecases.use_group)
22
+ @use_cases = Eco::API::UseCases::DefaultCases.new.merge(config.usecases)
23
23
 
24
24
  @schemas = config.schemas
25
25
  self.schema = config.people.default_schema || @schemas.first
@@ -41,12 +41,21 @@ module Eco
41
41
  batch_from(people, method: method, params: params, silent: silent)
42
42
  end
43
43
 
44
- def search(data, params: {})
44
+ def search(data, silent: false, params: {})
45
45
  params = {per_page: DEFAULT_BATCH_BLOCK}.merge(params)
46
46
 
47
- launch(data, method: :get, params: params, silent: true).tap do |status|
47
+ launch(data, method: :get, params: params, silent: silent).tap do |status|
48
48
  status.type = :search
49
- status.queue.each do |entry|
49
+
50
+ entries = status.queue
51
+ puts "\n"
52
+ entries.each_with_index do |entry, i|
53
+ if (i % 500 == 0)
54
+ percent = i * 100 / entries.length
55
+ print "Searching: #{percent.round}% (#{i}/#{entries.length} entries)\r"
56
+ $stdout.flush
57
+ end
58
+
50
59
  unless status.success?(entry)
51
60
  email = nil
52
61
  case
@@ -59,7 +68,7 @@ module Eco
59
68
  people_matching = []
60
69
  email = email.to_s.strip.downcase
61
70
  unless email.empty?
62
- people_matching = get(params: params.merge(q: email), silent: true).select do |person|
71
+ people_matching = get(params: params.merge(q: email), silent: silent).select do |person|
63
72
  person.email == email
64
73
  end
65
74
  end
@@ -91,16 +100,25 @@ module Eco
91
100
  page = params[:page] || 1
92
101
 
93
102
  people = []; total_pages = nil
103
+ results_from = nil
94
104
  loop do
105
+ params.merge!(results_from: results_from) unless !results_from
95
106
  people_res, response = client_get(client, params: params.merge(page: page), silent: silent)
96
107
  people += people_res
97
108
 
98
- total_pages ||= response.body["total_pages"]
109
+ total_iterations ||= response.body["total_pages"]
110
+ no_pages = !response.body["total_pages"]
111
+ total_results ||= response.body["total_results"]
112
+
113
+ if !total_iterations
114
+ total_iterations ||= (total_results.to_f / params[:per_page]).ceil
115
+ end
99
116
 
100
- msg = "page number: #{page}/#{total_pages}, got num people #{people_res.length}, with total #{people.length} people got"
117
+ msg = "iteration number: #{page}/#{total_iterations}, got num people #{people_res.length}, with total #{people.length} people got"
101
118
  logger.info(msg) unless silent
102
119
 
103
- break if page >= total_pages || !looping
120
+ iterate = (no_pages && results_from = response.body["next_results_from"]) || (looping && page < total_iterations)
121
+ break unless iterate
104
122
  page += 1
105
123
  end
106
124
 
@@ -123,23 +141,23 @@ module Eco
123
141
  [people, response]
124
142
  end
125
143
 
126
- def batch_from(people, method:, params: {}, silent: false)
144
+ def batch_from(data, method:, params: {}, silent: false)
127
145
  fatal "Invalid batch method: #{method}." if !self.class.valid_method?(method)
128
- return nil if !people || !people.is_a?(Enumerable)
146
+ return nil if !data || !data.is_a?(Enumerable)
129
147
  fatal "cannot batch #{method} without api connnection, please provide a valid api connection!" unless people_api = api&.people
130
148
 
131
149
  # batch Status
132
- status = new_status(people, method)
150
+ status = new_status(data, method)
133
151
 
134
152
  # param q does not make sense here, even for GET method
135
153
  params = {per_page: DEFAULT_BATCH_BLOCK}.merge(params)
136
154
  per_page = params[:per_page] || DEFAULT_BATCH_BLOCK
137
155
 
138
156
  iteration = 1; done = 0
139
- iterations = (people.length.to_f / per_page).ceil
157
+ iterations = (data.length.to_f / per_page).ceil
140
158
 
141
- people.each_slice(per_page) do |slice|
142
- msg = "starting batch '#{method}' iteration #{iteration}/#{iterations}, with #{slice.length} entries of #{people.length} -- #{done} done"
159
+ data.each_slice(per_page) do |slice|
160
+ msg = "starting batch '#{method}' iteration #{iteration}/#{iterations}, with #{slice.length} entries of #{data.length} -- #{done} done"
143
161
  logger.info(msg) unless silent
144
162
 
145
163
  people_api.batch do |batch|
@@ -137,7 +137,7 @@ module Eco
137
137
 
138
138
  def apply_policies(pre_queue)
139
139
  pre_queue.tap do |entries|
140
- policies = session.config.api_policies.policies
140
+ policies = session.config.policies
141
141
  unless policies.empty?
142
142
  policies.launch(people: people(entries), session: session)
143
143
  end
@@ -15,7 +15,7 @@ module Eco
15
15
 
16
16
  def initialize(e, queue:, method:, type: :exact)
17
17
  super(e)
18
- fatal("In batch operations you must batch an array. Received: #{queue}") unless queue && queue.is_a?(Array)
18
+ fatal("In batch operations you must batch an Enumerable. Received: #{queue}") unless queue && queue.is_a?(Enumerable)
19
19
 
20
20
  self.type = type
21
21
  @method = method
@@ -2,33 +2,46 @@ module Eco
2
2
  module API
3
3
  class Session
4
4
  class Config < Hash
5
- def initialize()
5
+ attr_reader :name
6
+
7
+ def initialize(name = :default)
6
8
  super(nil)
9
+ @name = name
7
10
  self["org"] = {}
8
11
  end
9
12
 
13
+ def clone(name)
14
+ keys.each_with_object(self.class.new(name)) do |key, cnf|
15
+ begin
16
+ cnf[key] = self[key].clone(config: cnf)
17
+ rescue ArgumentError
18
+ cnf[key] = self[key].clone
19
+ end
20
+ end
21
+ end
22
+
10
23
  def reopen
11
24
  yield(self)
12
25
  end
13
26
 
14
27
  def apis
15
- self["apis"] ||= Session::Config::Apis.new(root: self)
28
+ self["apis"] ||= Session::Config::Apis.new(config: self)
16
29
  end
17
30
 
18
31
  def logger
19
- self["logger"] ||= Session::Config::Logger.new(root: self)
32
+ self["logger"] ||= Session::Config::Logger.new(config: self)
20
33
  end
21
34
 
22
35
  def s3storage
23
- self["s3_storage"] ||= Session::Config::S3Storage.new(root: self)
36
+ self["s3_storage"] ||= Session::Config::S3Storage.new(config: self)
24
37
  end
25
38
 
26
39
  def files
27
- self["files"] ||= Session::Config::Files.new(root: self)
40
+ self["files"] ||= Session::Config::Files.new(config: self)
28
41
  end
29
42
 
30
43
  def mailer
31
- self["mailer"] ||= Session::Config::Mailer.new(root: self)
44
+ self["mailer"] ||= Session::Config::Mailer.new(config: self)
32
45
  end
33
46
 
34
47
  def org
@@ -36,15 +49,7 @@ module Eco
36
49
  end
37
50
 
38
51
  def people
39
- self["people"] ||= Session::Config::People.new(root: self)
40
- end
41
-
42
- def usecases
43
- self["usecases"] ||= Session::Config::UseCases.new(root: self)
44
- end
45
-
46
- def api_policies
47
- self["api_policies"] ||= Session::Config::Policies.new(root: self)
52
+ self["people"] ||= Session::Config::People.new(config: self)
48
53
  end
49
54
 
50
55
  # LOGGER
@@ -112,6 +117,14 @@ module Eco
112
117
  files.working_directory = path
113
118
  end
114
119
 
120
+ def working_directory(mode: :active_api)
121
+ if mode == :active_api
122
+ apis.active_root_name
123
+ else
124
+ files.working_directory
125
+ end
126
+ end
127
+
115
128
  def file_timestamp_pattern=(pattern)
116
129
  files.timestamp_pattern = pattern
117
130
  end
@@ -120,11 +133,32 @@ module Eco
120
133
  Eco::API::Common::Session::FileManager.new(self)
121
134
  end
122
135
 
123
- def require(file)
124
- require_relative "#{File.expand_path(file_manager.dir.file(file))}"
136
+ def require(file = nil, match: nil)
137
+ if match
138
+ file_manager.dir.dir_files(pattern: match).each do |file|
139
+ #pp "#{File.expand_path(file)}"
140
+ require_relative File.expand_path(file)
141
+ end
142
+ else
143
+ require_relative "#{File.expand_path(file_manager.dir.file(file))}"
144
+ end
125
145
  end
126
146
 
127
147
  # ORG
148
+
149
+ def location_codes=(file)
150
+ org["location_codes"] = file
151
+ end
152
+
153
+ def location_codes
154
+ org["location_codes"]
155
+ end
156
+
157
+ def locations_mapper
158
+ file = file_manager.newest(location_codes)
159
+ @locations_mapper ||= Eco::Data::Mapper.new(file_manager.load_json(file), internal: :first)
160
+ end
161
+
128
162
  def tagtree=(file)
129
163
  org["tagtree"] = file
130
164
  end
@@ -174,17 +208,29 @@ module Eco
174
208
 
175
209
  # CUSTOM PERSON PARSERS
176
210
  def person_parser(format: :csv, &block)
177
- people.add_parser(format: format, &block)
211
+ people.parser(format: format, &block)
178
212
  end
179
213
 
180
214
  # CUSTOM USE CASES
181
- def use_cases(&block)
182
- usecases.add(&block)
215
+ def usecases
216
+ cases = self["usecases"] ||= Eco::API::UseCases::UseGroup.new
217
+ if block_given?
218
+ yield(cases)
219
+ self
220
+ else
221
+ cases
222
+ end
183
223
  end
184
224
 
185
225
  # API POLICIES
186
- def policies(&block)
187
- api_policies.add(&block)
226
+ def policies
227
+ api_policies = self["policies"] ||= Eco::API::Policies::UsedPolicies.new
228
+ if block_given?
229
+ yield(api_policies)
230
+ self
231
+ else
232
+ api_policies
233
+ end
188
234
  end
189
235
 
190
236
  end
@@ -192,6 +238,7 @@ module Eco
192
238
  end
193
239
  end
194
240
 
241
+ require_relative 'config/base_config'
195
242
  require_relative 'config/api'
196
243
  require_relative 'config/apis'
197
244
  require_relative 'config/logger'
@@ -199,5 +246,3 @@ require_relative 'config/mailer'
199
246
  require_relative 'config/s3_storage'
200
247
  require_relative 'config/files'
201
248
  require_relative 'config/people'
202
- require_relative 'config/use_cases'
203
- require_relative 'config/policies'
@@ -2,12 +2,7 @@ module Eco
2
2
  module API
3
3
  class Session
4
4
  class Config
5
- class Apis < Hash
6
-
7
- def initialize(root:)
8
- super(nil)
9
- @root = root
10
- end
5
+ class Apis < BaseConfig
11
6
 
12
7
  def apis
13
8
  self["apis"] ||= {}
@@ -0,0 +1,26 @@
1
+ module Eco
2
+ module API
3
+ class Session
4
+ class Config
5
+ class BaseConfig < Hash
6
+ attr_reader :config
7
+ def initialize(config:)
8
+ super(nil)
9
+ @config = config
10
+ end
11
+
12
+ def clone(config:)
13
+ keys.each_with_object(self.class.new(config: config)) do |key, cnf|
14
+ begin
15
+ cnf[key] = self[key].clone(config: cnf)
16
+ rescue ArgumentError
17
+ cnf[key] = self[key].clone
18
+ end
19
+ end
20
+ end
21
+
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -2,11 +2,10 @@ module Eco
2
2
  module API
3
3
  class Session
4
4
  class Config
5
- class Files < Hash
5
+ class Files < BaseConfig
6
6
 
7
- def initialize(root:)
8
- super(nil)
9
- @root = root
7
+ def initialize(config:)
8
+ super(config: config)
10
9
  @validations = {}
11
10
  end
12
11
 
@@ -2,12 +2,7 @@ module Eco
2
2
  module API
3
3
  class Session
4
4
  class Config
5
- class Logger < Hash
6
-
7
- def initialize(root:)
8
- super(nil)
9
- @root = root
10
- end
5
+ class Logger < BaseConfig
11
6
 
12
7
  def console_level=(value)
13
8
  self["console_level"] = value
@@ -2,12 +2,7 @@ module Eco
2
2
  module API
3
3
  class Session
4
4
  class Config
5
- class Mailer < Hash
6
-
7
- def initialize(root:)
8
- super(nil)
9
- @root = root
10
- end
5
+ class Mailer < BaseConfig
11
6
 
12
7
  def from=(value)
13
8
  self["from"] = value
@@ -2,14 +2,7 @@ module Eco
2
2
  module API
3
3
  class Session
4
4
  class Config
5
- class People < Hash
6
- attr_reader :config
7
-
8
- def initialize(root:)
9
- super(nil)
10
- @root = root
11
- @config = @root
12
- end
5
+ class People < BaseConfig
13
6
 
14
7
  def cache=(file)
15
8
  self["cache"] = file
@@ -80,15 +73,6 @@ module Eco
80
73
  self["presets_map"]
81
74
  end
82
75
 
83
- # Defines an `ParserSerializer` for a `PersonParser` of certain `format`
84
- # @param format [Symbol] the target format this parser/serializer is made for.
85
- def add_parser(format: :csv)
86
- parsers[format] ||= Eco::API::Common::People::PersonParser.new
87
- parsers[format].tap do |prs|
88
- yield(prs, config)
89
- end
90
- end
91
-
92
76
  # @return [Hash] with defined pairs format `key` and Person parsers.
93
77
  def parsers
94
78
  self["parsers"] ||= {}
@@ -98,7 +82,13 @@ module Eco
98
82
  # @param format [Symbol] the format this parser/serializer recognizes.
99
83
  # @return [Eco::API::Common::People::PersonParser] parser/serializer for the defined `format`.
100
84
  def parser(format: :csv)
101
- parsers[format]
85
+ prs = parsers[format] ||= Eco::API::Common::People::PersonParser.new
86
+ if block_given?
87
+ yield(prs)
88
+ self
89
+ else
90
+ prs
91
+ end
102
92
  end
103
93
 
104
94
  end
@@ -2,12 +2,7 @@ module Eco
2
2
  module API
3
3
  class Session
4
4
  class Config
5
- class S3Storage < Hash
6
-
7
- def initialize(root:)
8
- super(nil)
9
- @root = root
10
- end
5
+ class S3Storage < BaseConfig
11
6
 
12
7
  def bucket_name=(value)
13
8
  self["bucket_name"] = value
@@ -25,7 +25,7 @@ module Eco
25
25
  end
26
26
 
27
27
  def initialize(name, type:, root:, options: {}, &block)
28
- raise "Undefine usecase type #{type}. Please, use any of #{TYPES}" unless self.class.valid_type?(type)
28
+ raise "Undefined usecase type #{type}, when creating '#{name}'. Please, use any of #{TYPES}" unless self.class.valid_type?(type)
29
29
 
30
30
  self.root = root
31
31
  @case = block
data/lib/eco/assets.rb ADDED
@@ -0,0 +1,42 @@
1
+ require 'ecoportal/api'
2
+
3
+ module Eco
4
+ class Assets
5
+
6
+ attr_reader :active_config
7
+
8
+ def initialize
9
+ @active_config = :default
10
+ end
11
+
12
+ def session(key: active_config)
13
+ sessions[key] ||= Eco::API::Session.new(config(key: key))
14
+ sessions[key].tap do |session|
15
+ yield(session) if block_given?
16
+ end
17
+ end
18
+
19
+ def sessions
20
+ @sessions ||= {}
21
+ end
22
+
23
+
24
+ def config(key: active_config)
25
+ configs[:default] ||= Eco::API::Session::Config.new(key)
26
+ unless configs.key?(key)
27
+ @active_config = key
28
+ configs[key] = configs[:default].clone(key)
29
+ end
30
+ configs[key].tap do |config|
31
+ yield(config) if block_given?
32
+ end
33
+ end
34
+
35
+ def configs
36
+ @configs ||= {}
37
+ end
38
+ end
39
+ end
40
+
41
+ ASSETS = Eco::Assets.new
42
+ #require_relative 'assets/'
@@ -26,8 +26,8 @@ module Eco
26
26
  File.expand_path(@dir_path)
27
27
  end
28
28
 
29
- def dir_files(file: nil, file_pattern: dir_pattern)
30
- find = !!file ? file_pattern(file) : dir_pattern
29
+ def dir_files(file: nil, pattern: dir_pattern)
30
+ find = !!file ? file_pattern(file) : file_pattern(pattern)
31
31
  Dir.glob(find)
32
32
  end
33
33
 
@@ -76,8 +76,13 @@ module Eco
76
76
 
77
77
  private
78
78
 
79
- def file_pattern(filename)
80
- Files::FilePattern.new(filename).pattern(@dir_path)
79
+ def file_pattern(value)
80
+ case value
81
+ when Files::FilePattern
82
+ value
83
+ else
84
+ Files::FilePattern.new(value).pattern(@dir_path)
85
+ end
81
86
  end
82
87
 
83
88
  def dir_pattern
@@ -24,7 +24,8 @@ module Eco
24
24
  filename = File.basename(@source_file)
25
25
  path = File.dirname(@source_file)
26
26
  path = File.join(dir, path) if dir
27
- File.join(path, "*" + filename)
27
+ wildcard = (filename =~ /\*/)? "" : "*"
28
+ File.join(path, wildcard + filename)
28
29
  end
29
30
  end
30
31
  end
@@ -49,6 +49,10 @@ module Eco
49
49
  self.class.new(data, klass: @klass, factory: @factory)
50
50
  end
51
51
 
52
+ def merge(data)
53
+ newFrom to_a + data
54
+ end
55
+
52
56
  def to_c
53
57
  Collection.new(self, klass: @klass, factory: @factory)
54
58
  end
@@ -12,7 +12,7 @@ module Eco
12
12
 
13
13
  def stop_on_unknown!(exclude: [])
14
14
  if arguments.any_unkown?(exclude: exclude)
15
- raise "There are unkown options in your command line arguments: #{arguments.unknown(exclude: exclude)}"
15
+ raise "There are unknown options in your command line arguments: #{arguments.unknown(exclude: exclude)}"
16
16
  end
17
17
  end
18
18
 
data/lib/eco/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Eco
2
- VERSION = "0.7.2"
2
+ VERSION = "0.8.1"
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: 0.7.2
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura
@@ -107,7 +107,7 @@ dependencies:
107
107
  version: '0.4'
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
- version: 0.4.2
110
+ version: 0.4.3
111
111
  type: :runtime
112
112
  prerelease: false
113
113
  version_requirements: !ruby/object:Gem::Requirement
@@ -117,7 +117,7 @@ dependencies:
117
117
  version: '0.4'
118
118
  - - ">="
119
119
  - !ruby/object:Gem::Version
120
- version: 0.4.2
120
+ version: 0.4.3
121
121
  - !ruby/object:Gem::Dependency
122
122
  name: thor
123
123
  requirement: !ruby/object:Gem::Requirement
@@ -323,13 +323,12 @@ files:
323
323
  - lib/eco/api/session/config.rb
324
324
  - lib/eco/api/session/config/api.rb
325
325
  - lib/eco/api/session/config/apis.rb
326
+ - lib/eco/api/session/config/base_config.rb
326
327
  - lib/eco/api/session/config/files.rb
327
328
  - lib/eco/api/session/config/logger.rb
328
329
  - lib/eco/api/session/config/mailer.rb
329
330
  - lib/eco/api/session/config/people.rb
330
- - lib/eco/api/session/config/policies.rb
331
331
  - lib/eco/api/session/config/s3_storage.rb
332
- - lib/eco/api/session/config/use_cases.rb
333
332
  - lib/eco/api/session/job_groups.rb
334
333
  - lib/eco/api/session/task.rb
335
334
  - lib/eco/api/usecases.rb
@@ -361,6 +360,7 @@ files:
361
360
  - lib/eco/api/usecases/use_case_chain.rb
362
361
  - lib/eco/api/usecases/use_case_io.rb
363
362
  - lib/eco/api/usecases/use_group.rb
363
+ - lib/eco/assets.rb
364
364
  - lib/eco/cli.rb
365
365
  - lib/eco/cli/api.rb
366
366
  - lib/eco/cli/root.rb
@@ -1,29 +0,0 @@
1
- module Eco
2
- module API
3
- class Session
4
- class Config
5
- class Policies < Hash
6
- attr_reader :config
7
-
8
- def initialize(root:)
9
- super(nil)
10
- @root = root
11
- @config = @root
12
- end
13
-
14
- # API POLICIES
15
- def add
16
- policies.tap do |group|
17
- yield(group, config)
18
- end
19
- end
20
-
21
- def policies
22
- self["used_policies"] ||= Eco::API::Policies::UsedPolicies.new
23
- end
24
-
25
- end
26
- end
27
- end
28
- end
29
- end
@@ -1,29 +0,0 @@
1
- module Eco
2
- module API
3
- class Session
4
- class Config
5
- class UseCases < Hash
6
- attr_reader :config
7
-
8
- def initialize(root:)
9
- super(nil)
10
- @root = root
11
- @config = @root
12
- end
13
-
14
- # CUSTOM USE CASES
15
- def add
16
- use_group.tap do |group|
17
- yield(group, config)
18
- end
19
- end
20
-
21
- def use_group
22
- self["use_group"] ||= Eco::API::UseCases::UseGroup.new
23
- end
24
-
25
- end
26
- end
27
- end
28
- end
29
- end