eco-helpers 0.9.5 → 1.0.2

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: 8824e93753de01f752b0b655339fcc09ddf4da24dfdad76b25cadb25bed11225
4
- data.tar.gz: 9db399712ea74e57ea62c696802f2dcf80e8fe01dd476f18edc4a938a66ca4ab
3
+ metadata.gz: 9e365c79c49402a5c46ebc79964b0b4d5848bc7822ac611c7ee882ed56a60888
4
+ data.tar.gz: 89616bae7fc5cf0755bd4b68f3ccc141be5b4fb95fa1ce16324244a98542ac39
5
5
  SHA512:
6
- metadata.gz: d655f7beb82c00655a86d3e75e0444d4e0eb9f233a8e8b265413384d41e50c5e985ecd0588f37fb3e45209a296f9a4a8f6d02a90bb2cea8e7d09b6da2385a509
7
- data.tar.gz: 325555d794297d40c3bfaffb8e3f500d622b3f16c274ad71001c0b56235a2560168cd6e18ce1fdfe5284bf0c91e75c5f0127b179e425f54195191629973d5349
6
+ metadata.gz: 719745fdba1d0e15a489553b424220f9c83f22fb431935682006c1299093fff99a8ee4c51b6af57b4db64d8bae0e98fd74445bd96f09fe5274fecf00a4829fad
7
+ data.tar.gz: 0e1f61a386be4dfebb8fe02942f26629aeeb1b83d982ed76e5a85d750ede88c6e758108152b0c3587e63962fe9896c3d3af8e81964baf3c42619245d2a1d0c22
data/eco-helpers.gemspec CHANGED
@@ -22,16 +22,16 @@ Gem::Specification.new do |s|
22
22
  #s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
23
23
  s.require_paths = ["lib"]
24
24
 
25
- s.add_development_dependency "bundler", "~> 1.16"
25
+ s.add_development_dependency "bundler", "~> 2.0.1"
26
26
  s.add_development_dependency "rspec", "~> 3", ">= 3.8"
27
- s.add_development_dependency "rake", "~> 10.0"
27
+ s.add_development_dependency "rake", "~> 12.3.0"
28
28
  s.add_development_dependency "yard", "~> 0.9", ">= 0.9.18"
29
- s.add_development_dependency "redcarpet", "~> 3.4", ">= 3.4.0"
29
+ s.add_development_dependency "redcarpet", "~> 3.5", ">= 3.5.0"
30
30
 
31
- s.add_dependency 'ecoportal-api', '~> 0.4', '>= 0.4.3'
31
+ s.add_dependency 'ecoportal-api', '~> 0.5', '>= 0.5.1'
32
32
  s.add_dependency 'aws-sdk-s3', '~> 1.30', '>= 1.30.1'
33
33
  s.add_dependency 'aws-sdk-ses', '~> 1.14', '>= 1.14.0'
34
34
  s.add_dependency 'dotenv', '~> 2.6', '>= 2.6.0'
35
- s.add_dependency 'faker', '~> 1', '>= 1.9'
35
+ s.add_dependency 'faker', '~> 2', '>= 2.1'
36
36
  s.add_dependency 'distribution', '~> 0.7', '>= 0.7.3'
37
37
  end
@@ -218,18 +218,28 @@ module Eco
218
218
 
219
219
  def _set_to_core(person, attr, value)
220
220
  value = value&.downcase if attr == "email"
221
- person.send("#{attr}=", value&.strip)
221
+ multiple = ["filter_tags"].include?(attr)
222
+ if multiple
223
+ value = @person_parser.parse(:multiple, value)
224
+ value = value.map { |v| v&.upcase } if attr == "filter_tags"
225
+ # preserve previous order
226
+ current = into_a(person.send(attr))
227
+ value = (current & value) + (value - current)
228
+ else
229
+ value = value&.strip
230
+ end
231
+
232
+ person.send("#{attr}=", value)
222
233
  end
223
234
 
224
235
  def _set_to_account(person, attr, value)
225
236
  return if !person.account
226
- multiple = ["policy_group_ids", "filter_tags"].include?(attr)
237
+ multiple = ["policy_group_ids"].include?(attr)
227
238
  if multiple
228
- value = @person_parser.parse(:multiple, value)
229
- value = value.map { |v| v&.upcase } if attr == "filter_tags"
239
+ value = @person_parser.parse(:multiple, value)
230
240
  # preserve previous order
231
241
  current = into_a(person.account.send(attr))
232
- value = (current & value) + (value - current)
242
+ value = (current & value) + (value - current)
233
243
  end
234
244
 
235
245
  person.account.send("#{attr}=", value)
@@ -9,8 +9,8 @@ module Eco
9
9
  # @attr_reader details_attrs [Array<String>] internal names of schema details attributes.
10
10
  # @attr_reader all_attrs [Array<String>] all the internal name attributes, including _core_, _account_ and _details_.
11
11
  class PersonParser
