bamfcsv 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -1
- data/Gemfile.lock +1 -1
- data/README +17 -2
- data/lib/bamfcsv/table.rb +5 -2
- data/lib/bamfcsv/version.rb +1 -1
- data/spec/lib/bamfcsv_spec.rb +11 -0
- metadata +1 -1
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/README
CHANGED
@@ -2,11 +2,26 @@ BAMFCSV -- Parsin' CSVs like a BAMF!
|
|
2
2
|
|
3
3
|
$ gem install bamfcsv
|
4
4
|
$ irb -rbamfcsv
|
5
|
-
irb> BAMFCSV.read "
|
5
|
+
irb> BAMFCSV.read "super_giant.csv"
|
6
|
+
===> ...large array of arrays...
|
6
7
|
|
7
8
|
BAMF!!! CSV IS PARSED IN LESS THAN ONE SECOND! GUARANTEED!*
|
8
9
|
|
10
|
+
also:
|
11
|
+
BAMFCSV.parse "csv,string,of,awesome"
|
9
12
|
|
13
|
+
AND! both #parse and #read take an optional :headers => true to generate a table!
|
10
14
|
|
15
|
+
irb(1.9.2): table = BAMFCSV.parse <<EOF, headers: true
|
16
|
+
?> foo,bar
|
17
|
+
?> 1,2
|
18
|
+
?> 3,4
|
19
|
+
?> EOF
|
20
|
+
==========> #<BAMFCSV::Table>
|
21
|
+
irb(1.9.2): table.first["foo"]
|
22
|
+
==========> "1"
|
23
|
+
irb(1.9.2): table[1]["bar"]
|
24
|
+
==========> "4"
|
11
25
|
|
12
|
-
|
26
|
+
|
27
|
+
(*) Results may vary.
|
data/lib/bamfcsv/table.rb
CHANGED
data/lib/bamfcsv/version.rb
CHANGED
data/spec/lib/bamfcsv_spec.rb
CHANGED
@@ -156,5 +156,16 @@ describe BAMFCSV do
|
|
156
156
|
table[1]["c"].should == "z"
|
157
157
|
end
|
158
158
|
end
|
159
|
+
|
160
|
+
describe "Table#each" do
|
161
|
+
let(:table) { BAMFCSV.parse("a,b\n1,2", :headers => true) }
|
162
|
+
it "Table#each returns self" do
|
163
|
+
table.each { |r| ;}.should == table
|
164
|
+
end
|
165
|
+
|
166
|
+
it "does not require a block" do
|
167
|
+
expect { table.each }.should_not raise_error(LocalJumpError)
|
168
|
+
end
|
169
|
+
end
|
159
170
|
end
|
160
171
|
end
|