smarter_csv 1.2.8 → 1.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of smarter_csv might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 90df8a442690ff9202ee2762a199e652ebca4dc6e5899d24ee0a72d192cf539f
4
- data.tar.gz: 16d4826bc7840a112ef5d5ea3b7acf0997d5fbeb46f8f5289ffa31a7356aa71c
3
+ metadata.gz: d8f46a382941610ffe65bb2bcf260370df6bd6745b3118011f27c34455925199
4
+ data.tar.gz: f6687d1622c3fde6bd4db287f67157f6408db49ef4fb3f5dc8b155443f5884bf
5
5
  SHA512:
6
- metadata.gz: 85cf20915d26794ba37e508379bc8460d65f054771803779df3b67cd907a61da9ea195d8b51da5a9942bb7f3a5866325114a7a107cbbfcc269f47f6bf6dbfff5
7
- data.tar.gz: e2508804722db4bd76e63a9e459b180fb75f7215e3e6d53970e5a83c120d0dab3cdd639c562abfe91d5b9458c3a990aa3959e85000491aef8529442ade5a3f90
6
+ metadata.gz: 5a398cdd05dae06a41fce1f68a1e11f92c329eed417f1fa14e716bd948edef8daa33f789b75a4ccbc6ab565aad454c33abf8c3844413097bffe67026647afc7d
7
+ data.tar.gz: d4297a08ac79e78d6ae89f09dd1ba976e3b840f1e3b43501502c993bce9942cc3adb5d1168a37a8869ce376c1424c05d7ad5ecdf94f3b429c828ee9063dd82e3
data/.travis.yml CHANGED
@@ -6,13 +6,9 @@ before_install:
6
6
 
7
7
  matrix:
8
8
  include:
9
- - rvm: 2.2.10
10
- - rvm: 2.3.8
11
- - rvm: 2.4.6
12
- - rvm: 2.5.7
13
- - rvm: 2.6.3
14
- - rvm: 2.7.2
9
+ - rvm: 2.7.4
15
10
  - rvm: 3.0.0
11
+ - rvm: 3.1.0
16
12
  - rvm: jruby-9.2.7.0
17
13
  env:
18
14
  - JRUBY_OPTS="--server -Xcompile.invokedynamic=false -J-XX:+TieredCompilation -J-XX:TieredStopAtLevel=1 -J-noverify -J-Xms512m -J-Xmx1024m"
data/README.md CHANGED
@@ -324,6 +324,11 @@ Planned in the next releases:
324
324
 
325
325
  ## Changes
326
326
 