12
- CORE_ATTRS = ["id", "external_id", "email", "name", "supervisor_id"]
13
- ACCOUNT_ATTRS = ["policy_group_ids", "filter_tags", "default_tag"]
12
+ CORE_ATTRS = ["id", "external_id", "email", "name", "supervisor_id", "filter_tags"]
13
+ ACCOUNT_ATTRS = ["policy_group_ids", "default_tag"]
14
14
  TYPE = [:select, :text, :date, :number, :phone_number, :boolean, :multiple]
15
15
  FORMAT = [:csv, :xml, :json]
16
16
 
@@ -17,12 +17,24 @@ module Eco
17
17
  else
18
18
  person = session.new_person
19
19
  core_excluded = ["supervisor_id"]
20
+
21
+ ini_tags = person.filter_tags || []
20
22
  entry.set_core(person, exclude: core_excluded)
23
+
24
+ if session.tagtree
25
+ person.filter_tags = session.tagtree.user_tags(
26
+ initial: ini_tags,
27
+ final: person.filter_tags,
28
+ preserve_custom: true,
29
+ add_custom: true
30
+ )
31
+ end
32
+
33
+
21
34
  entry.set_details(person) unless options.dig(:exclude, :details)
22
35
 
23
36
  unless options.dig(:exclude, :account)
24
37
  ini_pg_ids = person.account&.policy_group_ids || []
25
- ini_tags = person.account&.filter_tags || []
26
38
  entry.set_account(person)
27
39
 
28
40
  person.account&.send_invites = options[:send_invites] if options.key?(:send_invites)
@@ -35,15 +47,9 @@ module Eco
35
47
  person.account.permissions_custom = session.new_preset(person)
36
48
 
37
49
  if session.tagtree
38
- person.account.filter_tags = session.tagtree.user_tags(
39
- initial: ini_tags,
40
- final: person.account.filter_tags,
41
- preserve_custom: true,
42
- add_custom: true
43
- )
44
- person.account.default_tag = session.tagtree.default_tag(*person.account.filter_tags)
50
+ person.account.default_tag = session.tagtree.default_tag(*person.filter_tags)
45
51
  else
46
- tags = person.account.filter_tags
52
+ tags = person.filter_tags
47
53
  person.account.default_tag = tags.first unless tags.length > 1
48
54
  end
49
55
  end
@@ -37,7 +37,7 @@ module Eco
37
37
 
38
38
  person.account.permissions_custom = session.new_preset(person) unless !create && options.dig(:exclude, :abilities)
39
39
 
40
- person.account.default_tag = person.account.filter_tags.first if person.account.filter_tags.length == 1
40
+ person.account.default_tag = person.filter_tags.first if person.filter_tags.length == 1
41
41
 
42
42
 
43
43
  creation.add(person) if create
@@ -30,7 +30,7 @@ module Eco
30
30
 
31
31
  people.each_with_index do |person, i|
32
32
  #next unless person.id == "5c527ba63f7690001243f5b2"
33
- person.account.default_tag = session.tagtree.default_tag(*person.account.filter_tags)
33
+ person.account.default_tag = session.tagtree.default_tag(*person.filter_tags)
34
34
  update.add(person)
35
35
  end
36
36
 
@@ -23,14 +23,28 @@ module Eco
23
23
 
24
24
  entries.each.with_index do |entry, i|
25
25
  if person = people.find(entry, strict: strict_search)
26
+
26
27
  core_excluded = ["supervisor_id"]
27
28
  core_excluded.push("email") if options.dig(:exclude, :email)
28
- entry.set_core(person, exclude: core_excluded) unless options.dig(:exclude, :core)
29
+
30
+ unless options.dig(:exclude, :core)
31
+ ini_tags = person.filter_tags || []
32
+ entry.set_core(person, exclude: core_excluded)
33
+
34
+ if session.tagtree
35
+ person.filter_tags = session.tagtree.user_tags(
36
+ initial: ini_tags,
37
+ final: person.filter_tags,
38
+ preserve_custom: true,
39
+ add_custom: true
40
+ )
41
+ end
42
+ end
43
+
29
44
  entry.set_details(person) unless options.dig(:exclude, :details)
30
45
 
31
46
  unless options.dig(:exclude, :account)
32
47
  ini_pg_ids = person.account&.policy_group_ids || []
33
- ini_tags = person.account&.filter_tags || []
34
48
  entry.set_account(person)
35
49
 
