eco-helpers 1.4.2 → 1.5.0

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: 2248f088b428a4d94bc0a28fe735e680b179a64f138113206057c853e358e0f0
4
- data.tar.gz: 1284ede3bcbfc33df6281ab456247850d918cc98eb8318c7327c8047be8dcab0
3
+ metadata.gz: 27ff9c6e496ac4cc7d08cb7f8fec22096ccd6aa915103de89048229e334cbc46
4
+ data.tar.gz: 0baecbe3aeb2ea75ce995395f15d2daba1b59a8e5587d2ce1537d99c92db9c61
5
5
  SHA512:
6
- metadata.gz: fcc3c790f2c4a6c044f11da966ac97149eb652e503c91bce108d58fa12348c1be0be1a056518798c4121110bf9146ce2271bcafa87bc938a8d35058449949838
7
- data.tar.gz: 3f6a6888a1907419fceaa3ad25f0c997e133715a467cd3c3704ef1f43ec24f09528460069b3e7ceefb9bf612ca2e6d034d6d3beef5fac0487b88e0ecf5952b66
6
+ metadata.gz: 5c435f203bf8d3829829e8d00b74714a479544f48f0d0e081c83b1441a84a5bf6d9be678cab4aa60c09e9f5de3642388904ea52462477c83d259ba6960bab109
7
+ data.tar.gz: 7750b44622529f48bc58d577e4783affa8b1b5c7db58e780ff974634ee88dadcc4b0a93fe86879eec8cc4854959ce95ffa5cf7c256d5f458a2814715c7b9b6bc
@@ -1,12 +1,16 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
- ## [1.4.3] - 2020-07-xx
4
+ ## [1.5.0] - 2020-09-11
5
5
 
6
6
  ### Added
7
+ - `Eco::Data::Files#file_empty?` to prevent error when checking encoding
7
8
  ### Changed
9
+ - change abilities to align with ecoPortal release `1.5.2`
8
10
  ### Fixed
9
-
11
+ - `Eco::CSV#parse` and `Eco::CSV#read` should use the proper `encoding` when it's `bom`
12
+ * apparently, this can only be achieved by passing an argument such as `rb:bom|utf-8`
13
+ * best reference found: https://stackoverflow.com/a/60794851/4352306
10
14
 
11
15
  ## [1.4.2] - 2020-07-23
12
16
 
@@ -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.5", ">= 3.5.0"
30
30
 
31
- s.add_dependency 'ecoportal-api', '~> 0.5', '>= 0.5.9'
31
+ s.add_dependency 'ecoportal-api', '~> 0.7', '>= 0.7.0'
32
32
  s.add_dependency 'aws-sdk-s3', '~> 1', '>= 1.64.0'
33
33
  s.add_dependency 'aws-sdk-ses', '~> 1', '>= 1.29.0'
34
34
  s.add_dependency 'dotenv', '~> 2.7', '>= 2.7.0'
@@ -6,6 +6,8 @@
6
6
  "organization": null,
7
7
  "people": null,
8
8
  "person_core": null,
9
+ "person_core_create": null,
10
+ "person_core_edit": null,
9
11
  "person_account": null,
10
12
  "person_details": null,
11
13
  "pages": "view",
@@ -18,6 +20,8 @@
18
20
  "reports": "view",
19
21
  "organization": null,
20
22
  "person_core": "attach",
23
+ "person_core_create": null,
24
+ "person_core_edit": null,
21
25
  "person_account": null,
22
26
  "person_details": "view",
23
27
  "pages": "create",
@@ -30,6 +34,8 @@
30
34
  "reports": "edit",
31
35
  "organization": "view",
32
36
  "person_core": "view_people_manager",
37
+ "person_core_create": null,
38
+ "person_core_edit": null,
33
39
  "person_account": "view",
34
40
  "person_details": "view",
35
41
  "pages": "create",
@@ -41,7 +47,9 @@
41
47
  "data": "administrate",
42
48
  "reports": "administrate",
43
49
  "organization": "administrate",
44
- "person_core": "edit",
50
+ "person_core": "view_people_manager",
51
+ "person_core_create": "create",
52
+ "person_core_edit": "edit",
45
53
  "person_account": "edit",
46
54
  "person_details": "edit_private",
47
55
  "pages": "administrate",
@@ -3,7 +3,9 @@
3
3
  "data": [null, "view", "update", "administrate", "implement"],
4
4
  "reports": [null, "view", "edit", "administrate"],
5
5
  "organization": [null, "view", "administrate", "implement"],
6
- "person_core": [null, "attach", "view_people_manager", "create", "edit", "dashboard"],
6
+ "person_core": [null, "attach", "view_people_manager", "dashboard"],
7
+ "person_core_create": [null, "create"],
8
+ "person_core_edit": [null, "edit"],
7
9
  "person_account": [null, "view", "create", "edit"],
8
10
  "person_details": [null, "view", "edit_public", "view_private", "edit_private"],
9
11
  "pages": [null, "view", "update", "create", "administrate"],
@@ -15,9 +15,14 @@ module Eco
15
15
  end
16
16
 
17
17
  def read(file, **kargs)
18
- coding = Eco::API::Common::Session::FileManager.encoding(file)
19
- kargs = {headers: true, skip_blanks: true, encoding: coding}.merge(kargs)
20
- out = super(file, **kargs).reject do |row|
18
+ kargs = {headers: true, skip_blanks: true}.merge(kargs)
19
+
20
+ args = [file].tap do |arg|
21
+ coding = Eco::API::Common::Session::FileManager.encoding(file)
22
+ arg.push("rb:bom|utf-8") if coding == "bom"
23
+ end
24
+
25
+ out = super(*args, **kargs).reject do |row|
21
26
  values = row.to_hash.values
22
27
  values.all?(&:nil?) || values.map(&:to_s).all?(&:empty?)
23
28
  end
@@ -62,8 +62,13 @@ module Eco
62
62
  File.write(dest_file, File.read(source_file))
63
63
  end
64
64
 
65
+ def file_empty?(path)
66
+ return true if !File.file?(path)
67
+ File.zero?(path)
68
+ end
69
+
65
70
  def has_bom?(path)
66
- return false if !path
71
+ return false if !path || file_empty?(path)
67
72
  File.open(path, "rb") do |f|
68
73
  bytes = f.read(3)
69
74
  return bytes.unpack("C*") == [239, 187, 191]
@@ -1,3 +1,3 @@
1
1
  module Eco
2
- VERSION = "1.4.2"
2
+ VERSION = "1.5.0"
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.4.2
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura
@@ -108,22 +108,22 @@ dependencies:
108
108
  name: ecoportal-api
109
109
  requirement: !ruby/object:Gem::Requirement
110
110
  requirements:
111
- - - "~>"
112
- - !ruby/object:Gem::Version
113
- version: '0.5'
114
111
  - - ">="
115
112
  - !ruby/object:Gem::Version
116
- version: 0.5.9
113
+ version: 0.7.0
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: '0.7'
117
117
  type: :runtime
118
118
  prerelease: false
119
119
  version_requirements: !ruby/object:Gem::Requirement
120
120
  requirements:
121
- - - "~>"
122
- - !ruby/object:Gem::Version
123
- version: '0.5'
124
121
  - - ">="
125
122
  - !ruby/object:Gem::Version
126
- version: 0.5.9
123
+ version: 0.7.0
124
+ - - "~>"
125
+ - !ruby/object:Gem::Version
126
+ version: '0.7'
127
127
  - !ruby/object:Gem::Dependency
128
128
  name: aws-sdk-s3
129
129
  requirement: !ruby/object:Gem::Requirement