scsv 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -0
- data/Manifest.txt +2 -4
- data/lib/scsv.rb +2 -2
- data/test/test_helper.rb +3 -0
- data/test/test_scsv.rb +51 -0
- metadata +6 -7
- data/spec/scsv_spec.rb +0 -11
- data/spec/spec.opts +0 -1
- data/spec/spec_helper.rb +0 -10
- data/tasks/rspec.rake +0 -21
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
data/lib/scsv.rb
CHANGED
@@ -5,7 +5,7 @@ $:.unshift(File.dirname(__FILE__)) unless
|
|
5
5
|
# for COMMA separated file
|
6
6
|
#
|
7
7
|
class SCSV
|
8
|
-
VERSION = '0.
|
8
|
+
VERSION = '0.2.0'
|
9
9
|
|
10
10
|
DEFAULT_OPTIONS = {
|
11
11
|
:col_sep => ",",
|
@@ -14,7 +14,7 @@ class SCSV
|
|
14
14
|
}
|
15
15
|
|
16
16
|
def self.parse(filename, options = {}, &block)
|
17
|
-
|
17
|
+
options = DEFAULT_OPTIONS.merge(options)
|
18
18
|
if block_given?
|
19
19
|
parse_with_block(filename, options, &block)
|
20
20
|
else
|
data/test/test_helper.rb
ADDED
data/test/test_scsv.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class TestAbc < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_parse_csv_with_block
|
9
|
+
SCSV.parse("test/_data/csv_has_header.txt") do |row|
|
10
|
+
assert_instance_of Hash, row
|
11
|
+
end
|
12
|
+
|
13
|
+
SCSV.parse("test/_data/csv_has_no_header.txt", {:header => false}) do |row|
|
14
|
+
assert_instance_of Array, row
|
15
|
+
end
|
16
|
+
|
17
|
+
SCSV.parse("test/_data/csv_has_no_header.txt", {:header => ["h1", "h2", "h3"]}) do |row|
|
18
|
+
assert_instance_of Hash, row
|
19
|
+
end
|
20
|
+
|
21
|
+
SCSV.parse("test/_data/csv_japanese_utf8.txt") do |row|
|
22
|
+
assert_instance_of Hash, row
|
23
|
+
end
|
24
|
+
|
25
|
+
SCSV.parse("test/_data/tsv.txt", {:col_sep => "\t"}) do |row|
|
26
|
+
assert_instance_of Hash, row
|
27
|
+
end
|
28
|
+
STSV.parse("test/_data/tsv.txt") do |row|
|
29
|
+
assert_instance_of Hash, row
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_parse_csv_with_no_block
|
34
|
+
csv = SCSV.parse("test/_data/csv_has_header.txt")
|
35
|
+
assert_instance_of Array, csv
|
36
|
+
|
37
|
+
csv = SCSV.parse("test/_data/csv_has_no_header.txt", {:header => false})
|
38
|
+
assert_instance_of Array, csv
|
39
|
+
|
40
|
+
csv = SCSV.parse("test/_data/csv_has_no_header.txt", {:header => ["h1", "h2", "h3"]})
|
41
|
+
assert_instance_of Array, csv
|
42
|
+
|
43
|
+
csv = SCSV.parse("test/_data/csv_japanese_utf8.txt")
|
44
|
+
assert_instance_of Array, csv
|
45
|
+
|
46
|
+
csv = SCSV.parse("test/_data/tsv.txt", {:col_sep => "\t"})
|
47
|
+
assert_instance_of Array, csv
|
48
|
+
csv = STSV.parse("test/_data/tsv.txt")
|
49
|
+
assert_instance_of Array, csv
|
50
|
+
end
|
51
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scsv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kinumi
|
@@ -66,10 +66,8 @@ files:
|
|
66
66
|
- script/destroy.cmd
|
67
67
|
- script/generate
|
68
68
|
- script/generate.cmd
|
69
|
-
-
|
70
|
-
-
|
71
|
-
- spec/spec_helper.rb
|
72
|
-
- tasks/rspec.rake
|
69
|
+
- test/test_scsv.rb
|
70
|
+
- test/test_helper.rb
|
73
71
|
has_rdoc: true
|
74
72
|
homepage: http://github.com/kinumi/scsv
|
75
73
|
licenses: []
|
@@ -99,5 +97,6 @@ rubygems_version: 1.3.5
|
|
99
97
|
signing_key:
|
100
98
|
specification_version: 3
|
101
99
|
summary: A simple CSV(and TSV) parser to convert line into the Hash using header info.
|
102
|
-
test_files:
|
103
|
-
|
100
|
+
test_files:
|
101
|
+
- test/test_helper.rb
|
102
|
+
- test/test_scsv.rb
|
data/spec/scsv_spec.rb
DELETED
data/spec/spec.opts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--colour
|
data/spec/spec_helper.rb
DELETED
data/tasks/rspec.rake
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
require 'spec'
|
3
|
-
rescue LoadError
|
4
|
-
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
5
|
-
require 'spec'
|
6
|
-
end
|
7
|
-
begin
|
8
|
-
require 'spec/rake/spectask'
|
9
|
-
rescue LoadError
|
10
|
-
puts <<-EOS
|
11
|
-
To use rspec for testing you must install rspec gem:
|
12
|
-
gem install rspec
|
13
|
-
EOS
|
14
|
-
exit(0)
|
15
|
-
end
|
16
|
-
|
17
|
-
desc "Run the specs under spec/models"
|
18
|
-
Spec::Rake::SpecTask.new do |t|
|
19
|
-
t.spec_opts = ['--options', "spec/spec.opts"]
|
20
|
-
t.spec_files = FileList['spec/**/*_spec.rb']
|
21
|
-
end
|