36
50
  person.account.policy_group_ids = pgs.user_pg_ids(
@@ -41,15 +55,9 @@ module Eco
41
55
  person.account.permissions_custom = session.new_preset(person) unless options.dig(:exclude, :abilities)
42
56
 
43
57
  if session.tagtree
44
- person.account.filter_tags = session.tagtree.user_tags(
45
- initial: ini_tags,
46
- final: person.account.filter_tags,
47
- preserve_custom: true,
48
- add_custom: true
49
- )
50
- person.account.default_tag = session.tagtree.default_tag(*person.account.filter_tags)
58
+ person.account.default_tag = session.tagtree.default_tag(*person.filter_tags)
51
59
  else
52
- tags = person.account.filter_tags
60
+ tags = person.filter_tags
53
61
  person.account.default_tag = tags.first unless tags.length > 1
54
62
  end
55
63
 
@@ -19,12 +19,24 @@ module Eco
19
19
 
20
20
  core_excluded = ["supervisor_id"]
21
21
  core_excluded.push("email") if options.dig(:exclude, :email) && !create
22
- entry.set_core(person, exclude: core_excluded) unless options.dig(:exclude, :core) && !create
22
+
23
+ unless options.dig(:exclude, :core) && !create
24
+ ini_tags = person.filter_tags || []
25
+ entry.set_core(person, exclude: core_excluded)
26
+ if session.tagtree
27
+ person.filter_tags = session.tagtree.user_tags(
28
+ initial: ini_tags,
29
+ final: person.filter_tags,
30
+ preserve_custom: true,
31
+ add_custom: true
32
+ )
33
+ end
34
+ end
35
+
23
36
  entry.set_details(person) unless options.dig(:exclude, :details)
24
37
 
25
38
  unless options.dig(:exclude, :account)
26
39
  ini_pg_ids = person.account&.policy_group_ids || []
27
- ini_tags = person.account&.filter_tags || []
28
40
  entry.set_account(person)
29
41
 
30
42
  person.account.send_invites = options[:send_invites] if options.key?(:send_invites)
@@ -37,15 +49,9 @@ module Eco
37
49
  person.account.permissions_custom = session.new_preset(person) unless !create && options.dig(:exclude, :abilities)
38
50
 
39
51
  if session.tagtree
40
- person.account.filter_tags = session.tagtree.user_tags(
41
- initial: ini_tags,
42
- final: person.account.filter_tags,
43
- preserve_custom: true,
44
- add_custom: true
45
- )
46
- person.account.default_tag = session.tagtree.default_tag(*person.account.filter_tags)
52
+ person.account.default_tag = session.tagtree.default_tag(*person.filter_tags)
47
53
  else
48
- tags = person.account.filter_tags
54
+ tags = person.filter_tags
49
55
  person.account.default_tag = tags.first unless tags.length > 1
50
56
  end
51
57
 
data/lib/eco/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Eco
2
- VERSION = "0.9.5"
2
+ VERSION = "1.0.2"
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.9.5
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.16'
19
+ version: 2.0.1
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.16'
26
+ version: 2.0.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -50,14 +50,14 @@ dependencies:
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '10.0'
53
+ version: 12.3.0
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '10.0'
60
+ version: 12.3.0
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: yard
63
63
  requirement: !ruby/object:Gem::Requirement
@@ -84,40 +84,40 @@ dependencies:
84
84
  requirements:
85
85
  - - ">="
86
86
  - !ruby/object:Gem::Version
87
- version: 3.4.0
87
+ version: 3.5.0
88
88
  - - "~>"
89
89
  - !ruby/object:Gem::Version
90
- version: '3.4'
90
+ version: '3.5'
91
91
  type: :development
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
95
  - - ">="
96
96
  - !ruby/object:Gem::Version
97
- version: 3.4.0
97
+ version: 3.5.0
98
98
  - - "~>"
99
99
  - !ruby/object:Gem::Version
100
- version: '3.4'
100
+ version: '3.5'
101
101
  - !ruby/object:Gem::Dependency
102
102
  name: ecoportal-api
103
103
  requirement: !ruby/object:Gem::Requirement
104
104
  requirements:
105
105
  - - "~>"
106
106
  - !ruby/object:Gem::Version
107
- version: '0.4'
107
+ version: '0.5'
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
- version: 0.4.3
110
+ version: 0.5.1
111
111
  type: :runtime
112
112
  prerelease: false
113
113
  version_requirements: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '0.4'
117
+ version: '0.5'
118
118
  - - ">="
119
119
  - !ruby/object:Gem::Version
120
- version: 0.4.3
120
+ version: 0.5.1
121
121
  - !ruby/object:Gem::Dependency
122
122
  name: aws-sdk-s3
123
123
  requirement: !ruby/object:Gem::Requirement
@@ -184,20 +184,20 @@ dependencies:
184
184
  requirements:
185
185
  - - "~>"
186
186
  - !ruby/object:Gem::Version
187
- version: '1'
187
+ version: '2'
188
188
  - - ">="
189
189
  - !ruby/object:Gem::Version
190
- version: '1.9'
190
+ version: '2.1'
191
191
  type: :runtime
192
192
  prerelease: false
193
193
  version_requirements: !ruby/object:Gem::Requirement
194
194
  requirements:
195
195
  - - "~>"
196
196
  - !ruby/object:Gem::Version
197
- version: '1'
197
+ version: '2'
198
198
  - - ">="
199
199
  - !ruby/object:Gem::Version
200
- version: '1.9'
200
+ version: '2.1'
201
201
  - !ruby/object:Gem::Dependency
202
202
  name: distribution
203
203
  requirement: !ruby/object:Gem::Requirement