omgcsv 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/omgcsv.rb +0 -1
- data/spec/data.csv +1 -0
- data/spec/test_spec.rb +14 -5
- metadata +23 -10
data/lib/omgcsv.rb
CHANGED
data/spec/data.csv
CHANGED
data/spec/test_spec.rb
CHANGED
@@ -8,7 +8,7 @@ require 'omgcsv'
|
|
8
8
|
|
9
9
|
module OMGCSV
|
10
10
|
def data
|
11
|
-
parse(
|
11
|
+
parse(%Q{name,age,height\nDopey,2,1.2m\nSleepy,3,0.9m\n"Mr Grumpy",4,2m})
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
@@ -29,15 +29,24 @@ describe 'Parsing:' do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
it "Should produce an object with 2 correct rows" do
|
32
|
-
data.rows.size.should ==
|
32
|
+
data.rows.size.should == 3
|
33
33
|
data.rows[0].should === ['Dopey','2','1.2m']
|
34
34
|
data.rows[1].should === ['Sleepy','3','0.9m']
|
35
35
|
end
|
36
36
|
|
37
|
+
it "Should handle quoted strings" do
|
38
|
+
data[2].name.should == 'Mr Grumpy'
|
39
|
+
end
|
40
|
+
|
41
|
+
it "Should handle quoted strings with commas" do
|
42
|
+
data = parse(%Q{name,description\nA Stick,"long, brown and sticky"})
|
43
|
+
data[0][:description].should == 'long, brown and sticky'
|
44
|
+
end
|
45
|
+
|
37
46
|
it "Should provide access to rows by integer" do
|
38
47
|
data[0].should === ['Dopey','2','1.2m']
|
39
48
|
data[1].should === ['Sleepy','3','0.9m']
|
40
|
-
data.size.should ==
|
49
|
+
data.size.should == 3
|
41
50
|
end
|
42
51
|
|
43
52
|
it "Should allow access by integer" do
|
@@ -74,13 +83,13 @@ describe 'Parsing:' do
|
|
74
83
|
end
|
75
84
|
|
76
85
|
string = string[0..-5]
|
77
|
-
string.should == 'hello to Dopey and Sleepy'
|
86
|
+
string.should == 'hello to Dopey and Sleepy and Mr Grumpy'
|
78
87
|
end
|
79
88
|
|
80
89
|
it "Should provide more enumerable methods" do
|
81
90
|
total = data.inject(0) do |total, row|
|
82
91
|
total += row.age.to_i
|
83
92
|
end
|
84
|
-
total.should ==
|
93
|
+
total.should == 9
|
85
94
|
end
|
86
95
|
end
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omgcsv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- Edd Steel
|
@@ -9,8 +15,7 @@ autorequire:
|
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date:
|
13
|
-
default_executable:
|
18
|
+
date: 2012-02-26 00:00:00 Z
|
14
19
|
dependencies: []
|
15
20
|
|
16
21
|
description:
|
@@ -25,33 +30,41 @@ files:
|
|
25
30
|
- README.md
|
26
31
|
- LICENSE
|
27
32
|
- lib/omgcsv.rb
|
28
|
-
- spec/data.csv
|
29
33
|
- spec/test_spec.rb
|
30
|
-
|
34
|
+
- spec/data.csv
|
31
35
|
homepage: http://github.com/eddsteel/omgcsv
|
32
36
|
licenses: []
|
33
37
|
|
34
38
|
post_install_message:
|
35
|
-
rdoc_options:
|
36
|
-
|
39
|
+
rdoc_options:
|
40
|
+
- --line-numbers
|
41
|
+
- --inline-source
|
42
|
+
- --title
|
43
|
+
- OMG!CSV!
|
37
44
|
require_paths:
|
38
45
|
- lib
|
39
46
|
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
none: false
|
40
48
|
requirements:
|
41
49
|
- - ">="
|
42
50
|
- !ruby/object:Gem::Version
|
51
|
+
hash: 3
|
52
|
+
segments:
|
53
|
+
- 0
|
43
54
|
version: "0"
|
44
|
-
version:
|
45
55
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
46
57
|
requirements:
|
47
58
|
- - ">="
|
48
59
|
- !ruby/object:Gem::Version
|
60
|
+
hash: 3
|
61
|
+
segments:
|
62
|
+
- 0
|
49
63
|
version: "0"
|
50
|
-
version:
|
51
64
|
requirements: []
|
52
65
|
|
53
66
|
rubyforge_project:
|
54
|
-
rubygems_version: 1.
|
67
|
+
rubygems_version: 1.8.15
|
55
68
|
signing_key:
|
56
69
|
specification_version: 3
|
57
70
|
summary: Civilised CSV parsing
|