table_maker 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -2,7 +2,6 @@ GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
4
  git (1.2.5)
5
- jdbc-sqlite3 (3.6.14.2.056-java)
6
5
  jeweler (1.5.2)
7
6
  bundler (~> 1.0.0)
8
7
  git (>= 1.2.5)
@@ -11,6 +10,7 @@ GEM
11
10
  rcov (0.9.9)
12
11
  rcov (0.9.9-java)
13
12
  sequel (3.20.0)
13
+ sqlite3 (1.3.3)
14
14
 
15
15
  PLATFORMS
16
16
  java
@@ -18,7 +18,7 @@ PLATFORMS
18
18
 
19
19
  DEPENDENCIES
20
20
  bundler (~> 1.0.0)
21
- jdbc-sqlite3
22
21
  jeweler (~> 1.5.2)
23
22
  rcov
24
23
  sequel
24
+ sqlite3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.0
1
+ 0.0.1
data/lib/table_maker.rb CHANGED
@@ -19,7 +19,7 @@ class TableMaker
19
19
  line.strip!
20
20
  next if line =~ /^[-+|=]*$/
21
21
 
22
- parts = line.split(/\s*\|\s*/)
22
+ parts = line.split(/\|/).collect { |s| s.strip!; s == "" ? nil : s }
23
23
  parts.shift
24
24
 
25
25
  if @column_info.empty?
@@ -28,4 +28,48 @@ class TestTableMaker < Test::Unit::TestCase
28
28
  ]
29
29
  assert_equal expected, ds.select(:id, :foo, :bar, :baz).order(:id).all
30
30
  end
31
+
32
+ def test_manually_specified_id
33
+ db = Sequel.connect("#{RUBY_PLATFORM == 'java' ? "jdbc:" : ""}sqlite::memory:")
34
+ TableMaker.new(db, :foo, <<-EOF)
35
+ +-------------+-------------+-------------+--------------+
36
+ | id(Integer) | foo(String) | bar(String) | baz(Integer) |
37
+ +=============+=============+=============+==============+
38
+ | 31 | abc | def | 123 |
39
+ | 33 | ghi | jkl | 456 |
40
+ | 73 | mno | pqr | 789 |
41
+ | 13 | stu | vwx | 000 |
42
+ +-------------+-------------+-------------+--------------+
43
+ EOF
44
+ ds = db[:foo]
45
+ expected = [
46
+ {:id => 13, :foo => 'stu', :bar => 'vwx', :baz => 000},
47
+ {:id => 31, :foo => 'abc', :bar => 'def', :baz => 123},
48
+ {:id => 33, :foo => 'ghi', :bar => 'jkl', :baz => 456},
49
+ {:id => 73, :foo => 'mno', :bar => 'pqr', :baz => 789}
50
+ ]
51
+ assert_equal expected, ds.select(:id, :foo, :bar, :baz).order(:id).all
52
+ end
53
+
54
+ def test_blank_cells_are_null
55
+ db = Sequel.connect("#{RUBY_PLATFORM == 'java' ? "jdbc:" : ""}sqlite::memory:")
56
+ TableMaker.new(db, :foo, <<-EOF)
57
+ +-------------+-------------+--------------+
58
+ | foo(String) | bar(String) | baz(Integer) |
59
+ +=============+=============+==============+
60
+ | abc | | 123 |
61
+ | ghi | jkl | 456 |
62
+ | | pqr | |
63
+ | stu | vwx | 000 |
64
+ +-------------+-------------+--------------+
65
+ EOF
66
+ ds = db[:foo]
67
+ expected = [
68
+ {:id => 1, :foo => 'abc', :bar => nil, :baz => 123},
69
+ {:id => 2, :foo => 'ghi', :bar => 'jkl', :baz => 456},
70
+ {:id => 3, :foo => nil, :bar => 'pqr', :baz => nil},
71
+ {:id => 4, :foo => 'stu', :bar => 'vwx', :baz => 000}
72
+ ]
73
+ assert_equal expected, ds.select(:id, :foo, :bar, :baz).order(:id).all
74
+ end
31
75
  end
metadata CHANGED
@@ -1,11 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: table_maker
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.0.0
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
6
10
  platform: ruby
7
11
  authors:
8
- - Jeremy Stephens
12
+ - Jeremy Stephens
9
13
  autorequire:
10
14
  bindir: bin
11
15
  cert_chain: []
@@ -13,61 +17,75 @@ cert_chain: []
13
17
  date: 2011-03-01 00:00:00 -06:00
14
18
  default_executable:
15
19
  dependencies:
