fasterer-csv 1.6.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -1,3 +1,3 @@
1
- Mockyright (m) 2010 Mason
1
+ Monkeyright (m) 2010 Mason
2
2
 
3
3
  Permission is hereby granted.
@@ -6,21 +6,9 @@ Depends on various stuff and such it almost always reads at least twice as fast,
6
6
 
7
7
  It's got some caveats, though... which you'll discover in fun and entertaining ways.
8
8
 
9
- Also, it's not *completely* a drop in replacement, but it's really really close. Why do it this way? Because I hate you and want to make you life a little more difficult whenever possible.
9
+ Also, it's not *completely* a drop in replacement, but it's really really close. Why do it this way? To be contrary.
10
10
 
11
-
12
- == Note on Patches/Pull Requests
13
-
14
- * Spoon the project.
15
- * Make your feature addition or bug fix.
16
- * Add tests for it. This is important so I don't break it in a
17
- future version unintentionally.
18
- * Commit, do not mess with rakefile, version, or history.
19
- (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
20
- * Send me a pull request.
21
- * Delete everything you've done at the point because I'm probably going to reimplement it anyways.
22
-
23
- == Monkyright
11
+ == Monkeyright
24
12
 
25
13
  Monkeyright (m) 2010 Mason. See LICENSE for details.
26
14
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.6.0
1
+ 2.0.0
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{fasterer-csv}
8
- s.version = "1.6.0"
8
+ s.version = "2.0.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Mason"]
@@ -159,6 +159,7 @@ module FastererCSV
159
159
 
160
160
  def pull(*columns)
161
161
  columns.map do |column|
162
+ column = [nil] if column.nil?
162
163
  self[*column]
163
164
  end
164
165
  end
@@ -221,13 +222,13 @@ module FastererCSV
221
222
  end
222
223
 
223
224
  def <<(ch)
224
- if ch == ?-
225
+ if ch == ?-.ord
225
226
  @float = @int = size == 0
226
- elsif (ch > ?9 || ch < ?0) && ch != ?.
227
+ elsif (ch > ?9.ord || ch < ?0.ord) && ch != ?..ord
227
228
  @int = @float = false
228
- elsif ch == ?. && @dot
229
+ elsif ch == ?..ord && @dot
229
230
  @int = @float = false
230
- elsif ch == ?.
231
+ elsif ch == ?..ord
231
232
  @int = false
232
233
  @dot = true
233
234
  end
@@ -304,21 +305,21 @@ module FastererCSV
304
305
  end
305
306
 
306
307
  def parse(data, quot = '~', sep = ',', fail_on_malformed = true, column = NoConversion.new)
307
- q, s, row, inquot, clean, maybe, table, field, endline = quot[0], sep[0], [], false, true, false, nil, true, false
308
+ q, s, row, inquot, clean, maybe, table, field, endline = quot.ord, sep.ord, [], false, true, false, nil, true, false
308
309
 
309
310
  data.each_byte do |c|
310
- next if c == ?\r
311
+ next if c == ?\r.ord
311
312
 
312
313
  if maybe && c == s
313
314
  row << column.convert(true)
314
315
  column.clear
315
316
  clean, inquot, maybe, field, endline = true, false, false, true, false
316
- elsif maybe && c == ?\n && table.nil?
317
+ elsif maybe && c == ?\n.ord && table.nil?
317
318
  row << column.convert(true) unless (column.empty? && endline)
318
319
  column.clear
319
320
  table = Table.new(row, fail_on_malformed) unless row.empty?
320
321
  row, clean, inquot, maybe, field, endline = [], true, false, false, false, true
321
- elsif maybe && c == ?\n
322
+ elsif maybe && c == ?\n.ord
322
323
  row << column.convert(true) unless (column.empty? && endline)
323
324
  column.clear
324
325
  table << row unless row.empty?
@@ -337,14 +338,14 @@ module FastererCSV
337
338
  row << column.convert(false)
338
339
  column.clear
339
340
  clean, field, endline = true, true, false
340
- elsif c == ?\n && table.nil?
341
+ elsif c == ?\n.ord && table.nil?
341
342
 
342
343
  row << column.convert(false) unless column.empty? && endline
343
344
 
344
345
  column.clear
345
346
  table = Table.new(row, fail_on_malformed) unless row.empty?
346
347
  row, clean, inquot, field, endline = [], true, false, false, true
347
- elsif c == ?\n
348
+ elsif c == ?\n.ord
348
349
 
349
350
  row << column.convert(false) unless column.empty? && endline
350
351
 
@@ -21,7 +21,7 @@ describe "FastererCSV" do
21
21
  it "works" do
22
22
 
23
23
  conv = FastererCSV::NumericConversion.new
