comma-heaven 0.8.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.0
1
+ 0.8.1
data/comma-heaven.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "comma-heaven"
8
- s.version = "0.8.0"
8
+ s.version = "0.8.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Silvano Stralla"]
12
- s.date = "2012-11-14"
12
+ s.date = "2013-04-16"
13
13
  s.description = "CommaHeaven permits easy exports of Rails models to CSV"
14
14
  s.email = "silvano.stralla@sistrall.it"
15
15
  s.extra_rdoc_files = [
@@ -49,7 +49,7 @@ Gem::Specification.new do |s|
49
49
  s.homepage = "http://github.com/sistrall/comma-heaven"
50
50
  s.licenses = ["MIT"]
51
51
  s.require_paths = ["lib"]
52
- s.rubygems_version = "1.8.13"
52
+ s.rubygems_version = "1.8.23"
53
53
  s.summary = "CSV exporter for Rails"
54
54
 
55
55
  if s.respond_to? :specification_version then
@@ -34,7 +34,13 @@ module CommaHeaven
34
34
  def table_alias(method = :pluralize)
35
35
  t = case self
36
36
  when HasManyColumns, BelongsToColumns, HasOneColumns then association.name.to_s.send(method)
37
- else table.to_s.send(method)
37
+ else
38
+ case method
39
+ when :pluralize
40
+ model.table_name.send(method)
41
+ else
42
+ model.name.underscore
43
+ end
38
44
  end
39
45
 
40
46
  return prefix + [((parent && parent.parent) ? parent.table_alias(method) : nil), t, index].compact.join('_')
@@ -230,7 +230,8 @@ EOS
230
230
  end
231
231
 
232
232
  it "should allow denormalized export (also called 'by row')" do
233
- Tree.to_comma_heaven(:export => {:name => {0 => {:include => '1', :as => ''}}, :age => {1 => {:include => '0', :as => ''}}, :leafs => {2 => {:export => {:position => {4 => {:include => '1', :as => ''}}}, :by => 'row', :limit => 3}}}).to_csv.should == <<-EOS
233
+ csv = Tree.to_comma_heaven(:export => {:name => {0 => {:include => '1', :as => ''}}, :age => {1 => {:include => '0', :as => ''}}, :leafs => {2 => {:export => {:position => {4 => {:include => '1', :as => ''}}}, :by => 'row', :limit => 3}}}).to_csv
234
+ ref = <<-EOS
234
235
  tree_name,leaf_position
235
236
  Olmo,bottom
236
237
  Olmo,middle
@@ -238,10 +239,12 @@ Olmo,top
238
239
  Ulivo,0
239
240
  Ulivo,5
240
241
  EOS
242
+ csv.split(/\n/).sort.should == ref.split(/\n/).sort
241
243
  end
242
244
 
243
245
  it "should allow denormalized export (also called 'by row')" do
244
- Tree.to_comma_heaven(:export => {:name => {0 => {:include => '1', :as => ''}}, :age => {1 => {:include => '0', :as => ''}}, :leafs => {2 => {:export => {:position => {4 => {:include => '1', :as => ''}}}, :by => 'row', :limit => 3}}}).to_csv.should == <<-EOS
246
+ csv = Tree.to_comma_heaven(:export => {:name => {0 => {:include => '1', :as => ''}}, :age => {1 => {:include => '0', :as => ''}}, :leafs => {2 => {:export => {:position => {4 => {:include => '1', :as => ''}}}, :by => 'row', :limit => 3}}}).to_csv
247
+ ref = <<-EOS
245
248
  tree_name,leaf_position
246
249
  Olmo,bottom
247
250
  Olmo,middle
@@ -249,8 +252,10 @@ Olmo,top
249
252
  Ulivo,0
250
253
  Ulivo,5
251
254
  EOS
255
+ csv.split(/\n/).sort.should == ref.split(/\n/).sort
252
256
 
253
- Tree.to_comma_heaven(:export => {:name => {0 => {}}, :gardener => {1 => {:export => {:name => {2 => {}}, :surname => {3 => {}}}}}, :leafs => {4 => {:export => {:position => {5 => {}}}, :by => 'row', :limit => 2}}}).to_csv.should == <<-EOS
257
+ csv = Tree.to_comma_heaven(:export => {:name => {0 => {}}, :gardener => {1 => {:export => {:name => {2 => {}}, :surname => {3 => {}}}}}, :leafs => {4 => {:export => {:position => {5 => {}}}, :by => 'row', :limit => 2}}}).to_csv
258
+ ref = <<-EOS
254
259
  tree_name,gardener_name,gardener_surname,leaf_position
255
260
  Olmo,Alice,,bottom
256
261
  Olmo,Alice,,middle
@@ -258,6 +263,7 @@ Olmo,Alice,,top
258
263
  Ulivo,Bob,,0
259
264
  Ulivo,Bob,,5
260
265
  EOS
266
+ csv.split(/\n/).sort.should == ref.split(/\n/).sort
261
267
  end
262
268
 
263
269
 
data/spec/spec_helper.rb CHANGED
@@ -41,7 +41,7 @@ RSpec.configure do |config|
41
41
  t.integer :gardener_id
42
42
  end
43
43
 
44
- create_table :leafs do |t|
44
+ create_table :leaves do |t|
45
45
  t.integer :tree_id
46
46
  t.string :position
47
47
  t.float :size
@@ -86,6 +86,8 @@ RSpec.configure do |config|
86
86
  end
87
87
 
88
88
  class Leaf < ActiveRecord::Base
89
+ self.table_name = 'leaves'
90
+
89
91
  belongs_to :tree
90
92
  has_many :cells
91
93
  end
@@ -113,7 +115,7 @@ RSpec.configure do |config|
113
115
  drop_table :gardeners
114
116
  drop_table :gardener_clones
115
117
  drop_table :trees
116
- drop_table :leafs
118
+ drop_table :leaves
117
119
  drop_table :cells
118
120
  end
119
121
  end
@@ -15,7 +15,7 @@ describe "BelongsToColumns" do
15
15
  column = CommaHeaven::Sqler::BelongsToColumns.new(@association, {:age => {4 => {:include => '1', :as => ''}}}, 1, @leaf)
16
16
  column.joins.should == <<-EOS.gsub(/\n/, ' ').squeeze(' ').strip
17
17
  LEFT JOIN "trees" AS _trees
18
- ON _trees.id = leafs.tree_id
18
+ ON _trees.id = leaves.tree_id
19
19
  EOS
20
20
  end
21
21
  end
@@ -19,9 +19,9 @@ describe "HasManyColumns" do
19
19
  it "should build correct SQL joins clause" do
20
20
  column = CommaHeaven::Sqler::HasManyColumns.new(@association, {:position => {4 => {:include => '1', :as => ''}}}, 1, @tree, 1, :limit => '3')
21
21
  column.joins.should == <<-EOS.gsub(/\n/, ' ').squeeze(' ').strip
22
- LEFT JOIN "leafs" AS _leafs_1
22
+ LEFT JOIN "leaves" AS _leafs_1
23
23
  ON trees.id = _leafs_1.tree_id
24
- AND _leafs_1.id = (SELECT id FROM "leafs" WHERE tree_id = trees.id LIMIT 1, 1)
24
+ AND _leafs_1.id = (SELECT id FROM "leaves" WHERE tree_id = trees.id LIMIT 1, 1)
25
25
  EOS
26
26
  end
27
27
 
@@ -34,12 +34,12 @@ EOS
34
34
  column.joins.should == <<-EOS.gsub(/\n/, ' ').squeeze(' ').strip
35
35
  LEFT JOIN trees AS _trees_leafs_0
36
36
  ON gardeners.id = _trees_leafs_0.gardener_id
37
- LEFT JOIN "leafs" AS _leafs_0
37
+ LEFT JOIN "leaves" AS _leafs_0
38
38
  ON _trees_leafs_0.id = _leafs_0.tree_id
39
39
  AND _leafs_0.id =
40
- ( SELECT "leafs".id
41
- FROM "leafs"
42
- JOIN trees ON "leafs".tree_id = trees.id
40
+ ( SELECT "leaves".id
41
+ FROM "leaves"
42
+ JOIN trees ON "leaves".tree_id = trees.id
43
43
  WHERE gardener_id = gardeners.id LIMIT 0, 1 )
44
44
  EOS
45
45
  end
metadata CHANGED
@@ -1,137 +1,184 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: comma-heaven
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.8.0
5
+ version: 0.8.1
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Silvano Stralla
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2012-11-14 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2013-04-16 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ prerelease: false
16
16
  name: activerecord
17
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ type: :runtime
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - <
21
+ - !ruby/object:Gem::Version
22
+ version: 4.0.0
18
23
  none: false
19
- requirements:
24
+ requirement: !ruby/object:Gem::Requirement
25
+ requirements:
20
26
  - - <
21
- - !ruby/object:Gem::Version
27
+ - !ruby/object:Gem::Version
22
28
  version: 4.0.0
23
- type: :runtime
29
+ none: false
30
+ - !ruby/object:Gem::Dependency
24
31
  prerelease: false
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
27
32
  name: actionpack
28
- requirement: &id002 !ruby/object:Gem::Requirement
33
+ type: :runtime
34
+ version_requirements: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - <
37
+ - !ruby/object:Gem::Version
38
+ version: 4.0.0
29
39
  none: false
30
- requirements:
40
+ requirement: !ruby/object:Gem::Requirement
41
+ requirements:
31
42
  - - <
32
- - !ruby/object:Gem::Version
43
+ - !ruby/object:Gem::Version
33
44
  version: 4.0.0
34
- type: :runtime
45
+ none: false
46
+ - !ruby/object:Gem::Dependency
35
47
  prerelease: false
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
38
48
  name: rspec
39
- requirement: &id003 !ruby/object:Gem::Requirement
49
+ type: :development
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 1.2.9
40
55
  none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ! '>='
59
+ - !ruby/object:Gem::Version
44
60
  version: 1.2.9
45
- type: :development
61
+ none: false
62
+ - !ruby/object:Gem::Dependency
46
63
  prerelease: false
47
- version_requirements: *id003
48
- - !ruby/object:Gem::Dependency
49
64
  name: rdoc
50
- requirement: &id004 !ruby/object:Gem::Requirement
65
+ type: :development
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ~>
69
+ - !ruby/object:Gem::Version
70
+ version: '3.12'
51
71
  none: false
52
- requirements:
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
53
74
  - - ~>
54
- - !ruby/object:Gem::Version
55
- version: "3.12"
56
- type: :development
75
+ - !ruby/object:Gem::Version
76
+ version: '3.12'
77
+ none: false
78
+ - !ruby/object:Gem::Dependency
57
79
  prerelease: false
58
- version_requirements: *id004
59
- - !ruby/object:Gem::Dependency
60
80
  name: bundler
61
- requirement: &id005 !ruby/object:Gem::Requirement
81
+ type: :development
82
+ version_requirements: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: 1.0.0
62
87
  none: false
63
- requirements:
64
- - - ">="
65
- - !ruby/object:Gem::Version
88
+ requirement: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ! '>='
91
+ - !ruby/object:Gem::Version
66
92
  version: 1.0.0
67
- type: :development
93
+ none: false
94
+ - !ruby/object:Gem::Dependency
68
95
  prerelease: false
69
- version_requirements: *id005
70
- - !ruby/object:Gem::Dependency
71
96
  name: jeweler
72
- requirement: &id006 !ruby/object:Gem::Requirement
97
+ type: :development
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ~>
101
+ - !ruby/object:Gem::Version
102
+ version: 1.8.3
73
103
  none: false
74
- requirements:
104
+ requirement: !ruby/object:Gem::Requirement
105
+ requirements:
75
106
  - - ~>
76
- - !ruby/object:Gem::Version
107
+ - !ruby/object:Gem::Version
77
108
  version: 1.8.3
78
- type: :development
109
+ none: false
110
+ - !ruby/object:Gem::Dependency
79
111
  prerelease: false
80
- version_requirements: *id006
81
- - !ruby/object:Gem::Dependency
82
112
  name: simplecov
83
- requirement: &id007 !ruby/object:Gem::Requirement
84
- none: false
85
- requirements:
86
- - - ">="
87
- - !ruby/object:Gem::Version
88
- version: "0"
89
113
  type: :development
114
+ version_requirements: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ! '>='
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ none: false
120
+ requirement: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ! '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ none: false
126
+ - !ruby/object:Gem::Dependency
90
127
  prerelease: false
91
- version_requirements: *id007
92
- - !ruby/object:Gem::Dependency
93
128
  name: sqlite3
94
- requirement: &id008 !ruby/object:Gem::Requirement
95
- none: false
96
- requirements:
97
- - - ">="
98
- - !ruby/object:Gem::Version
99
- version: "0"
100
129
  type: :development
130
+ version_requirements: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ! '>='
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ none: false
136
+ requirement: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - ! '>='
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ none: false
142
+ - !ruby/object:Gem::Dependency
101
143
  prerelease: false
102
- version_requirements: *id008
103
- - !ruby/object:Gem::Dependency
104
144
  name: mysql2
105
- requirement: &id009 !ruby/object:Gem::Requirement
145
+ type: :development
146
+ version_requirements: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - '='
149
+ - !ruby/object:Gem::Version
150
+ version: 0.2.7
106
151
  none: false
107
- requirements:
108
- - - "="
109
- - !ruby/object:Gem::Version
152
+ requirement: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - '='
155
+ - !ruby/object:Gem::Version
110
156
  version: 0.2.7
111
- type: :development
157
+ none: false
158
+ - !ruby/object:Gem::Dependency
112
159
  prerelease: false
113
- version_requirements: *id009
114
- - !ruby/object:Gem::Dependency
115
160
  name: awesome_print
116
- requirement: &id010 !ruby/object:Gem::Requirement
117
- none: false
118
- requirements:
119
- - - ">="
120
- - !ruby/object:Gem::Version
121
- version: "0"
122
161
  type: :development
123
- prerelease: false
124
- version_requirements: *id010
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ! '>='
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ none: false
168
+ requirement: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - ! '>='
171
+ - !ruby/object:Gem::Version
172
+ version: '0'
173
+ none: false
125
174
  description: CommaHeaven permits easy exports of Rails models to CSV
126
175
  email: silvano.stralla@sistrall.it
127
176
  executables: []
128
-
129
177
  extensions: []
130
-
131
- extra_rdoc_files:
178
+ extra_rdoc_files:
132
179
  - LICENSE
133
180
  - README.rdoc
134
- files:
181
+ files:
135
182
  - .document
136
183
  - Gemfile
137
184
  - Gemfile.lock
@@ -161,34 +208,31 @@ files:
161
208
  - spec/sqler/has_many_columns_spec.rb
162
209
  - spec/sqler/has_one_association_spec.rb
163
210
  homepage: http://github.com/sistrall/comma-heaven
164
- licenses:
211
+ licenses:
165
212
  - MIT
166
213
  post_install_message:
167
214
  rdoc_options: []
168
-
169
- require_paths:
215
+ require_paths:
170
216
  - lib
171
- required_ruby_version: !ruby/object:Gem::Requirement
172
- none: false
173
- requirements:
174
- - - ">="
175
- - !ruby/object:Gem::Version
176
- hash: -4302887848545016982
177
- segments:
217
+ required_ruby_version: !ruby/object:Gem::Requirement
218
+ requirements:
219
+ - - ! '>='
220
+ - !ruby/object:Gem::Version
221
+ segments:
178
222
  - 0
179
- version: "0"
180
- required_rubygems_version: !ruby/object:Gem::Requirement
223
+ hash: 3192761689763648763
224
+ version: '0'
225
+ none: false
226
+ required_rubygems_version: !ruby/object:Gem::Requirement
227
+ requirements:
228
+ - - ! '>='
229
+ - !ruby/object:Gem::Version
230
+ version: '0'
181
231
  none: false
182
- requirements:
183
- - - ">="
184
- - !ruby/object:Gem::Version
185
- version: "0"
186
232
  requirements: []
187
-
188
233
  rubyforge_project:
189
- rubygems_version: 1.8.13
234
+ rubygems_version: 1.8.23
190
235
  signing_key:
191
236
  specification_version: 3
192
237
  summary: CSV exporter for Rails
193
238
  test_files: []
194
-