scsv 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,9 @@
1
+ === 0.2.0 2010-01-23
2
+
3
+ * bug fix
4
+ * add tests
5
+
1
6
  === 0.1.0 2010-01-23
2
7
 
3
8
  * first release
9
+
@@ -10,7 +10,5 @@ script/destroy
10
10
  script/destroy.cmd
11
11
  script/generate
12
12
  script/generate.cmd
13
- spec/scsv_spec.rb
14
- spec/spec.opts
15
- spec/spec_helper.rb
16
- tasks/rspec.rake
13
+ test/test_scsv.rb
14
+ test/test_helper.rb
@@ -5,7 +5,7 @@ $:.unshift(File.dirname(__FILE__)) unless
5
5
  # for COMMA separated file
6
6
  #
7
7
  class SCSV
8
- VERSION = '0.1.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
- p options = DEFAULT_OPTIONS.merge(options)
17
+ options = DEFAULT_OPTIONS.merge(options)
18
18
  if block_given?
19
19
  parse_with_block(filename, options, &block)
20
20
  else
@@ -0,0 +1,3 @@
1
+ require 'stringio'
2
+ require 'test/unit'
3
+ require File.dirname(__FILE__) + '/../lib/scsv'
@@ -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.1.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
- - spec/scsv_spec.rb
70
- - spec/spec.opts
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
@@ -1,11 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
2
-
3
- # Time to add your specs!
4
- # http://rspec.info/
5
- describe "Place your specs here" do
6
-
7
- it "find this spec in spec directory" do
8
- # violated "Be sure to write your specs"
9
- end
10
-
11
- end
@@ -1 +0,0 @@
1
- --colour
@@ -1,10 +0,0 @@
1
- begin
2
- require 'spec'
3
- rescue LoadError
4
- require 'rubygems' unless ENV['NO_RUBYGEMS']
5
- gem 'rspec'
6
- require 'spec'
7
- end
8
-
9
- $:.unshift(File.dirname(__FILE__) + '/../lib')
10
- require 'scsv'
@@ -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