16
- - !ruby/object:Gem::Dependency
17
- name: sequel
18
- version_requirements: &id001 !ruby/object:Gem::Requirement
19
- none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: "0"
24
- requirement: *id001
25
- prerelease: false
26
- type: :runtime
27
- - !ruby/object:Gem::Dependency
28
- name: bundler
29
- version_requirements: &id002 !ruby/object:Gem::Requirement
30
- none: false
31
- requirements:
32
- - - ~>
33
- - !ruby/object:Gem::Version
34
- version: 1.0.0
35
- requirement: *id002
36
- prerelease: false
37
- type: :development
38
- - !ruby/object:Gem::Dependency
39
- name: jeweler
40
- version_requirements: &id003 !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ~>
44
- - !ruby/object:Gem::Version
45
- version: 1.5.2
46
- requirement: *id003
47
- prerelease: false
48
- type: :development
49
- - !ruby/object:Gem::Dependency
50
- name: rcov
51
- version_requirements: &id004 !ruby/object:Gem::Requirement
52
- none: false
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- version: "0"
57
- requirement: *id004
58
- prerelease: false
59
- type: :development
60
- - !ruby/object:Gem::Dependency
61
- name: jdbc-sqlite3
62
- version_requirements: &id005 !ruby/object:Gem::Requirement
63
- none: false
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- version: "0"
68
- requirement: *id005
69
- prerelease: false
70
- type: :development
20
+ - !ruby/object:Gem::Dependency
21
+ name: sequel
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ type: :runtime
31
+ prerelease: false
32
+ version_requirements: *id001
33
+ - !ruby/object:Gem::Dependency
34
+ name: bundler
35
+ requirement: &id002 !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ segments:
41
+ - 1
42
+ - 0
43
+ - 0
44
+ version: 1.0.0
45
+ type: :development
46
+ prerelease: false
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: jeweler
50
+ requirement: &id003 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ~>
54
+ - !ruby/object:Gem::Version
55
+ segments:
56
+ - 1
57
+ - 5
58
+ - 2
59
+ version: 1.5.2
60
+ type: :development
61
+ prerelease: false
62
+ version_requirements: *id003
63
+ - !ruby/object:Gem::Dependency
64
+ name: rcov
65
+ requirement: &id004 !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ segments:
71
+ - 0
72
+ version: "0"
73
+ type: :development
74
+ prerelease: false
75
+ version_requirements: *id004
76
+ - !ruby/object:Gem::Dependency
77
+ name: sqlite3
78
+ requirement: &id005 !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ segments:
84
+ - 0
85
+ version: "0"
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: *id005
71
89
  description: Simple ASCII table importer for Sequel
72
90
  email: viking@pillageandplunder.net
73
91
  executables: []
@@ -75,50 +93,52 @@ executables: []
75
93
  extensions: []
76
94
 
77
95
  extra_rdoc_files:
78
- - LICENSE.txt
79
- - README.rdoc
96
+ - LICENSE.txt
97
+ - README.rdoc
80
98
  files:
81
- - .document
82
- - Gemfile
83
- - Gemfile.lock
84
- - LICENSE.txt
85
- - README.rdoc
86
- - Rakefile
87
- - VERSION
88
- - lib/table_maker.rb
89
- - test/helper.rb
90
- - test/test_table_maker.rb
99
+ - .document
100
+ - Gemfile
101
+ - Gemfile.lock
102
+ - LICENSE.txt
103
+ - README.rdoc
104
+ - Rakefile
105
+ - VERSION
106
+ - lib/table_maker.rb
107
+ - test/helper.rb
108
+ - test/test_table_maker.rb
91
109
  has_rdoc: true
92
110
  homepage: http://github.com/viking/table_maker
93
111
  licenses:
94
- - MIT
112
+ - MIT
95
113
  post_install_message:
96
114
  rdoc_options: []
97
115
 
98
116
  require_paths:
99
- - lib
117
+ - lib
100
118
  required_ruby_version: !ruby/object:Gem::Requirement
101
119
  none: false
102
120
  requirements:
103
- - - ">="
104
- - !ruby/object:Gem::Version
105
- hash: 2
106
- segments:
107
- - 0
108
- version: "0"
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ hash: 3180758858338140348
124
+ segments:
125
+ - 0
126
+ version: "0"
109
127
  required_rubygems_version: !ruby/object:Gem::Requirement
110
128
  none: false
111
129
  requirements:
112
- - - ">="
113
- - !ruby/object:Gem::Version
114
- version: "0"
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ segments:
133
+ - 0
134
+ version: "0"
115
135
  requirements: []
116
136
 
117
137
  rubyforge_project:
118
- rubygems_version: 1.5.0
138
+ rubygems_version: 1.3.7
119
139
  signing_key:
120
140
  specification_version: 3
121
141
  summary: Simple ASCII table importer for Sequel
122
142
  test_files:
123
- - test/helper.rb
124
- - test/test_table_maker.rb
143
+ - test/helper.rb
144
+ - test/test_table_maker.rb