bamfcsv 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/lib/bamfcsv/table.rb +9 -3
- data/lib/bamfcsv/version.rb +1 -1
- data/spec/lib/bamfcsv_spec.rb +12 -0
- metadata +2 -2
data/Gemfile.lock
CHANGED
data/lib/bamfcsv/table.rb
CHANGED
@@ -36,13 +36,19 @@ module BAMFCSV
|
|
36
36
|
end
|
37
37
|
|
38
38
|
class Row
|
39
|
-
|
39
|
+
attr_reader :fields
|
40
|
+
|
41
|
+
def initialize(header_map, fields)
|
40
42
|
@header_map = header_map
|
41
|
-
@
|
43
|
+
@fields = fields
|
44
|
+
end
|
45
|
+
|
46
|
+
def headers
|
47
|
+
@header_map.keys
|
42
48
|
end
|
43
49
|
|
44
50
|
def [](key)
|
45
|
-
@
|
51
|
+
@fields[@header_map[key]]
|
46
52
|
end
|
47
53
|
end
|
48
54
|
end
|
data/lib/bamfcsv/version.rb
CHANGED
data/spec/lib/bamfcsv_spec.rb
CHANGED
@@ -155,6 +155,18 @@ describe BAMFCSV do
|
|
155
155
|
table.first["a"].should == "1"
|
156
156
|
table[1]["c"].should == "z"
|
157
157
|
end
|
158
|
+
|
159
|
+
it "knows the headers" do
|
160
|
+
table = BAMFCSV.parse("a,b,c\r\n1,2,3\r\nx,y,z", :headers => true)
|
161
|
+
row = table.first
|
162
|
+
row.headers.should == ['a', 'b', 'c']
|
163
|
+
end
|
164
|
+
|
165
|
+
it "knows the fields" do
|
166
|
+
table = BAMFCSV.parse("a,b,c\r\n1,2,3\r\nx,y,z", :headers => true)
|
167
|
+
row = table.first
|
168
|
+
row.fields.should == ['1', '2', '3']
|
169
|
+
end
|
158
170
|
end
|
159
171
|
|
160
172
|
describe "Table#each" do
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: bamfcsv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Jon Distad
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2011-04-
|
14
|
+
date: 2011-04-15 00:00:00 -04:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|