eco-helpers 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/eco/api/common/people/entries.rb +0 -27
- data/lib/eco/api/common/people/entry_factory.rb +35 -0
- data/lib/eco/api/common/people.rb +1 -0
- data/lib/eco/api/common/session/environment.rb +1 -1
- data/lib/eco/api/session.rb +1 -0
- data/lib/eco/api/session_config/people.rb +12 -7
- data/lib/eco/api/session_config/use_cases.rb +6 -5
- data/lib/eco/api/session_config.rb +2 -2
- data/lib/eco/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1be39cfd739ccf1346f635fb4b341faf84567869
|
4
|
+
data.tar.gz: e7b0a20c6a4438a8cb7475d93c84a098339ed2b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85d763bfd6a440ed19d6bb43b130073cb625eb4da0076d2e09430b6c09709a5aa87218c588988dca3ffd11e771174dac4bdcf688eab59630441d6635e170eb45
|
7
|
+
data.tar.gz: a26f655e2f9afc47ffdd4e9a545e8223d248a5430b94ef0dc972e926b1a3ac425bb1a7f23474b6680c4a06875a159111c269f3cdd7f88aa97ba4fb8c3ac01688
|
@@ -2,33 +2,6 @@ module Eco
|
|
2
2
|
module API
|
3
3
|
module Common
|
4
4
|
module People
|
5
|
-
class EntryFactory
|
6
|
-
|
7
|
-
attr_reader :person_parser
|
8
|
-
|
9
|
-
def initialize(schema:, person_parser: nil, fields_mapper: nil, logger: ::Logger.new(IO::NULL))
|
10
|
-
raise "Constructor needs a PersonSchema. Given: #{schema}" if !schema.is_a?(Ecoportal::API::V1::PersonSchema)
|
11
|
-
raise "Expecting PersonParser. Given: #{person_parser}" if person_parser && !person_parser.is_a?(Eco::API::Common::People::PersonParser)
|
12
|
-
raise "Expecting Mapper object. Given: #{fields_mapper}" if fields_mapper && !fields_mapper.is_a?(Eco::Data::Mapper)
|
13
|
-
|
14
|
-
@logger = logger
|
15
|
-
@schema = Ecoportal::API::V1::PersonSchema.new(JSON.parse(schema.doc.to_json))
|
16
|
-
|
17
|
-
default_parser = Eco::API::Common::People::DefaultParsers.new(schema: @schema)
|
18
|
-
@parser = default_parser.merge(person_parser)
|
19
|
-
|
20
|
-
@fields_mapper = fields_mapper
|
21
|
-
end
|
22
|
-
|
23
|
-
def new(data, dependencies: {})
|
24
|
-
PersonEntry.new(data, parser: @parser, mapper: @fields_mapper, dependencies: dependencies, logger: @logger)
|
25
|
-
end
|
26
|
-
|
27
|
-
def entries(data)
|
28
|
-
Entries.new(data, klass: PersonEntry, factory: self)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
5
|
class Entries < Eco::Language::Models::Collection
|
33
6
|
|
34
7
|
# build the shortcuts of Collection
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Eco
|
2
|
+
module API
|
3
|
+
module Common
|
4
|
+
module People
|
5
|
+
class EntryFactory
|
6
|
+
|
7
|
+
attr_reader :person_parser
|
8
|
+
|
9
|
+
def initialize(schema:, person_parser: nil, fields_mapper: nil, logger: ::Logger.new(IO::NULL))
|
10
|
+
raise "Constructor needs a PersonSchema. Given: #{schema}" if !schema.is_a?(Ecoportal::API::V1::PersonSchema)
|
11
|
+
raise "Expecting PersonParser. Given: #{person_parser}" if person_parser && !person_parser.is_a?(Eco::API::Common::People::PersonParser)
|
12
|
+
raise "Expecting Mapper object. Given: #{fields_mapper}" if fields_mapper && !fields_mapper.is_a?(Eco::Data::Mapper)
|
13
|
+
|
14
|
+
@logger = logger
|
15
|
+
@schema = Ecoportal::API::V1::PersonSchema.new(JSON.parse(schema.doc.to_json))
|
16
|
+
|
17
|
+
default_parser = Eco::API::Common::People::DefaultParsers.new(schema: @schema)
|
18
|
+
@parser = default_parser.merge(person_parser)
|
19
|
+
|
20
|
+
@fields_mapper = fields_mapper
|
21
|
+
end
|
22
|
+
|
23
|
+
def new(data, dependencies: {})
|
24
|
+
PersonEntry.new(data, parser: @parser, mapper: @fields_mapper, dependencies: dependencies, logger: @logger)
|
25
|
+
end
|
26
|
+
|
27
|
+
def entries(data)
|
28
|
+
Entries.new(data, klass: PersonEntry, factory: self)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -32,7 +32,7 @@ module Eco
|
|
32
32
|
api = config.api(log)
|
33
33
|
|
34
34
|
unless log_connection
|
35
|
-
logger.info("Created connection pointing to '#{config.apis.active_api.host}'")
|
35
|
+
logger.info("Created connection pointing to '#{config.apis.active_api.host}' in '#{config.apis.active_api.mode}' mode")
|
36
36
|
api.logger.level = ::Logger::UNKNOWN
|
37
37
|
end
|
38
38
|
|
data/lib/eco/api/session.rb
CHANGED
@@ -159,6 +159,7 @@ module Eco
|
|
159
159
|
def process_case(name, type: nil, **params)
|
160
160
|
args = { session: self }.merge(params)
|
161
161
|
fatal("Undefined usecase '#{name}' of type '#{type.to_s}'") if !@use_cases.defined?(name, type: type)
|
162
|
+
logger.debug("Session: going to process '#{name}' defined case")
|
162
163
|
@use_cases.case(name, type: type).process(**args)
|
163
164
|
end
|
164
165
|
|
@@ -2,10 +2,12 @@ module Eco
|
|
2
2
|
module API
|
3
3
|
class SessionConfig
|
4
4
|
class People < Hash
|
5
|
+
attr_reader :config
|
5
6
|
|
6
7
|
def initialize(root:)
|
7
8
|
super(nil)
|
8
|
-
@root
|
9
|
+
@root = root
|
10
|
+
@config = @root
|
9
11
|
end
|
10
12
|
|
11
13
|
def cache=(file)
|
@@ -69,18 +71,21 @@ module Eco
|
|
69
71
|
end
|
70
72
|
|
71
73
|
# CUSTOM PERSON PARSERS
|
72
|
-
def
|
73
|
-
self["parsers"] ||= Eco::API::Common::People::PersonParser.new
|
74
|
+
def add_parser(format: :csv)
|
74
75
|
new_parsers = Eco::API::Common::People::PersonParser.new
|
75
76
|
|
76
|
-
yield(new_parsers,
|
77
|
+
yield(new_parsers, config)
|
78
|
+
parsers[format] ||= Eco::API::Common::People::PersonParser.new
|
79
|
+
parsers[format] = parsers[format] ? parsers[format].merge(new_parsers) : new_parsers
|
80
|
+
end
|
77
81
|
|
78
|
-
|
79
|
-
self["parsers"]
|
82
|
+
def parsers
|
83
|
+
self["parsers"] ||= {}
|
84
|
+
self["parsers"]
|
80
85
|
end
|
81
86
|
|
82
87
|
def parser(format: :csv)
|
83
|
-
|
88
|
+
parsers[format]
|
84
89
|
end
|
85
90
|
|
86
91
|
end
|
@@ -2,19 +2,20 @@ module Eco
|
|
2
2
|
module API
|
3
3
|
class SessionConfig
|
4
4
|
class UseCases < Hash
|
5
|
-
|
5
|
+
attr_reader :config
|
6
|
+
|
6
7
|
def initialize(root:)
|
7
8
|
super(nil)
|
8
|
-
@root
|
9
|
+
@root = root
|
10
|
+
@config = @root
|
9
11
|
end
|
10
12
|
|
11
13
|
# CUSTOM USE CASES
|
12
14
|
def add
|
13
|
-
self["use_group"] ||= Eco::API::UseCases::UseGroup.new
|
14
15
|
new_group = Eco::API::UseCases::UseGroup.new
|
16
|
+
yield(new_group, config)
|
15
17
|
|
16
|
-
|
17
|
-
|
18
|
+
self["use_group"] ||= Eco::API::UseCases::UseGroup.new
|
18
19
|
group = self["use_group"]
|
19
20
|
group = group ? group.merge(new_group) : group
|
20
21
|
self["use_group"] = group
|
@@ -126,7 +126,7 @@ module Eco
|
|
126
126
|
|
127
127
|
# PEOPLE
|
128
128
|
def discarded_people_file=(value)
|
129
|
-
people.
|
129
|
+
people.discarded_file = value
|
130
130
|
end
|
131
131
|
|
132
132
|
def people_cache=(file)
|
@@ -157,7 +157,7 @@ module Eco
|
|
157
157
|
|
158
158
|
# CUSTOM PERSON PARSERS
|
159
159
|
def person_parser(format: :csv, &block)
|
160
|
-
people.
|
160
|
+
people.add_parser(format: format, &block)
|
161
161
|
end
|
162
162
|
|
163
163
|
# CUSTOM USE CASES
|
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: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oscar Segura
|
@@ -193,6 +193,7 @@ files:
|
|
193
193
|
- lib/eco/api/common/people/default_parsers/numeric_parser.rb
|
194
194
|
- lib/eco/api/common/people/default_parsers/select_parser.rb
|
195
195
|
- lib/eco/api/common/people/entries.rb
|
196
|
+
- lib/eco/api/common/people/entry_factory.rb
|
196
197
|
- lib/eco/api/common/people/person_entry.rb
|
197
198
|
- lib/eco/api/common/people/person_factory.rb
|
198
199
|
- lib/eco/api/common/people/person_modifier.rb
|