csv-utils 0.3.11 → 0.3.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/csv-utils.gemspec +1 -1
- data/lib/csv_utils/csv_iterator.rb +20 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7b43801f0f7e62d34d8a77508964f0b6ea054a3ac2c8d17bf42d22aa0b245bd
|
4
|
+
data.tar.gz: ccd3282e4c7b1e1985439e24a159fe09c570b18446adee2b8db4776bc6024852
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1684319de3c4f728f55e1c201790dd5cc3aa110e09d14a4043fcdf3b70c02568fe898c4f2d7b839e633f461294f9870fae0a8cf2d3d785d173aa66f9c8ba2ab1
|
7
|
+
data.tar.gz: 6e7689f6f544e5280dbf144dc5a23a4b088aeff6c06931c0a856f6cd16353048e4ed343da0406550d2e7f48abd8af6e1ef31f6114ec9f3435aa56815c5fea24b
|
data/csv-utils.gemspec
CHANGED
@@ -43,6 +43,26 @@ class CSVUtils::CSVIterator
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
+
def headers
|
47
|
+
first.keys
|
48
|
+
end
|
49
|
+
|
50
|
+
def to_hash(key, value = nil)
|
51
|
+
raise("header #{key} not found in #{headers}") unless headers.include?(key)
|
52
|
+
raise("headers #{value} not found in #{headers}") if value && !headers.include?(value)
|
53
|
+
|
54
|
+
value_proc =
|
55
|
+
if value
|
56
|
+
proc { |row| row[value] }
|
57
|
+
else
|
58
|
+
proc { |row| yield(row) }
|
59
|
+
end
|
60
|
+
|
61
|
+
each_with_object({}) do |row, hsh|
|
62
|
+
hsh[row[key]] = value_proc.call(row)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
46
66
|
private
|
47
67
|
|
48
68
|
def strip_bom!(col)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: csv-utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Doug Youch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: inheritance-helper
|