csv-importer 0.7.0 → 0.8.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: 5e17c85aa62e6f2774f1cb86dcea9d7743622b73690fb896228d1bf7ce54951e
4
- data.tar.gz: acfd22bf68c1c228a0afecba046cf3cb7231311192ee1ee5c88828a56a51f429
3
+ metadata.gz: 803f33e5d2db4d5331bb2f6ef1c5fd6cc9ea19d1d8350e1c16a2041f2ac2176c
4
+ data.tar.gz: 822e5caa1ae8d3e73909fcf42a9e57e6cff00dc6f2f2bb900b25e010bed72f19
5
5
  SHA512:
6
- metadata.gz: c5c8894e68eaa33418761a9cad3ab8f0ddfea0eeaa3e62101ab1105a40978b7c206dc7448a4b536f9efc06c06b952935146efe9b4ae010c9a3f98428f649b641
7
- data.tar.gz: 66f498dc9d2e62bf413ba35ac362b03fa557640c724cafb8cc38686bfe825334455d936c1c8a4e79b97fc4ec0355887cb0f6dee178b0f3893d0b37c6dc043b09
6
+ metadata.gz: 0edf3c998a6b506a4778d0e36fddc828339cf8900653de0b41494489e4de57358df23a34ed30ad03f8583837ec0ca9c29d4166982ab80e17018481c00baad84d
7
+ data.tar.gz: c11177ab4e4fb02751a8e1be12ded7c41360bd62f2f72156c75b8a90819d47f861fbff94b1ed1c8fa29940c5db4484ccb15341c8baaf2bfae256234fb2183c35
@@ -1,6 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.3.0
4
+ - 2.7
4
5
  addons:
5
6
  code_climate:
6
7
  repo_token: bcecbf1b229a2ddd666a2c3830f26a0113fd56ae1586d30d2d3fb1af837bf0e4
@@ -2,6 +2,12 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [0.8.0] - 2020-09-02
6
+
7
+ ### Fixed
8
+
9
+ * Ruby 2.7 compatibility. [#93][] by [@perezperret][]
10
+
5
11
  ## [0.7.0] - 2019-11-29
6
12
 
7
13
  ### Added
@@ -195,6 +201,7 @@ report object instead of raising an exception.
195
201
  [#83]: https://github.com/pcreux/csv-importer/issues/83
196
202
  [#85]: https://github.com/pcreux/csv-importer/issues/85
197
203
  [#88]: https://github.com/pcreux/csv-importer/issues/88
204
+ [#93]: https://github.com/pcreux/csv-importer/issues/93
198
205
  [@brain-geek]: https://github.com/brain-geek
199
206
  [@danielweinmann]: https://github.com/danielweinmann
200
207
  [@egg-chicken]: https://github.com/egg-chicken
@@ -203,6 +210,7 @@ report object instead of raising an exception.
203
210
  [@mltsy]: https://github.com/mltsy
204
211
  [@paulodeleo]: https://github.com/paulodeleo
205
212
  [@pcreux]: https://github.com/pcreux
213
+ [@perezperret]: https://github.com/perezperret
206
214
  [@pnomolos]: https://github.com/pnomolos
207
215
  [@shvetsovdm]: https://github.com/shvetsovdm
208
216
  [@stas]: https://github.com/stas
data/Gemfile CHANGED
@@ -2,9 +2,3 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in csv-importer.gemspec
4
4
  gemspec
5
-
6
- gem 'rspec', '~> 3.3.0'
7
- gem 'guard-rspec'
8
- gem 'activemodel'
9
- gem 'simplecov', require: nil
10
- gem "codeclimate-test-reporter", require: nil
@@ -20,6 +20,10 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_dependency "virtus"
22
22
 
23
- spec.add_development_dependency "bundler", "~> 1.8"
24
- spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec", "~> 3.3.0"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "guard-rspec"
26
+ spec.add_development_dependency "activemodel", "~> 5"
27
+ spec.add_development_dependency "simplecov"
28
+ spec.add_development_dependency "codeclimate-test-reporter"
25
29
  end
@@ -14,8 +14,12 @@ module CSVImporter
14
14
  @csv_rows ||= begin
15
15
  sane_content = sanitize_content(read_content)
16
16
  separator = detect_separator(sane_content)
17
- cells = CSV.parse(sane_content, col_sep: separator, quote_char: quote_char, skip_blanks: true, encoding: encoding)
18
- sanitize_cells(cells)
17
+ cells = CSV.parse(
18
+ sane_content,
19
+ col_sep: separator, quote_char: quote_char, skip_blanks: true,
20
+ external_encoding: source_encoding
21
+ )
22
+ sanitize_cells(encode_cells(cells))
19
23
  end
20
24
  end
21
25
 
@@ -44,9 +48,8 @@ module CSVImporter
44
48
  end
45
49
 
46
50
  def sanitize_content(csv_content)
47
- internal_encoding = encoding.split(':').last
48
51
  csv_content
49
- .encode(Encoding.find(internal_encoding), {invalid: :replace, undef: :replace, replace: ''}) # Remove invalid byte sequences
52
+ .encode(Encoding.find(source_encoding), invalid: :replace, undef: :replace, replace: '') # Remove invalid byte sequences
50
53
  .gsub(/\r\r?\n?/, "\n") # Replaces windows line separators with "\n"
51
54
  end
52
55
 
@@ -75,5 +78,21 @@ module CSVImporter
75
78
  end
76
79
  end
77
80
  end
81
+
82
+ def encode_cells(rows)
83
+ rows.map do |cells|
84
+ cells.map do |cell|
85
+ cell ? cell.encode(target_encoding) : ""
86
+ end
87
+ end
88
+ end
89
+
90
+ def source_encoding
91
+ encoding.split(':').first || 'UTF-8'
92
+ end
93
+
94
+ def target_encoding
95
+ encoding.split(':').last || 'UTF-8'
96
+ end
78
97
  end
79
98
  end
@@ -1,3 +1,3 @@
1
1
  module CSVImporter
2
- VERSION = "0.7.0"
2
+ VERSION = "0.8.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: csv-importer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philippe Creux
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-29 00:00:00.000000000 Z
11
+ date: 2020-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: virtus
@@ -25,34 +25,90 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: bundler
28
+ name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.8'
33
+ version: 3.3.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.8'
40
+ version: 3.3.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard-rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: activemodel
43
71
  requirement: !ruby/object:Gem::Requirement
44
72
  requirements:
45
73
  - - "~>"
46
74
  - !ruby/object:Gem::Version
47
- version: '10.0'
75
+ version: '5'
48
76
  type: :development
49
77
  prerelease: false
50
78
  version_requirements: !ruby/object:Gem::Requirement
51
79
  requirements:
52
80
  - - "~>"
53
81
  - !ruby/object:Gem::Version
54
- version: '10.0'
55
- description:
82
+ version: '5'
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: codeclimate-test-reporter
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description:
56
112
  email:
57
113
  - pcreux@gmail.com
58
114
  executables: []
@@ -89,7 +145,7 @@ homepage: https://github.com/pcreux/csv-importer
89
145
  licenses:
90
146
  - MIT
91
147
  metadata: {}
92
- post_install_message:
148
+ post_install_message:
93
149
  rdoc_options: []
94
150
  require_paths:
95
151
  - lib
@@ -105,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
161
  version: '0'
106
162
  requirements: []
107
163
  rubygems_version: 3.0.3
108
- signing_key:
164
+ signing_key:
109
165
  specification_version: 4
110
166
  summary: CSV Import for humans
111
167
  test_files: []