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 CHANGED
@@ -8,4 +8,4 @@ a.out
8
8
  *.csv*
9
9
  !spec/fixtures/*.csv*
10
10
  Makefile
11
- pkg
11
+ *.gem
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bamfcsv (0.1.0)
4
+ bamfcsv (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
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 "super_giant_properly_formatted.csv"
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
- * Results may vary.
26
+
27
+ (*) Results may vary.
data/lib/bamfcsv/table.rb CHANGED
@@ -12,9 +12,12 @@ module BAMFCSV
12
12
  end
13
13
 
14
14
  def each
15
- @matrix.size.times do |idx|
16
- yield self[idx]
15
+ if block_given?
16
+ @matrix.size.times do |idx|
17
+ yield self[idx]
18
+ end
17
19
  end
20
+ self
18
21
  end
19
22
 
20
23
  def [](idx)
@@ -1,3 +1,3 @@
1
1
  module BAMFCSV
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -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
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: bamfcsv
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.1
5
+ version: 0.1.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jon Distad