24
- conv << ?1
24
+ conv << ?1.ord
25
25
  conv.convert(true).class.should == String
26
26
  conv.convert(true).should == "1"
27
27
 
@@ -29,37 +29,37 @@ describe "FastererCSV" do
29
29
  conv.convert(false).should == 1
30
30
 
31
31
  conv.clear
32
- conv << ?-
33
- conv << ?1
32
+ conv << ?-.ord
33
+ conv << ?1.ord
34
34
  conv.convert(false).class.should == Fixnum
35
35
  conv.convert(false).should == -1
36
36
 
37
37
  conv.clear
38
- conv << ?1
39
- conv << ?.
40
- conv << ?1
38
+ conv << ?1.ord
39
+ conv << ?..ord
40
+ conv << ?1.ord
41
41
  conv.convert(false).class.should == Float
42
42
  conv.convert(false).should == 1.1
43
43
 
44
44
  conv.clear
45
- conv << ?-
46
- conv << ?1
47
- conv << ?.
48
- conv << ?1
45
+ conv << ?-.ord
46
+ conv << ?1.ord
47
+ conv << ?..ord
48
+ conv << ?1.ord
49
49
  conv.convert(false).class.should == Float
50
50
  conv.convert(false).should == -1.1
51
51
 
52
52
  conv.clear
53
- conv << ?1
54
- conv << ?.
55
- conv << ?1
56
- conv << ?.
57
- conv << ?1
53
+ conv << ?1.ord
54
+ conv << ?..ord
55
+ conv << ?1.ord
56
+ conv << ?..ord
57
+ conv << ?1.ord
58
58
  conv.convert(false).class.should == String
59
59
  conv.convert(false).should == "1.1.1"
60
60
 
61
61
  conv.clear
62
- conv << ?a
62
+ conv << ?a.ord
63
63
  conv.convert(false).class.should == String
64
64
  conv.convert(false).should == "a"
65
65
 
@@ -74,7 +74,7 @@ describe "FastererCSV" do
74
74
  it "works" do
75
75
 
76
76
  conv = FastererCSV::NoConversion.new
77
- conv << ?1
77
+ conv << ?1.ord
78
78
  conv.convert(true).class.should == String
79
79
  conv.convert(false).class.should == String
80
80
 
@@ -105,11 +105,11 @@ a,b,c,d,e,f,g,h,i,j,k,l,m,
105
105
  describe "parse" do
106
106
  it "works" do
107
107
  table = FastererCSV.parse(@data)
108
- table.headers.should == [:a, :b, :c,:d,:e,:f,:g,:h,:i,:j,:k,:l,:m,:_]
108
+ table.headers.should == [:a, :b, :c, :d, :e, :f, :g, :h, :i, :j, :k, :l, :m, :_]
109
109
  table.lines.should == 2
110
110
 
111
- table[0].should == [nil, nil, "1", "1.1", "-1", "-1.1", "1.1.1", "1", "a", "a", "a~a", "a\n~a", ",", nil]
112
- table[1].should == ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "14"]
111
+ table[0].should == [nil, nil, "1", "1.1", "-1", "-1.1", "1.1.1", "1", "a", "a", "a~a", "a\n~a", ",", nil ]
112
+ table[1].should == ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "14"]
113
113
 
114
114
  row = table[1]
115
115
  row.pull(:a, nil, 'd').should == ["0","14","3"]
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fasterer-csv
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
5
- prerelease: false
6
- segments:
7
- - 1
8
- - 6
9
- - 0
10
- version: 1.6.0
4
+ prerelease:
5
+ version: 2.0.0
11
6
  platform: ruby
12
7
  authors:
13
8
  - Mason
@@ -15,7 +10,7 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2010-07-02 00:00:00 -07:00
13
+ date: 2010-07-02 00:00:00 -05:00
19
14
  default_executable:
20
15
  dependencies: []
21
16
 
@@ -76,23 +71,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
76
71
  requirements:
77
72
  - - ">="
78
73
  - !ruby/object:Gem::Version
79
- hash: 3
80
- segments:
81
- - 0
82
74
  version: "0"
83
75
  required_rubygems_version: !ruby/object:Gem::Requirement
84
76
  none: false
85
77
  requirements:
86
78
  - - ">="
87
79
  - !ruby/object:Gem::Version
88
- hash: 3
89
- segments:
90
- - 0
91
80
  version: "0"
92
81
  requirements: []
93
82
 
94
83
  rubyforge_project:
95
- rubygems_version: 1.3.7
84
+ rubygems_version: 1.5.2
96
85
  signing_key:
97
86
  specification_version: 3
98
87
  summary: Even fasterer than FasterCSV!