comma 0.5.2 → 2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc CHANGED
@@ -1,4 +1,4 @@
1
- rvm 1.9.2-p290@comma --create
1
+ rvm 1.8.7-p352@comma --create
2
2
 
3
3
  if ! command -v bundle ; then
4
4
  gem install bundler
data/Appraisals CHANGED
@@ -1,9 +1,12 @@
1
- appraise "activesupport2" do
2
- gem "activesupport", "<3"
3
- gem "activerecord", "<3"
4
- end
1
+ ['2.3.2', '2.3.5', '2.3.7', '~>2.3.14' ].each do |version_number|
2
+ clean_number = version_number.gsub(/[<>~=]*/, '')
3
+
4
+ appraise "rails#{ clean_number }" do
5
+ gem "rails", version_number
6
+ end
5
7
 
6
- appraise "activesupport3" do
7
- gem "activesupport", ">3"
8
- gem "activerecord", ">3"
9
- end
8
+ appraise "active#{ clean_number }" do
9
+ gem "activesupport", version_number
10
+ gem "activerecord", version_number
11
+ end
12
+ end
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- comma (0.5.2)
4
+ comma (2.0)
5
5
  fastercsv (= 1.5.4)
6
6
 
7
7
  GEM
@@ -1,10 +1,35 @@
1
- = COMMA
1
+ #COMMA
2
2
 
3
3
  http://github.com/crafterm/comma
4
4
 
5
- == DESCRIPTION:
5
+ ##COMPATIBILITY
6
+ This branch of the project builds gems to the 2.x version series, and is compatible and tested with :
7
+ - Ruby 1.8.7, 1.9.2
8
+ - Rails 2.x
6
9
 