327
+
328
+ #### 1.2.9 (2021-11-22)
329
+ * fix bug for key_mappings (issue #181)
330
+ The values of the `key_mappings` hash will now be used "as is", and no longer forced to be symbols
331
+
327
332
  #### 1.2.8 (2020-02-04)
328
333
  * fix deprecation warnings on Ruby 2.7 (thank to Diego Salido)
329
334
 
@@ -92,7 +92,7 @@ module SmarterCSV
92
92
  # do some key mapping on the keys in the file header
93
93
  # if you want to completely delete a key, then map it to nil or to ''
94
94
  if ! key_mappingH.nil? && key_mappingH.class == Hash && key_mappingH.keys.size > 0
95
- headerA.map!{|x| key_mappingH.has_key?(x) ? (key_mappingH[x].nil? ? nil : key_mappingH[x].to_sym) : (options[:remove_unmapped_keys] ? nil : x)}
95
+ headerA.map!{|x| key_mappingH.has_key?(x) ? (key_mappingH[x].nil? ? nil : key_mappingH[x]) : (options[:remove_unmapped_keys] ? nil : x)}
96
96
  end
97
97
  end
98
98
 
@@ -1,3 +1,3 @@
1
1
  module SmarterCSV
2
- VERSION = "1.2.8"
2
+ VERSION = "1.2.9"
3
3
  end
data/smarter_csv.gemspec CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |gem|
15
15
  gem.require_paths = ["lib"]
16
16
  gem.requirements = ['csv'] # for CSV.parse() only needed in case we have quoted fields
17
17
  gem.version = SmarterCSV::VERSION
18
- gem.licenses = ['MIT','GPL-2']
18
+ gem.licenses = ['MIT','GPL-2'] # pick either of these licenses - only that license applies to you
19
19
  gem.add_development_dependency "rspec"
20
20
  # gem.add_development_dependency "guard-rspec"
21
21
  end
@@ -0,0 +1,2 @@
1
+ THIS,THAT,other
2
+ this,that,other
@@ -22,4 +22,19 @@ describe 'be_able_to' do
22
22
  end
23
23
  end
24
24
 
25
+ describe 'when keep_original_headers' do
26
+ it 'sets key_mapping to a symbol' do
27
+ options = {:keep_original_headers => true, :key_mapping => {'other' => :other}}
28
+ data = SmarterCSV.process("#{fixture_path}/key_mapping.csv", options)
29
+ data.size.should == 1
30
+ data.first.keys.should == ['THIS', 'THAT', :other]
31
+ end
32
+
33
+ it 'sets key_mapping to a string' do
34
+ options = {:keep_original_headers => true, :key_mapping => {'other' => 'OTHER'}}
35
+ data = SmarterCSV.process("#{fixture_path}/key_mapping.csv", options)
36
+ data.size.should == 1
37
+ data.first.keys.should == ['THIS', 'THAT', 'OTHER']
38
+ end
39
+ end
25
40
  end
@@ -8,14 +8,10 @@ describe 'malformed_csv' do
8
8
  context "malformed header" do
9
9
  let(:csv_path) { "#{fixture_path}/malformed_header.csv" }
10
10
  it { should raise_error(CSV::MalformedCSVError) }
11
- it { should raise_error(/(Missing or stray quote in line 1|CSV::MalformedCSVError)/) }
12
- it { should raise_error(CSV::MalformedCSVError) }
13
11
  end
14
12
 
15
13
  context "malformed content" do
16
14
  let(:csv_path) { "#{fixture_path}/malformed.csv" }
17
15
  it { should raise_error(CSV::MalformedCSVError) }
18
- it { should raise_error(/(Missing or stray quote in line 1|CSV::MalformedCSVError)/) }
19
- it { should raise_error(CSV::MalformedCSVError) }
20
16
  end
21
17
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smarter_csv
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.8
4
+ version: 1.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - 'Tilo Sloboda
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-02-04 00:00:00.000000000 Z
13
+ date: 2021-11-23 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
@@ -60,6 +60,7 @@ files:
60
60
  - spec/fixtures/empty.csv
61
61
  - spec/fixtures/ignore_comments.csv
62
62
  - spec/fixtures/ignore_comments2.csv
63
+ - spec/fixtures/key_mapping.csv
63
64
  - spec/fixtures/line_endings_n.csv
64
65
  - spec/fixtures/line_endings_r.csv
65
66
  - spec/fixtures/line_endings_rn.csv
@@ -136,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
137
  version: '0'
137
138
  requirements:
138
139
  - csv
139
- rubygems_version: 3.0.6
140
+ rubygems_version: 3.1.6
140
141
  signing_key:
141
142
  specification_version: 4
142
143
  summary: Ruby Gem for smarter importing of CSV Files (and CSV-like files), with lots
@@ -153,6 +154,7 @@ test_files:
153
154
  - spec/fixtures/empty.csv
154
155
  - spec/fixtures/ignore_comments.csv
155
156
  - spec/fixtures/ignore_comments2.csv
157
+ - spec/fixtures/key_mapping.csv
156
158
  - spec/fixtures/line_endings_n.csv
157
159
  - spec/fixtures/line_endings_r.csv
158
160
  - spec/fixtures/line_endings_rn.csv