smarter_csv 1.7.2 → 1.7.3
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/CONTRIBUTORS.md +1 -0
- data/README.md +3 -2
- data/lib/smarter_csv/version.rb +1 -1
- data/lib/smarter_csv.rb +6 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4046758f38c21262fdec6bc7e13e3a7811c7aee3944d92e0cc36a2a1cfb032a
|
4
|
+
data.tar.gz: 9d111e2f36171ca488034f3af73fc71c7c9f6fde73986d277aeaf1560a066fa2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c46c5c45dd3fafe66735b2b17b0679c5aaff27b3670140d97bc19e1c825ad91310fa2cf55a12a5c7b0c31ef82fe9cc12a2c4bda0a78b218d80ad5816c01c0d9f
|
7
|
+
data.tar.gz: ba03acd95955f8afeb8e96f16c7cfa2e1605dbaf6fddb7008930294aab83196aed21f57605efb3553799381c1c4811528eee2db221efa50dc82f58bcf9135842
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
|
2
2
|
# SmarterCSV 1.x Change Log
|
3
3
|
|
4
|
+
## 1.7.3 (2022-12-05)
|
5
|
+
* new option :silence_missing_keys; if set to true, it ignores missing keys in `key_mapping`
|
6
|
+
|
4
7
|
## 1.7.2 (2022-08-29)
|
5
8
|
* new option :with_line_numbers; if set to true, it adds :csv_line_number to each data hash (issue #130)
|
6
9
|
|
data/CONTRIBUTORS.md
CHANGED
@@ -48,3 +48,4 @@ A Big Thank you to everyone who filed issues, sent comments, and who contributed
|
|
48
48
|
* [Viacheslav Markin](https://github.com/KXEinc)
|
49
49
|
* [Nicolas Rodriguez](https://github.com/n-rodriguez)
|
50
50
|
* [Hirotaka Mizutani ](https://github.com/hirotaka)
|
51
|
+
* [Rahul Chaudhary](https://github.com/rahulch95)
|
data/README.md
CHANGED
@@ -240,7 +240,7 @@ The options and the block are optional.
|
|
240
240
|
| | | You can not combine the :user_provided_headers and :key_mapping options |
|
241
241
|
| :remove_empty_hashes | true | remove / ignore any hashes which don't have any key/value pairs or all empty values |
|
242
242
|
| :verbose | false | print out line number while processing (to track down problems in input files) |
|
243
|
-
| :with_line_numbers | false | add :csv_line_number to
|
243
|
+
| :with_line_numbers | false | add :csv_line_number to each data hash |
|
244
244
|
---------------------------------------------------------------------------------------------------------------------------------
|
245
245
|
|
246
246
|
#### Deprecated 1.x Options: to be replaced in 2.0
|
@@ -253,7 +253,8 @@ And header and data validations will also be supported in 2.x
|
|
253
253
|
| Option | Default | Explanation |
|
254
254
|
---------------------------------------------------------------------------------------------------------------------------------
|
255
255
|
| :key_mapping | nil | a hash which maps headers from the CSV file to keys in the result hash |
|
256
|
-
| :
|
256
|
+
| :silence_missing_key | false | ignore missing keys in `key_mapping` if true |
|
257
|
+
| :required_headers | nil | An array. Each of the given headers must be present after header manipulation, |
|
257
258
|
| | | or an exception is raised No validation if nil is given. |
|
258
259
|
| :remove_unmapped_keys | false | when using :key_mapping option, should non-mapped keys / columns be removed? |
|
259
260
|
| :downcase_header | true | downcase all column headers |
|
data/lib/smarter_csv/version.rb
CHANGED
data/lib/smarter_csv.rb
CHANGED
@@ -227,6 +227,7 @@ module SmarterCSV
|
|
227
227
|
remove_zero_values: false,
|
228
228
|
required_headers: nil,
|
229
229
|
row_sep: $/,
|
230
|
+
silence_missing_keys: false,
|
230
231
|
skip_lines: nil,
|
231
232
|
strings_as_keys: false,
|
232
233
|
strip_chars_from_headers: nil,
|
@@ -479,9 +480,11 @@ module SmarterCSV
|
|
479
480
|
# do some key mapping on the keys in the file header
|
480
481
|
# if you want to completely delete a key, then map it to nil or to ''
|
481
482
|
if !key_mappingH.nil? && key_mappingH.class == Hash && key_mappingH.keys.size > 0
|
482
|
-
|
483
|
-
|
484
|
-
|
483
|
+
unless options[:silence_missing_keys]
|
484
|
+
# if silence_missing_keys are not set, raise error if missing header
|
485
|
+
missing_keys = key_mappingH.keys - headerA
|
486
|
+
puts "WARNING: missing header(s): #{missing_keys.join(",")}" unless missing_keys.empty?
|
487
|
+
end
|
485
488
|
|
486
489
|
headerA.map!{|x| key_mappingH.has_key?(x) ? (key_mappingH[x].nil? ? nil : key_mappingH[x]) : (options[:remove_unmapped_keys] ? nil : x)}
|
487
490
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smarter_csv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tilo Sloboda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: awesome_print
|
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
140
|
- !ruby/object:Gem::Version
|
141
141
|
version: '0'
|
142
142
|
requirements: []
|
143
|
-
rubygems_version: 3.
|
143
|
+
rubygems_version: 3.1.6
|
144
144
|
signing_key:
|
145
145
|
specification_version: 4
|
146
146
|
summary: Ruby Gem for smarter importing of CSV Files (and CSV-like files), with lots
|