chugalug 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +1 -0
- data/LICENSE +184 -0
- data/Manifest +15 -0
- data/README +12 -0
- data/Rakefile +9 -0
- data/chugalug.gemspec +32 -0
- data/ext/chugalug.c +79 -0
- data/ext/csv.h +86 -0
- data/ext/extconf.rb +3 -0
- data/ext/libcsv.c +579 -0
- data/test/data.csv +1000000 -0
- data/test/data_small.csv +20 -0
- data/test/easy.csv +2 -0
- data/test/messages.csv +100000 -0
- data/test/quoted_values.csv +2 -0
- data/test/unit/test_chugalug.rb +69 -0
- metadata +90 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
|
|
2
|
+
require 'test/unit'
|
|
3
|
+
require 'chugalug'
|
|
4
|
+
require 'benchmark'
|
|
5
|
+
|
|
6
|
+
# Yeah, I know.
|
|
7
|
+
begin
|
|
8
|
+
require 'csv'
|
|
9
|
+
require 'rubygems'
|
|
10
|
+
require 'fastercsv'
|
|
11
|
+
require 'lightcsv'
|
|
12
|
+
require 'csvscan'
|
|
13
|
+
|
|
14
|
+
module CSVScan
|
|
15
|
+
def self.foreach(file, &block)
|
|
16
|
+
open(file) do |f|
|
|
17
|
+
scan(f, &block)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
rescue LoadError
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
class TestCcsv < Test::Unit::TestCase
|
|
26
|
+
|
|
27
|
+
def setup
|
|
28
|
+
@dir = "#{File.dirname(__FILE__)}/../"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_should_raise
|
|
32
|
+
assert_raises(RuntimeError) do
|
|
33
|
+
Chugalug.foreach('fdssfd') do
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def test_accuracy
|
|
39
|
+
# chugalug = []
|
|
40
|
+
# file = @dir + "data_small.csv"
|
|
41
|
+
# Chugalug.foreach(file) do |values|
|
|
42
|
+
# chugalug << values.dup
|
|
43
|
+
# end
|
|
44
|
+
#
|
|
45
|
+
# csv = []
|
|
46
|
+
# CSV.foreach(file) do |values|
|
|
47
|
+
# csv << values
|
|
48
|
+
# end
|
|
49
|
+
#
|
|
50
|
+
# assert_equal csv, chugalug
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def test_speed
|
|
54
|
+
# [Chugalug, FasterCSV, CSV].each do |klass| # CSVScan, LightCsv,
|
|
55
|
+
# Benchmark.bm do |x|
|
|
56
|
+
# x.report(klass.name) do
|
|
57
|
+
# klass.foreach(@dir + "data.csv") do |values| end
|
|
58
|
+
# end
|
|
59
|
+
# end
|
|
60
|
+
# end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def test_quoted_values
|
|
64
|
+
file = @dir + "easy.csv"
|
|
65
|
+
Chugalug.foreach(file) do |values|
|
|
66
|
+
puts values.inspect
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: chugalug
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
prerelease: false
|
|
5
|
+
segments:
|
|
6
|
+
- 0
|
|
7
|
+
- 0
|
|
8
|
+
- 1
|
|
9
|
+
version: 0.0.1
|
|
10
|
+
platform: ruby
|
|
11
|
+
authors:
|
|
12
|
+
- Josh Ferguson
|
|
13
|
+
autorequire:
|
|
14
|
+
bindir: bin
|
|
15
|
+
cert_chain: []
|
|
16
|
+
|
|
17
|
+
date: 2010-05-15 00:00:00 -07:00
|
|
18
|
+
default_executable:
|
|
19
|
+
dependencies: []
|
|
20
|
+
|
|
21
|
+
description: A wrapper around libcsv.
|
|
22
|
+
email: josh@besquared.net
|
|
23
|
+
executables: []
|
|
24
|
+
|
|
25
|
+
extensions:
|
|
26
|
+
- ext/extconf.rb
|
|
27
|
+
extra_rdoc_files:
|
|
28
|
+
- CHANGELOG
|
|
29
|
+
- LICENSE
|
|
30
|
+
- README
|
|
31
|
+
- ext/chugalug.c
|
|
32
|
+
- ext/csv.h
|
|
33
|
+
- ext/extconf.rb
|
|
34
|
+
- ext/libcsv.c
|
|
35
|
+
files:
|
|
36
|
+
- CHANGELOG
|
|
37
|
+
- LICENSE
|
|
38
|
+
- Manifest
|
|
39
|
+
- README
|
|
40
|
+
- Rakefile
|
|
41
|
+
- ext/chugalug.c
|
|
42
|
+
- ext/csv.h
|
|
43
|
+
- ext/extconf.rb
|
|
44
|
+
- ext/libcsv.c
|
|
45
|
+
- test/data.csv
|
|
46
|
+
- test/data_small.csv
|
|
47
|
+
- test/easy.csv
|
|
48
|
+
- test/messages.csv
|
|
49
|
+
- test/quoted_values.csv
|
|
50
|
+
- test/unit/test_chugalug.rb
|
|
51
|
+
- chugalug.gemspec
|
|
52
|
+
has_rdoc: true
|
|
53
|
+
homepage: http://www.github.com/besquared/chugalug/
|
|
54
|
+
licenses: []
|
|
55
|
+
|
|
56
|
+
post_install_message:
|
|
57
|
+
rdoc_options:
|
|
58
|
+
- --line-numbers
|
|
59
|
+
- --inline-source
|
|
60
|
+
- --title
|
|
61
|
+
- Chugalug
|
|
62
|
+
- --main
|
|
63
|
+
- README
|
|
64
|
+
require_paths:
|
|
65
|
+
- lib
|
|
66
|
+
- ext
|
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
68
|
+
requirements:
|
|
69
|
+
- - ">="
|
|
70
|
+
- !ruby/object:Gem::Version
|
|
71
|
+
segments:
|
|
72
|
+
- 0
|
|
73
|
+
version: "0"
|
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
|
+
requirements:
|
|
76
|
+
- - ">="
|
|
77
|
+
- !ruby/object:Gem::Version
|
|
78
|
+
segments:
|
|
79
|
+
- 1
|
|
80
|
+
- 2
|
|
81
|
+
version: "1.2"
|
|
82
|
+
requirements: []
|
|
83
|
+
|
|
84
|
+
rubyforge_project: Besquared
|
|
85
|
+
rubygems_version: 1.3.6
|
|
86
|
+
signing_key:
|
|
87
|
+
specification_version: 3
|
|
88
|
+
summary: A wrapper around libcsv.
|
|
89
|
+
test_files:
|
|
90
|
+
- test/unit/test_chugalug.rb
|