7
- Comma is a CSV (ie. comma separated values) generation extension for Ruby objects, that lets you seamlessly define a CSV output format via a small DSL. Comma works well on pure Ruby objects with attributes, as well as complex ones such as ActiveRecord objects with associations, extensions, etc. It doesn't distinguish between attributes, methods, associations, extensions, etc. - they all are considered equal and invoked identically via the Comma DSL description. Multiple different CSV output descriptions can also be defined.
10
+ ##LOOKING FOR RAILS 3?
11
+ Rails 3 is supported in the main branch of this project, and versioned in the 3.x version of this gem. (http://github.com/crafterm/comma)
12
+
13
+ ##INSTALLATION
14
+
15
+ Comma is distributed as a gem, best installed via Bundler.
16
+
17
+ Include the gem in your Gemfile:
18
+
19
+ ```Ruby
20
+ gem "comma", "~> 2.0"
21
+ ```
22
+
23
+ Or, if you want to live life on the edge, you can get master from the main comma repository:
24
+
25
+ ```Ruby
26
+ gem "comma", :git => "git://github.com/crafterm/comma.git", :branch => 'rails2'
27
+ ```
28
+
29
+
30
+ ##DESCRIPTION:
31
+
32
+ Comma is a CSV (i.e. comma separated values) generation extension for Ruby objects, that lets you seamlessly define a CSV output format via a small DSL. Comma works well on pure Ruby objects with attributes, as well as complex ones such as ActiveRecord objects with associations, extensions, etc. It doesn't distinguish between attributes, methods, associations, extensions, etc. - they all are considered equal and invoked identically via the Comma DSL description. Multiple different CSV output descriptions can also be defined.
8
33
 
9
34
  When multiple objects in an Array are converted to CSV, the output includes generation of a header row reflected from names of the properties requested, or specified via the DSL.
10
35
 
@@ -12,6 +37,8 @@ CSV can be a bit of a boring format - the motivation behind Comma was to have a
12
37
 
13
38
  An example Comma CSV enabled ActiveRecord class:
14
39
 
40
+ ```Ruby
41
+
15
42
  class Book < ActiveRecord::Base
16
43
 
17
44
  # ================
@@ -38,8 +65,11 @@ An example Comma CSV enabled ActiveRecord class:
38
65
 
39
66
  end
40
67
 
68
+ ```
69
+
41
70
  Annotated, the comma description is as follows:
42
71
 
72
+ ```Ruby
43
73
  # starts a Comma description block, generating 2 methods #to_comma and
44
74
  # #to_comma_headers for this class.
45
75
  comma do
@@ -67,14 +97,18 @@ Annotated, the comma description is as follows:
67
97
 
68
98
  end
69
99
 
100
+ ```
101
+
70
102
  In the above example, any of the declarations (name, description, pages, publisher, isbn, blurb, etc), could be methods, attributes, associations, etc - no distinction during configuration is required, as everything is invoked via Ruby's #send method.
71
103
 
72
104
  You can get the CSV representation of any object by calling the to_comma method, optionally providing a CSV description name to use.
73
105
 
74
- Object values are automatically converted to strings via to_s allowing you to reuse any existing to_s methods on your objects (instead of having to call particular properties or define CSV specific output methods). Header names are also automatically humanized when reflected (eg. Replacing _ characters with whitespace). The 'isbn' example above shows how multiple values can be added to the CSV output.
106
+ Object values are automatically converted to strings via to_s allowing you to reuse any existing to_s methods on your objects (instead of having to call particular properties or define CSV specific output methods). Header names are also automatically humanised when reflected (eg. Replacing _ characters with whitespace). The 'isbn' example above shows how multiple values can be added to the CSV output.
75
107
 
76
108
  Multiple CSV descriptions can also be specified for the same class, eg:
77
109
 
110
+ ```Ruby
111
+
78
112
  class Book < ActiveRecord::Base
79
113
 
80
114
  # ================
@@ -109,30 +143,42 @@ Multiple CSV descriptions can also be specified for the same class, eg:
109
143
 
110
144
  end
111
145
 
146
+ ```
147
+
112
148
  You can specify which output format you would like to use via an optional parameter to to_comma:
113
149
 
150
+ ```Ruby
114
151
  Book.limited(10).to_comma(:brief)
152
+ ```
115
153
 
116
154
  Specifying no description name to to_comma is equivalent to specifying :default as the description name.
117
155
 
118
156
  You can pass options for FasterCSV, e.g.
119
157
 
158
+ ```Ruby
120
159
  Book.limited(10).to_comma(:style => :brief,
121
160
  :col_sep => ';',
122
161
  :force_quotes => true)
162
+ ```
123
163
 
124
164
  You can pass the :filename option and have Comma writes the CSV output to this file:
125
165
 
166
+ ```Ruby
126
167
  Book.limited(10).to_comma(:filename => 'books.csv')
168
+ ```
127
169
 
128
170
  You also can pass the :write_header option to hide the header line (true is default):
129
171
 
172
+ ```Ruby
130
173
  Book.limited(10).to_comma(:write_headers => false)
174
+ ```
131
175
 
132
- == Using blocks
176
+ ##Using blocks
133
177
 
134
178
  For more complex relationships you can pass blocks for calculated values, or related values. Following the previous example here is a comma set using blocks (both with and without labels for your CSV headings):
135
179
 
180
+ ```Ruby
181
+
136
182
  class Publisher < ActiveRecord::Base
137
183
  # ================
138
184
  # = Associations =
@@ -168,15 +214,19 @@ For more complex relationships you can pass blocks for calculated values, or rel
168
214
 
169
215
  end
170
216
 
217
+ ```
171
218
 
172
219
  In the preceding example, the 2 new fields added (both based on the publisher relationship) mean that the following will be added:
173
- - the first example 'publishers_contact' is loaded straight as a block. The value returned by the lambda is displayed with a header value of 'Publisher'
174
- - the second example 'total_publishers_users' is sent via a hash and a custom label is set, if used in the first examples method the header would be 'Publisher', but sent as a hash the header is 'Number of publisher users'.
175
220
 
176
- === USING WITH RAILS
221
+ * the first example 'publishers_contact' is loaded straight as a block. The value returned by the lambda is displayed with a header value of 'Publisher'
222
+ * the second example 'total_publishers_users' is sent via a hash and a custom label is set, if used in the first examples method the header would be 'Publisher', but sent as a hash the header is 'Number of publisher users'.
223
+
224
+ ###USING WITH RAILS
177
225
 
178
226
  When used with Rails (ie. add 'comma' as a gem dependency), Comma automatically adds support for rendering CSV output in your controllers:
179
227
 
228
+ ```Ruby
229
+
180
230
  class BooksController < ApplicationController
181
231
 
182
232
  def index
@@ -187,7 +237,12 @@ When used with Rails (ie. add 'comma' as a gem dependency), Comma automatically
187
237
 
188
238
  end
189
239
 
240
+ ```
241
+
190
242
  You can specify which output format you would like to use by specifying a style parameter:
243
+
244
+ ```Ruby
245
+
191
246
  class BooksController < ApplicationController
192
247
 
193
248
  def index
@@ -198,12 +253,16 @@ You can specify which output format you would like to use by specifying a style
198
253
 
199
254
  end
200
255
 
256
+ ```
257
+
201
258
  With the Rails renderer you can supply any of the regular parameters that you would use with to_comma such as :filename,
202
259
  :write_headers, :force_quotes, etc. The parameters just need to be supplied after you specify the collection for the csv as demonstrated
203
260
  above.
204
261
 
205
262
  When used with Rails 2.3.*, Comma also adds support for exporting named scopes:
206
263
 
264
+ ```Ruby
265
+
207
266
  class Book < ActiveRecord::Base
208
267
  named_scope :recent,
209
268
  lambda { { :conditions => ['created_at > ?', 1.month.ago] } }
@@ -211,30 +270,38 @@ When used with Rails 2.3.*, Comma also adds support for exporting named scopes:
211
270
  # ...
212
271
  end
213
272
 
273
+ ```
274
+
214
275
  Calling the to_comma method on the named scope will internally use Rails' find_each method, instantiating only 1,000 ActiveRecord objects at a time:
215
276
 
277
+ ```Ruby
278
+
216
279
  Book.recent.to_comma
217
280
 
218
- == DEPENDENCIES
281
+ ```
282
+
283
+ ##DEPENDENCIES
219
284
 
220
285
  If you're on Ruby 1.8.*, the FasterCSV gem is recommended for performance reasons.
221
286
 
222
287
  gem install fastercsv
223
288
 
224
- If you have any questions or suggestions for Comma, please feel free to contact me at crafterm@redartisan.com, all feedback welcome!
289
+ If you have any questions or suggestions for Comma, please feel free to contact me at tom@venombytes.com, all feedback welcome!
225
290
 
226
- == TESTING
291
+ ##TESTING
227
292
 
228
293
  This gem has been tested on :
229
294
  Ruby 1.8.7, 1.9.2
230
295
 
231
- And on Rails 2.x and 3.x.
296
+ And on multiple Rails 2.x projects.
232
297
 
233
298
  To run the test suite across multiple gem file sets, we're using [Appraisal](https://github.com/thoughtbot/appraisal), use the following commands :
234
299
 
235
- ```
300
+ ```Bash
301
+
236
302
  bundle install
237
303
  bundle exec rake appraisals:install
238
304
  bundle exec rake appraisals spec
305
+
239
306
  ```
240
307
 
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "activesupport", "~>2.3.14"
6
+ gem "activerecord", "~>2.3.14"
7
+
8
+ gemspec :path=>"../"
@@ -0,0 +1,39 @@
1
+ PATH
2
+ remote: /Users/tom/Development/Projects/comma
3
+ specs:
4
+ comma (2.0)
5
+ fastercsv (= 1.5.4)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ activerecord (2.3.14)
11
+ activesupport (= 2.3.14)
12
+ activesupport (2.3.14)
13
+ appraisal (0.4.1)
14
+ bundler
15
+ rake
16
+ diff-lcs (1.1.3)
17
+ fastercsv (1.5.4)
18
+ rake (0.8.7)
19
+ rspec (2.7.0)
20
+ rspec-core (~> 2.7.0)
21
+ rspec-expectations (~> 2.7.0)
22
+ rspec-mocks (~> 2.7.0)
23
+ rspec-core (2.7.1)
24
+ rspec-expectations (2.7.0)
25
+ diff-lcs (~> 1.1.2)
26
+ rspec-mocks (2.7.0)
27
+ sqlite3 (1.3.5)
28
+
29
+ PLATFORMS
30
+ ruby
31
+
32
+ DEPENDENCIES
33
+ activerecord (~> 2.3.14)
34
+ activesupport (~> 2.3.14)
35
+ appraisal (>= 0.4.0)
36
+ comma!
37
+ rake (= 0.8.7)
38
+ rspec (~> 2.7.0)
39
+ sqlite3 (~> 1.3.4)
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "activesupport", "2.3.2"
6
+ gem "activerecord", "2.3.2"
7
+
8
+ gemspec :path=>"../"
@@ -0,0 +1,39 @@
1
+ PATH
2
+ remote: /Users/tom/Development/Projects/comma
3
+ specs:
4
+ comma (2.0)
5
+ fastercsv (= 1.5.4)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ activerecord (2.3.2)
11
+ activesupport (= 2.3.2)
12
+ activesupport (2.3.2)
13
+ appraisal (0.4.1)
14
+ bundler
15
+ rake
16
+ diff-lcs (1.1.3)
17
+ fastercsv (1.5.4)
18
+ rake (0.8.7)
19
+ rspec (2.7.0)
20
+ rspec-core (~> 2.7.0)
21
+ rspec-expectations (~> 2.7.0)
22
+ rspec-mocks (~> 2.7.0)
23
+ rspec-core (2.7.1)
24
+ rspec-expectations (2.7.0)
25
+ diff-lcs (~> 1.1.2)
26
+ rspec-mocks (2.7.0)
27
+ sqlite3 (1.3.5)
28
+
29
+ PLATFORMS
30
+ ruby
31
+
32
+ DEPENDENCIES
33
+ activerecord (= 2.3.2)
34
+ activesupport (= 2.3.2)
35
+ appraisal (>= 0.4.0)
36
+ comma!
37
+ rake (= 0.8.7)
38
+ rspec (~> 2.7.0)
39
+ sqlite3 (~> 1.3.4)
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "activesupport", "2.3.5"
6
+ gem "activerecord", "2.3.5"
7
+
8
+ gemspec :path=>"../"
@@ -0,0 +1,39 @@
1
+ PATH
2
+ remote: /Users/tom/Development/Projects/comma
3
+ specs:
4
+ comma (2.0)
5
+ fastercsv (= 1.5.4)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ activerecord (2.3.5)
11
+ activesupport (= 2.3.5)
12
+ activesupport (2.3.5)
13
+ appraisal (0.4.1)
14
+ bundler
15
+ rake
16
+ diff-lcs (1.1.3)
17
+ fastercsv (1.5.4)
18
+ rake (0.8.7)
19
+ rspec (2.7.0)
20
+ rspec-core (~> 2.7.0)
21
+ rspec-expectations (~> 2.7.0)
22
+ rspec-mocks (~> 2.7.0)
23
+ rspec-core (2.7.1)
24
+ rspec-expectations (2.7.0)
25
+ diff-lcs (~> 1.1.2)
26
+ rspec-mocks (2.7.0)
27
+ sqlite3 (1.3.5)
28
+
29
+ PLATFORMS
30
+ ruby
31
+
32
+ DEPENDENCIES
33
+ activerecord (= 2.3.5)
34
+ activesupport (= 2.3.5)
35
+ appraisal (>= 0.4.0)
36
+ comma!
37
+ rake (= 0.8.7)
38
+ rspec (~> 2.7.0)
39
+ sqlite3 (~> 1.3.4)
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "activesupport", "2.3.7"
6
+ gem "activerecord", "2.3.7"
7
+
8
+ gemspec :path=>"../"
@@ -0,0 +1,39 @@
1
+ PATH
2
+ remote: /Users/tom/Development/Projects/comma
3
+ specs:
4
+ comma (2.0)
5
+ fastercsv (= 1.5.4)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ activerecord (2.3.7)
11
+ activesupport (= 2.3.7)
12
+ activesupport (2.3.7)
13
+ appraisal (0.4.1)
14
+ bundler
15
+ rake
16
+ diff-lcs (1.1.3)
17
+ fastercsv (1.5.4)
18
+ rake (0.8.7)
19
+ rspec (2.7.0)
20
+ rspec-core (~> 2.7.0)
21
+ rspec-expectations (~> 2.7.0)
22
+ rspec-mocks (~> 2.7.0)
23
+ rspec-core (2.7.1)
24
+ rspec-expectations (2.7.0)
25
+ diff-lcs (~> 1.1.2)
26
+ rspec-mocks (2.7.0)
27
+ sqlite3 (1.3.5)
28
+
29
+ PLATFORMS
30
+ ruby
31
+
32
+ DEPENDENCIES
33
+ activerecord (= 2.3.7)
34
+ activesupport (= 2.3.7)
35
+ appraisal (>= 0.4.0)
36
+ comma!
37
+ rake (= 0.8.7)
38
+ rspec (~> 2.7.0)
39
+ sqlite3 (~> 1.3.4)
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "rails", "~>2.3.14"
6
+
7
+ gemspec :path=>"../"
@@ -0,0 +1,53 @@
1
+ PATH
2
+ remote: /Users/tom/Development/Projects/comma
3
+ specs:
4
+ comma (2.0)
5
+ fastercsv (= 1.5.4)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ actionmailer (2.3.14)
11
+ actionpack (= 2.3.14)
12
+ actionpack (2.3.14)
13
+ activesupport (= 2.3.14)
14
+ rack (~> 1.1.0)
15
+ activerecord (2.3.14)
16
+ activesupport (= 2.3.14)
17
+ activeresource (2.3.14)
18
+ activesupport (= 2.3.14)
19
+ activesupport (2.3.14)
20
+ appraisal (0.4.1)
21
+ bundler
22
+ rake
23
+ diff-lcs (1.1.3)
24
+ fastercsv (1.5.4)
25
+ rack (1.1.3)
26
+ rails (2.3.14)
27
+ actionmailer (= 2.3.14)
28
+ actionpack (= 2.3.14)
29
+ activerecord (= 2.3.14)
30
+ activeresource (= 2.3.14)
31
+ activesupport (= 2.3.14)
32
+ rake (>= 0.8.3)
33
+ rake (0.8.7)
34
+ rspec (2.7.0)
35
+ rspec-core (~> 2.7.0)
36
+ rspec-expectations (~> 2.7.0)
37
+ rspec-mocks (~> 2.7.0)
38
+ rspec-core (2.7.1)
39
+ rspec-expectations (2.7.0)
40
+ diff-lcs (~> 1.1.2)
41
+ rspec-mocks (2.7.0)
42
+ sqlite3 (1.3.5)
43
+
44
+ PLATFORMS
45
+ ruby
46
+
47
+ DEPENDENCIES
48
+ appraisal (>= 0.4.0)
49
+ comma!
50
+ rails (~> 2.3.14)
51
+ rake (= 0.8.7)
52
+ rspec (~> 2.7.0)
53
+ sqlite3 (~> 1.3.4)
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "rails", "2.3.2"
6
+
7
+ gemspec :path=>"../"
@@ -0,0 +1,51 @@
1
+ PATH
2
+ remote: /Users/tom/Development/Projects/comma
3
+ specs:
4
+ comma (2.0)
5
+ fastercsv (= 1.5.4)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ actionmailer (2.3.2)
11
+ actionpack (= 2.3.2)
12
+ actionpack (2.3.2)
13
+ activesupport (= 2.3.2)
14
+ activerecord (2.3.2)
15
+ activesupport (= 2.3.2)
16
+ activeresource (2.3.2)
17
+ activesupport (= 2.3.2)
18
+ activesupport (2.3.2)
19
+ appraisal (0.4.1)
20
+ bundler
21
+ rake
22
+ diff-lcs (1.1.3)
23
+ fastercsv (1.5.4)
24
+ rails (2.3.2)
25
+ actionmailer (= 2.3.2)
26
+ actionpack (= 2.3.2)
27
+ activerecord (= 2.3.2)
28
+ activeresource (= 2.3.2)
29
+ activesupport (= 2.3.2)
30
+ rake (>= 0.8.3)
31
+ rake (0.8.7)
32
+ rspec (2.7.0)
33
+ rspec-core (~> 2.7.0)
34
+ rspec-expectations (~> 2.7.0)
35
+ rspec-mocks (~> 2.7.0)
36
+ rspec-core (2.7.1)
37
+ rspec-expectations (2.7.0)
38
+ diff-lcs (~> 1.1.2)
39
+ rspec-mocks (2.7.0)
40
+ sqlite3 (1.3.5)
41
+
42
+ PLATFORMS
43
+ ruby
44
+
45
+ DEPENDENCIES
46
+ appraisal (>= 0.4.0)
47
+ comma!
48
+ rails (= 2.3.2)
49
+ rake (= 0.8.7)
50
+ rspec (~> 2.7.0)
51
+ sqlite3 (~> 1.3.4)
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "rails", "2.3.5"
6
+
7
+ gemspec :path=>"../"
@@ -0,0 +1,53 @@
1
+ PATH
2
+ remote: /Users/tom/Development/Projects/comma
3
+ specs:
4
+ comma (2.0)
5
+ fastercsv (= 1.5.4)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ actionmailer (2.3.5)
11
+ actionpack (= 2.3.5)
12
+ actionpack (2.3.5)
13
+ activesupport (= 2.3.5)
14
+ rack (~> 1.0.0)
15
+ activerecord (2.3.5)
16
+ activesupport (= 2.3.5)
17
+ activeresource (2.3.5)
18
+ activesupport (= 2.3.5)
19
+ activesupport (2.3.5)
20
+ appraisal (0.4.1)
21
+ bundler
22
+ rake
23
+ diff-lcs (1.1.3)
24
+ fastercsv (1.5.4)
25
+ rack (1.0.1)
26
+ rails (2.3.5)
27
+ actionmailer (= 2.3.5)
28
+ actionpack (= 2.3.5)
29
+ activerecord (= 2.3.5)
30
+ activeresource (= 2.3.5)
31
+ activesupport (= 2.3.5)
32
+ rake (>= 0.8.3)
33
+ rake (0.8.7)
34
+ rspec (2.7.0)
35
+ rspec-core (~> 2.7.0)
36
+ rspec-expectations (~> 2.7.0)
37
+ rspec-mocks (~> 2.7.0)
38
+ rspec-core (2.7.1)
39
+ rspec-expectations (2.7.0)
40
+ diff-lcs (~> 1.1.2)
41
+ rspec-mocks (2.7.0)
42
+ sqlite3 (1.3.5)
43
+
44
+ PLATFORMS
45
+ ruby
46
+
47
+ DEPENDENCIES
48
+ appraisal (>= 0.4.0)
49
+ comma!
50
+ rails (= 2.3.5)
51
+ rake (= 0.8.7)
52
+ rspec (~> 2.7.0)
53
+ sqlite3 (~> 1.3.4)
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "rails", "2.3.7"
6
+
7
+ gemspec :path=>"../"
@@ -0,0 +1,53 @@
1
+ PATH
2
+ remote: /Users/tom/Development/Projects/comma
3
+ specs:
4
+ comma (2.0)
5
+ fastercsv (= 1.5.4)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ actionmailer (2.3.7)
11
+ actionpack (= 2.3.7)
12
+ actionpack (2.3.7)
13
+ activesupport (= 2.3.7)
14
+ rack (~> 1.1.0)
15
+ activerecord (2.3.7)
16
+ activesupport (= 2.3.7)
17
+ activeresource (2.3.7)
18
+ activesupport (= 2.3.7)
19
+ activesupport (2.3.7)
20
+ appraisal (0.4.1)
21
+ bundler
22
+ rake
23
+ diff-lcs (1.1.3)
24
+ fastercsv (1.5.4)
25
+ rack (1.1.3)
26
+ rails (2.3.7)
27
+ actionmailer (= 2.3.7)
28
+ actionpack (= 2.3.7)
29
+ activerecord (= 2.3.7)
30
+ activeresource (= 2.3.7)
31
+ activesupport (= 2.3.7)
32
+ rake (>= 0.8.3)
33
+ rake (0.8.7)
34
+ rspec (2.7.0)
35
+ rspec-core (~> 2.7.0)
36
+ rspec-expectations (~> 2.7.0)
37
+ rspec-mocks (~> 2.7.0)
38
+ rspec-core (2.7.1)
39
+ rspec-expectations (2.7.0)
40
+ diff-lcs (~> 1.1.2)
41
+ rspec-mocks (2.7.0)
42
+ sqlite3 (1.3.5)
43
+
44
+ PLATFORMS
45
+ ruby
46
+
47
+ DEPENDENCIES
48
+ appraisal (>= 0.4.0)
49
+ comma!
50
+ rails (= 2.3.7)
51
+ rake (= 0.8.7)
52
+ rspec (~> 2.7.0)
53
+ sqlite3 (~> 1.3.4)
@@ -19,26 +19,18 @@ else
19
19
  end
20
20
  end
21
21
 
22
- #TODO : Rails 2.3.x Deprecation
23
- # conditional loading of activesupport
24
- if defined? Rails and (Rails.version.split('.').map(&:to_i) <=> [2,3,5]) < 0
25
- require 'activesupport'
26
- else
27
- require 'active_support/core_ext/class/inheritable_attributes'
28
- end
22
+ #Enable class_attribute_accessor
23
+ require 'active_support/core_ext/class/inheritable_attributes'
24
+
25
+ # begin
26
+ # require 'action_controller'
27
+ # rescue Exception => e
28
+ # #Force load rails for specs until controller specs completed
29
+ # end
29
30
 
30
31
  if defined?(ActiveRecord)
31
32
  require 'comma/association_proxy'
32
-
33
- #TODO : Rails 2.3.x Deprecation
34
- if defined?(ActiveRecord::Relation)
35
- #Rails 3.x relations
36
- require 'comma/relation'
37
- elsif defined?(ActiveRecord::NamedScope::Scope)
38
- #Rails 2.x scoping
39
- require 'comma/named_scope'
40
- end
41
-
33
+ require 'comma/named_scope'
42
34
  end
43
35
 
44
36
  require 'comma/extractors'
@@ -1,4 +1,3 @@
1
- #TODO : Rails 2.3.x Deprecation
2
1
  class ActiveRecord::Associations::AssociationProxy
3
2
  def to_comma(style = :default)
4
3
  #Bug in Rails 2.3.5, this is a workaround as association_proxy.rb doesn't pass the &block in the send method so it silently fails
@@ -1,4 +1,3 @@
1
- #TODO : Rails 2.3.x Deprecations
2
1
  class ActiveRecord::NamedScope::Scope
3
2
  def to_comma(style = :default)
4
3
  Comma::Generator.new(self, style).run(:find_each)
@@ -1,11 +1,5 @@
1
1
  class Object
2
- if Class.respond_to?(:class_attribute)
3
- class_attribute :comma_formats
4
- else
5
- #TODO : Rails 2.3.x Deprecation
6
- #Deprecated method for class accessors - Maintained for those still on Rails 2.3.x
7
- class_inheritable_accessor :comma_formats
8
- end
2
+ class_inheritable_accessor :comma_formats
9
3
 
10
4
  def self.comma(style = :default, &block)
11
5
  (self.comma_formats ||= {})[style] = block
@@ -1,58 +1,49 @@
1
- if defined?(ActionController::Renderers) && ActionController::Renderers.respond_to?(:add)
2
- ActionController::Renderers.add :csv do |obj, options|
3
- filename = options[:filename] || 'data'
4
- send_data obj.to_comma, :type => Mime::CSV, :disposition => "attachment; filename=#{filename}.csv"
1
+ module RenderAsCSV
2
+ def self.included(base)
3
+ base.alias_method_chain :render, :csv
5
4
  end
6
- else
7
- module RenderAsCSV
8
- def self.included(base)
9
- base.alias_method_chain :render, :csv
10
- end
11
5
 
12
- def render_with_csv(options = nil, extra_options = {}, &block)
13
- return render_without_csv(options, extra_options, &block) unless options.is_a?(Hash) and options[:csv].present?
6
+ def render_with_csv(options = nil, extra_options = {}, &block)
7
+ return render_without_csv(options, extra_options, &block) unless options.is_a?(Hash) and options[:csv].present?
14
8
 
15
- content = options.delete(:csv)
16
- style = options.delete(:style) || :default
17
- filename = options.delete(:filename)
9
+ content = options.delete(:csv)
10
+ style = options.delete(:style) || :default
11
+ filename = options.delete(:filename)
18
12
 
19
- headers.merge!(
20
- 'Content-Transfer-Encoding' => 'binary',
21
- 'Content-Type' => 'text/csv; charset=utf-8'
22
- )
23
- filename_header_value = "attachment"
24
- filename_header_value += "; filename=\"#{filename}\"" if filename.present?
25
- headers.merge!('Content-Disposition' => filename_header_value)
13
+ headers.merge!(
14
+ 'Content-Transfer-Encoding' => 'binary',
15
+ 'Content-Type' => 'text/csv; charset=utf-8'
16
+ )
17
+ filename_header_value = "attachment"
18
+ filename_header_value += "; filename=\"#{filename}\"" if filename.present?
19
+ headers.merge!('Content-Disposition' => filename_header_value)
26
20
 
27
- @performed_render = false
21
+ @performed_render = false
28
22
 
29
- render_stream :status => 200,
30
- :content => Array(content),
31
- :style => style
32
- end
23
+ render_stream :status => 200,
24
+ :content => Array(content),
25
+ :style => style
26
+ end
33
27
 
34
- protected
35
-
36
- #TODO : Rails 2.3.x Deprecation
37
- def render_stream(options)
38
- status = options[:status]
39
- content = options[:content]
40
- style = options[:style]
41
-
42
- # If Rails 2.x
43
- if defined? Rails and (Rails.version.split('.').map(&:to_i) <=> [2,3,5]) < 0
44
- render :status => status, :text => Proc.new { |response, output|
45
- output.write CSV_HANDLER.generate_line(content.first.to_comma_headers(style))
46
- content.each { |line| output.write CSV_HANDLER.generate_line(line.to_comma(style)) }
47
- }
48
- else # If Rails 3.x
49
- self.status = status
50
- self.response_body = proc { |response, output|
51
- output.write CSV_HANDLER.generate_line(content.first.to_comma_headers(style))
52
- content.each { |line| output.write CSV_HANDLER.generate_line(line.to_comma(style)) }
53
- }
54
- end
28
+ protected
29
+
30
+ def render_stream(options)
31
+ status = options[:status]
32
+ content = options[:content]
33
+ style = options[:style]
34
+
35
+ if defined? Rails and (Rails.version.split('.').map(&:to_i) <=> [2,3,5]) < 0
36
+ render :status => status, :text => Proc.new { |response, output|
37
+ output.write CSV_HANDLER.generate_line(content.first.to_comma_headers(style))
38
+ content.each { |line| output.write CSV_HANDLER.generate_line(line.to_comma(style)) }
39
+ }
40
+ else
41
+ self.status = status
42
+ self.response_body = proc { |response, output|
43
+ output.write CSV_HANDLER.generate_line(content.first.to_comma_headers(style))
44
+ content.each { |line| output.write CSV_HANDLER.generate_line(line.to_comma(style)) }
45
+ }
55
46
  end
56
47
  end
57
- #credit : http://ramblingsonrails.com/download-a-large-amount-of-data-in-csv-from-rails
58
48
  end
49
+ #credit : http://ramblingsonrails.com/download-a-large-amount-of-data-in-csv-from-rails
@@ -1,3 +1,3 @@
1
1
  module Comma
2
- VERSION = "0.5.2"
2
+ VERSION = "2.0"
3
3
  end
metadata CHANGED
@@ -1,117 +1,109 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: comma
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 5
8
- - 2
9
- version: 0.5.2
3
+ version: !ruby/object:Gem::Version
4
+ version: '2.0'
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Marcus Crafter
13
9
  - Tom Meier
14
10
  autorequire:
15
11
  bindir: bin
16
12
  cert_chain: []
17
-
18
- date: 2012-02-18 00:00:00 +11:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- version_requirements: &id001 !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "="
25
- - !ruby/object:Gem::Version
26
- segments:
27
- - 1
28
- - 5
29
- - 4
30
- version: 1.5.4
31
- requirement: *id001
13
+ date: 2012-02-19 00:00:00.000000000Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
32
16
  name: fastercsv
33
- prerelease: false
17
+ requirement: &70144148616020 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - =
21
+ - !ruby/object:Gem::Version
22
+ version: 1.5.4
34
23
  type: :runtime
35
- - !ruby/object:Gem::Dependency
36
- version_requirements: &id002 !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "="
39
- - !ruby/object:Gem::Version
40
- segments:
41
- - 0
42
- - 8
43
- - 7
44
- version: 0.8.7
45
- requirement: *id002
46
- name: rake
47
24
  prerelease: false
25
+ version_requirements: *70144148616020
26
+ - !ruby/object:Gem::Dependency
27
+ name: rake
28
+ requirement: &70144148615060 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - =
32
+ - !ruby/object:Gem::Version
33
+ version: 0.8.7
48
34
  type: :development
49
- - !ruby/object:Gem::Dependency
50
- version_requirements: &id003 !ruby/object:Gem::Requirement
51
- requirements:
35
+ prerelease: false
36
+ version_requirements: *70144148615060
37
+ - !ruby/object:Gem::Dependency
38
+ name: sqlite3
39
+ requirement: &70144148614600 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
52
42
  - - ~>
53
- - !ruby/object:Gem::Version
54
- segments:
55
- - 1
56
- - 3
57
- - 4
43
+ - !ruby/object:Gem::Version
58
44
  version: 1.3.4
59
- requirement: *id003
60
- name: sqlite3
61
- prerelease: false
62
45
  type: :development
63
- - !ruby/object:Gem::Dependency
64
- version_requirements: &id004 !ruby/object:Gem::Requirement
65
- requirements:
46
+ prerelease: false
47
+ version_requirements: *70144148614600
48
+ - !ruby/object:Gem::Dependency
49
+ name: rspec
50
+ requirement: &70144148614120 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
66
53
  - - ~>
67
- - !ruby/object:Gem::Version
68
- segments:
69
- - 2
70
- - 7
71
- - 0
54
+ - !ruby/object:Gem::Version
72
55
  version: 2.7.0
73
- requirement: *id004
74
- name: rspec
75
- prerelease: false
76
56
  type: :development
77
- - !ruby/object:Gem::Dependency
78
- version_requirements: &id005 !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- segments:
83
- - 0
84
- - 4
85
- - 0
86
- version: 0.4.0
87
- requirement: *id005
88
- name: appraisal
89
57
  prerelease: false
58
+ version_requirements: *70144148614120
59
+ - !ruby/object:Gem::Dependency
60
+ name: appraisal
61
+ requirement: &70144148613640 !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
66
+ version: 0.4.0
90
67
  type: :development
68
+ prerelease: false
69
+ version_requirements: *70144148613640
91
70
  description: Ruby Comma Seperated Values generation library
92
- email:
71
+ email:
93
72
  - crafterm@redartisan.com
94
73
  - tom@venombytes.com
95
74
  executables: []
96
-
97
75
  extensions: []
98
-
99
76
  extra_rdoc_files: []
100
-
101
- files:
77
+ files:
102
78
  - .gitignore
103
79
  - .rvmrc
104
80
  - Appraisals
105
81
  - Gemfile
106
82
  - Gemfile.lock
107
83
  - MIT-LICENSE
108
- - README.rdoc
84
+ - README.markdown
109
85
  - Rakefile
110
86
  - comma.gemspec
87
+ - gemfiles/active2.3.14.gemfile
88
+ - gemfiles/active2.3.14.gemfile.lock
89
+ - gemfiles/active2.3.2.gemfile
90
+ - gemfiles/active2.3.2.gemfile.lock
91
+ - gemfiles/active2.3.5.gemfile
92
+ - gemfiles/active2.3.5.gemfile.lock
93
+ - gemfiles/active2.3.7.gemfile
94
+ - gemfiles/active2.3.7.gemfile.lock
111
95
  - gemfiles/activesupport2.gemfile
112
96
  - gemfiles/activesupport2.gemfile.lock
113
97
  - gemfiles/activesupport3.gemfile
114
98
  - gemfiles/activesupport3.gemfile.lock
99
+ - gemfiles/rails2.3.14.gemfile
100
+ - gemfiles/rails2.3.14.gemfile.lock
101
+ - gemfiles/rails2.3.2.gemfile
102
+ - gemfiles/rails2.3.2.gemfile.lock
103
+ - gemfiles/rails2.3.5.gemfile
104
+ - gemfiles/rails2.3.5.gemfile.lock
105
+ - gemfiles/rails2.3.7.gemfile
106
+ - gemfiles/rails2.3.7.gemfile.lock
115
107
  - init.rb
116
108
  - lib/comma.rb
117
109
  - lib/comma/array.rb
@@ -120,7 +112,6 @@ files:
120
112
  - lib/comma/generator.rb
121
113
  - lib/comma/named_scope.rb
122
114
  - lib/comma/object.rb
123
- - lib/comma/relation.rb
124
115
  - lib/comma/render_as_csv.rb
125
116
  - lib/comma/version.rb
126
117
  - spec/comma/ar_spec.rb
@@ -129,37 +120,37 @@ files:
129
120
  - spec/spec.opts
130
121
  - spec/spec_helper.rb
131
122
  - spec/support/database.yml
132
- has_rdoc: true
133
123
  homepage: http://github.com/crafterm/comma
134
124
  licenses: []
135
-
136
125
  post_install_message:
137
126
  rdoc_options: []
138
-
139
- require_paths:
127
+ require_paths:
140
128
  - lib
141
- required_ruby_version: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- segments:
129
+ required_ruby_version: !ruby/object:Gem::Requirement
130
+ none: false
131
+ requirements:
132
+ - - ! '>='
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ segments:
146
136
  - 0
147
- version: "0"
148
- required_rubygems_version: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - ">="
151
- - !ruby/object:Gem::Version
152
- segments:
137
+ hash: 1438170047706309440
138
+ required_rubygems_version: !ruby/object:Gem::Requirement
139
+ none: false
140
+ requirements:
141
+ - - ! '>='
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ segments:
153
145
  - 0
154
- version: "0"
146
+ hash: 1438170047706309440
155
147
  requirements: []
156
-
157
148
  rubyforge_project: comma
158
- rubygems_version: 1.3.6
149
+ rubygems_version: 1.8.10
159
150
  signing_key:
160
151
  specification_version: 3
161
152
  summary: Ruby Comma Seperated Values generation library
162
- test_files:
153
+ test_files:
163
154
  - spec/comma/ar_spec.rb
164
155
  - spec/comma/comma_spec.rb
165
156
  - spec/comma/extractors_spec.rb
@@ -1,5 +0,0 @@
1
- class ActiveRecord::Relation
2
- def to_comma(style = :default)
3
- Comma::Generator.new(self, style).run(:find_each)
4
- end
5
- end