csvr 1.0.2 → 1.0.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/lib/csvr.rb +4 -2
- data/lib/csvr/format.rb +0 -4
- data/lib/csvr/parse.rb +6 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 395e1a35433e5cff975e65dad8546bf376b44b25
|
4
|
+
data.tar.gz: 577b8791634c167da2704224cdaaca1f6a4c5010
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44e335942b9187ae6a450062cf5aeb4e9553c201b9b0e747fc437074fb1e6b586cc01c2de4a08c30471340dcca7f9abcdaa84b131e3cbb0df3967f1418ba73df
|
7
|
+
data.tar.gz: bdf6fe6b96d8dd99c1f871f5d2265ed09805aa01f14dddadb7405c6ee76748d5a39b502b35d82e548d4445a81c80b46a064273b0b7bcc2341faa8f485bd9fa3d
|
data/lib/csvr.rb
CHANGED
@@ -26,11 +26,13 @@ module CSVR
|
|
26
26
|
def parse
|
27
27
|
@headers ||= CSVR::Parse.headers(@file)
|
28
28
|
@rows = CSVR::Parse.rows(@file, @headers, @filters)
|
29
|
-
|
29
|
+
puts "HEADERS: #{@headers}, #{@headers.class}"
|
30
|
+
puts "ROWS: #{@rows.sample}, #{@rows.sample.class}, #{@rows.class}, #{@rows.empty?}"
|
31
|
+
@types = CSVR::Parse.type(@headers, @rows[0]) unless @rows.empty?
|
30
32
|
end
|
31
33
|
|
32
34
|
def format
|
33
|
-
@headers = Format.headers(@headers, @types)
|
35
|
+
@headers = Format.headers(@headers, @types) unless @types.nil?
|
34
36
|
@rows = @rows.map{ |row| Format.row(row) }
|
35
37
|
end
|
36
38
|
|
data/lib/csvr/format.rb
CHANGED
data/lib/csvr/parse.rb
CHANGED
@@ -61,19 +61,20 @@ module CSVR
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def filter(hash, filters)
|
64
|
-
|
65
64
|
hash.each do |key, value|
|
66
65
|
filters.each do |filter|
|
67
|
-
|
68
|
-
|
66
|
+
if filter.class == String
|
67
|
+
match = value.match(filter) if value.respond_to? :match
|
68
|
+
return hash if match
|
69
|
+
elsif filter.class == Fixnum || filter.class == Float
|
70
|
+
return hash if hash.value?(filter)
|
71
|
+
end
|
69
72
|
end
|
70
73
|
end
|
71
|
-
|
72
74
|
return nil
|
73
75
|
end
|
74
76
|
|
75
77
|
def type(headers, row)
|
76
|
-
|
77
78
|
types = []
|
78
79
|
headers.each do |header|
|
79
80
|
hash = {}
|