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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4f2285828f990459399861ec63fca804d0b3bb0b
4
- data.tar.gz: 87d0d166b6649b4c6170793afcf36661ddea22ca
3
+ metadata.gz: 395e1a35433e5cff975e65dad8546bf376b44b25
4
+ data.tar.gz: 577b8791634c167da2704224cdaaca1f6a4c5010
5
5
  SHA512:
6
- metadata.gz: 98b11ec98049994269742d640a0db132555c4b90d845e5aff945d0445e548ddbfb318b989579ae7b8bb515e50f5f527a13ef7993234d4830a6c087009b65277a
7
- data.tar.gz: b89358a1d611689711dbec2196a5902c2e5dc297aad838203d17316f6b75e47ea20f63ee7c87ef14703cb1dea0a9862b040df691338aaaa6ec8404a6bba2d217
6
+ metadata.gz: 44e335942b9187ae6a450062cf5aeb4e9553c201b9b0e747fc437074fb1e6b586cc01c2de4a08c30471340dcca7f9abcdaa84b131e3cbb0df3967f1418ba73df
7
+ data.tar.gz: bdf6fe6b96d8dd99c1f871f5d2265ed09805aa01f14dddadb7405c6ee76748d5a39b502b35d82e548d4445a81c80b46a064273b0b7bcc2341faa8f485bd9fa3d
@@ -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
- @types = CSVR::Parse.type(@headers, @rows.sample)
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
 
@@ -9,10 +9,6 @@ module Format
9
9
  end
10
10
 
11
11
  def type(header, types)
12
- # return "TEXT" unless types[header] == Fixnum || types[header] == Float
13
- # return "INTEGER" unless types[header] == Float
14
- # return "REAL"
15
-
16
12
  case types[header]
17
13
  when Fixnum
18
14
  return "INTEGER"
@@ -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
- match = value.match(filter) if value.respond_to? :match
68
- return hash if match
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 = {}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: csvr
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Smith