comma 3.0.3 → 3.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +2 -1
- data/.travis.yml +1 -0
- data/Appraisals +2 -2
- data/Gemfile.lock +1 -1
- data/README.markdown +21 -3
- data/gemfiles/active3.0.9.gemfile.lock +2 -2
- data/gemfiles/active3.1.1.gemfile.lock +2 -2
- data/gemfiles/active3.2.1.gemfile.lock +1 -1
- data/gemfiles/active3.2.8.gemfile +9 -0
- data/gemfiles/active3.2.8.gemfile.lock +57 -0
- data/gemfiles/rails3.0.9.gemfile.lock +2 -2
- data/gemfiles/rails3.1.1.gemfile.lock +2 -2
- data/gemfiles/{rails3.2.1.gemfile → rails3.2.8.gemfile} +1 -1
- data/gemfiles/{rails3.2.1.gemfile.lock → rails3.2.8.gemfile.lock} +51 -51
- data/lib/comma.rb +4 -2
- data/lib/comma/version.rb +1 -1
- data/spec/controllers/users_controller_spec.rb +15 -1
- metadata +44 -17
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/Appraisals
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
['3.0.9', '3.1.1', '~>3.2.
|
1
|
+
['3.0.9', '3.1.1', '~>3.2.8' ].each do |version_number|
|
2
2
|
clean_number = version_number.gsub(/[<>~=]*/, '')
|
3
3
|
|
4
4
|
appraise "rails#{ clean_number }" do
|
@@ -10,4 +10,4 @@
|
|
10
10
|
gem "activesupport", version_number
|
11
11
|
gem "activerecord", version_number
|
12
12
|
end
|
13
|
-
end
|
13
|
+
end
|
data/Gemfile.lock
CHANGED
data/README.markdown
CHANGED
@@ -5,7 +5,9 @@ http://github.com/crafterm/comma
|
|
5
5
|
##COMPATIBILITY
|
6
6
|
The mainline of this project builds gems to the 3.x version series, and is compatible and tested with :
|
7
7
|
|
8
|
-
* Ruby 1.8.7,
|
8
|
+
* Ruby 1.8.7, 1.9.2, 1.9.3
|
9
|
+
* REE 1.8.7
|
10
|
+
* RBX 1.8
|
9
11
|
* Rails 3.x (all versions)
|
10
12
|
|
11
13
|
[](http://travis-ci.org/crafterm/comma)
|
@@ -257,6 +259,22 @@ You can specify which output format you would like to use by specifying a style
|
|
257
259
|
|
258
260
|
```
|
259
261
|
|
262
|
+
You can also specify a different file extension ('csv' by default)
|
263
|
+
|
264
|
+
```Ruby
|
265
|
+
|
266
|
+
class BooksController < ApplicationController
|
267
|
+
|
268
|
+
def index
|
269
|
+
respond_to do |format|
|
270
|
+
format.csv { render :csv => Book.limited(50), :extension => 'txt' }
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
end
|
275
|
+
|
276
|
+
```
|
277
|
+
|
260
278
|
With the Rails renderer you can supply any of the regular parameters that you would use with to_comma such as :filename,
|
261
279
|
:write_headers, :force_quotes, etc. The parameters just need to be supplied after you specify the collection for the csv as demonstrated
|
262
280
|
above.
|
@@ -293,8 +311,8 @@ To run the test suite across multiple gem file sets, we're using [Appraisal](htt
|
|
293
311
|
```Bash
|
294
312
|
|
295
313
|
bundle install
|
296
|
-
bundle exec rake
|
297
|
-
bundle exec rake
|
314
|
+
bundle exec rake appraisal:install
|
315
|
+
bundle exec rake appraisal spec
|
298
316
|
|
299
317
|
```
|
300
318
|
|
@@ -0,0 +1,57 @@
|
|
1
|
+
PATH
|
2
|
+
remote: /Users/tom/development/projects/current/comma
|
3
|
+
specs:
|
4
|
+
comma (3.0.3)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: http://rubygems.org/
|
8
|
+
specs:
|
9
|
+
activemodel (3.2.8)
|
10
|
+
activesupport (= 3.2.8)
|
11
|
+
builder (~> 3.0.0)
|
12
|
+
activerecord (3.2.8)
|
13
|
+
activemodel (= 3.2.8)
|
14
|
+
activesupport (= 3.2.8)
|
15
|
+
arel (~> 3.0.2)
|
16
|
+
tzinfo (~> 0.3.29)
|
17
|
+
activesupport (3.2.8)
|
18
|
+
i18n (~> 0.6)
|
19
|
+
multi_json (~> 1.0)
|
20
|
+
appraisal (0.4.1)
|
21
|
+
bundler
|
22
|
+
rake
|
23
|
+
arel (3.0.2)
|
24
|
+
builder (3.0.4)
|
25
|
+
diff-lcs (1.1.3)
|
26
|
+
fastercsv (1.5.5)
|
27
|
+
i18n (0.6.1)
|
28
|
+
multi_json (1.3.7)
|
29
|
+
rake (0.9.2.2)
|
30
|
+
rspec (2.8.0)
|
31
|
+
rspec-core (~> 2.8.0)
|
32
|
+
rspec-expectations (~> 2.8.0)
|
33
|
+
rspec-mocks (~> 2.8.0)
|
34
|
+
rspec-core (2.8.0)
|
35
|
+
rspec-expectations (2.8.0)
|
36
|
+
diff-lcs (~> 1.1.2)
|
37
|
+
rspec-mocks (2.8.0)
|
38
|
+
simplecov (0.7.1)
|
39
|
+
multi_json (~> 1.0)
|
40
|
+
simplecov-html (~> 0.7.1)
|
41
|
+
simplecov-html (0.7.1)
|
42
|
+
sqlite3 (1.3.6)
|
43
|
+
tzinfo (0.3.35)
|
44
|
+
|
45
|
+
PLATFORMS
|
46
|
+
ruby
|
47
|
+
|
48
|
+
DEPENDENCIES
|
49
|
+
activerecord (~> 3.2.8)
|
50
|
+
activesupport (~> 3.2.8)
|
51
|
+
appraisal (~> 0.4.1)
|
52
|
+
comma!
|
53
|
+
fastercsv
|
54
|
+
rake (~> 0.9.2)
|
55
|
+
rspec (~> 2.8.0)
|
56
|
+
simplecov
|
57
|
+
sqlite3 (~> 1.3.4)
|
@@ -1,79 +1,79 @@
|
|
1
1
|
PATH
|
2
|
-
remote: /Users/tom/
|
2
|
+
remote: /Users/tom/development/projects/current/comma
|
3
3
|
specs:
|
4
|
-
comma (3.0.
|
4
|
+
comma (3.0.3)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: http://rubygems.org/
|
8
8
|
specs:
|
9
|
-
actionmailer (3.2.
|
10
|
-
actionpack (= 3.2.
|
11
|
-
mail (~> 2.4.
|
12
|
-
actionpack (3.2.
|
13
|
-
activemodel (= 3.2.
|
14
|
-
activesupport (= 3.2.
|
9
|
+
actionmailer (3.2.8)
|
10
|
+
actionpack (= 3.2.8)
|
11
|
+
mail (~> 2.4.4)
|
12
|
+
actionpack (3.2.8)
|
13
|
+
activemodel (= 3.2.8)
|
14
|
+
activesupport (= 3.2.8)
|
15
15
|
builder (~> 3.0.0)
|
16
16
|
erubis (~> 2.7.0)
|
17
|
-
journey (~> 1.0.
|
17
|
+
journey (~> 1.0.4)
|
18
18
|
rack (~> 1.4.0)
|
19
|
-
rack-cache (~> 1.
|
19
|
+
rack-cache (~> 1.2)
|
20
20
|
rack-test (~> 0.6.1)
|
21
|
-
sprockets (~> 2.1.
|
22
|
-
activemodel (3.2.
|
23
|
-
activesupport (= 3.2.
|
21
|
+
sprockets (~> 2.1.3)
|
22
|
+
activemodel (3.2.8)
|
23
|
+
activesupport (= 3.2.8)
|
24
24
|
builder (~> 3.0.0)
|
25
|
-
activerecord (3.2.
|
26
|
-
activemodel (= 3.2.
|
27
|
-
activesupport (= 3.2.
|
28
|
-
arel (~> 3.0.
|
25
|
+
activerecord (3.2.8)
|
26
|
+
activemodel (= 3.2.8)
|
27
|
+
activesupport (= 3.2.8)
|
28
|
+
arel (~> 3.0.2)
|
29
29
|
tzinfo (~> 0.3.29)
|
30
|
-
activeresource (3.2.
|
31
|
-
activemodel (= 3.2.
|
32
|
-
activesupport (= 3.2.
|
33
|
-
activesupport (3.2.
|
30
|
+
activeresource (3.2.8)
|
31
|
+
activemodel (= 3.2.8)
|
32
|
+
activesupport (= 3.2.8)
|
33
|
+
activesupport (3.2.8)
|
34
34
|
i18n (~> 0.6)
|
35
35
|
multi_json (~> 1.0)
|
36
36
|
appraisal (0.4.1)
|
37
37
|
bundler
|
38
38
|
rake
|
39
39
|
arel (3.0.2)
|
40
|
-
builder (3.0.
|
40
|
+
builder (3.0.4)
|
41
41
|
diff-lcs (1.1.3)
|
42
42
|
erubis (2.7.0)
|
43
|
-
fastercsv (1.5.
|
43
|
+
fastercsv (1.5.5)
|
44
44
|
hike (1.2.1)
|
45
|
-
i18n (0.6.
|
46
|
-
journey (1.0.
|
47
|
-
json (1.
|
48
|
-
mail (2.4.
|
45
|
+
i18n (0.6.1)
|
46
|
+
journey (1.0.4)
|
47
|
+
json (1.7.5)
|
48
|
+
mail (2.4.4)
|
49
49
|
i18n (>= 0.4.0)
|
50
50
|
mime-types (~> 1.16)
|
51
51
|
treetop (~> 1.4.8)
|
52
|
-
mime-types (1.
|
53
|
-
multi_json (1.
|
52
|
+
mime-types (1.19)
|
53
|
+
multi_json (1.3.7)
|
54
54
|
polyglot (0.3.3)
|
55
55
|
rack (1.4.1)
|
56
|
-
rack-cache (1.
|
56
|
+
rack-cache (1.2)
|
57
57
|
rack (>= 0.4)
|
58
58
|
rack-ssl (1.3.2)
|
59
59
|
rack
|
60
|
-
rack-test (0.6.
|
60
|
+
rack-test (0.6.2)
|
61
61
|
rack (>= 1.0)
|
62
|
-
rails (3.2.
|
63
|
-
actionmailer (= 3.2.
|
64
|
-
actionpack (= 3.2.
|
65
|
-
activerecord (= 3.2.
|
66
|
-
activeresource (= 3.2.
|
67
|
-
activesupport (= 3.2.
|
62
|
+
rails (3.2.8)
|
63
|
+
actionmailer (= 3.2.8)
|
64
|
+
actionpack (= 3.2.8)
|
65
|
+
activerecord (= 3.2.8)
|
66
|
+
activeresource (= 3.2.8)
|
67
|
+
activesupport (= 3.2.8)
|
68
68
|
bundler (~> 1.0)
|
69
|
-
railties (= 3.2.
|
70
|
-
railties (3.2.
|
71
|
-
actionpack (= 3.2.
|
72
|
-
activesupport (= 3.2.
|
69
|
+
railties (= 3.2.8)
|
70
|
+
railties (3.2.8)
|
71
|
+
actionpack (= 3.2.8)
|
72
|
+
activesupport (= 3.2.8)
|
73
73
|
rack-ssl (~> 1.3.2)
|
74
74
|
rake (>= 0.8.7)
|
75
75
|
rdoc (~> 3.4)
|
76
|
-
thor (
|
76
|
+
thor (>= 0.14.6, < 2.0)
|
77
77
|
rake (0.9.2.2)
|
78
78
|
rdoc (3.12)
|
79
79
|
json (~> 1.4)
|
@@ -90,21 +90,21 @@ GEM
|
|
90
90
|
activesupport (>= 3.0)
|
91
91
|
railties (>= 3.0)
|
92
92
|
rspec (~> 2.8.0)
|
93
|
-
simplecov (0.
|
93
|
+
simplecov (0.7.1)
|
94
94
|
multi_json (~> 1.0)
|
95
|
-
simplecov-html (~> 0.
|
96
|
-
simplecov-html (0.
|
97
|
-
sprockets (2.1.
|
95
|
+
simplecov-html (~> 0.7.1)
|
96
|
+
simplecov-html (0.7.1)
|
97
|
+
sprockets (2.1.3)
|
98
98
|
hike (~> 1.2)
|
99
99
|
rack (~> 1.0)
|
100
100
|
tilt (~> 1.1, != 1.3.0)
|
101
|
-
sqlite3 (1.3.
|
102
|
-
thor (0.
|
101
|
+
sqlite3 (1.3.6)
|
102
|
+
thor (0.16.0)
|
103
103
|
tilt (1.3.3)
|
104
|
-
treetop (1.4.
|
104
|
+
treetop (1.4.12)
|
105
105
|
polyglot
|
106
106
|
polyglot (>= 0.3.1)
|
107
|
-
tzinfo (0.3.
|
107
|
+
tzinfo (0.3.35)
|
108
108
|
|
109
109
|
PLATFORMS
|
110
110
|
ruby
|
@@ -113,7 +113,7 @@ DEPENDENCIES
|
|
113
113
|
appraisal (~> 0.4.1)
|
114
114
|
comma!
|
115
115
|
fastercsv
|
116
|
-
rails (~> 3.2.
|
116
|
+
rails (~> 3.2.8)
|
117
117
|
rake (~> 0.9.2)
|
118
118
|
rspec (~> 2.8.0)
|
119
119
|
rspec-rails
|
data/lib/comma.rb
CHANGED
@@ -36,9 +36,11 @@ require 'comma/object'
|
|
36
36
|
#Load into Rails controllers
|
37
37
|
if defined?(ActionController::Renderers) && ActionController::Renderers.respond_to?(:add)
|
38
38
|
ActionController::Renderers.add :csv do |obj, options|
|
39
|
-
filename = options[:filename]
|
39
|
+
filename = options[:filename] || 'data'
|
40
|
+
extension = options[:extension] || 'csv'
|
41
|
+
mime_type = options[:mime_type] || Mime::CSV
|
40
42
|
#Capture any CSV optional settings passed to comma or comma specific options
|
41
43
|
csv_options = options.slice(*CSV_HANDLER::DEFAULT_OPTIONS.merge(Comma::DEFAULT_OPTIONS).keys)
|
42
|
-
send_data obj.to_comma(csv_options), :type =>
|
44
|
+
send_data obj.to_comma(csv_options), :type => mime_type, :disposition => "attachment; filename=#{filename}.#{extension}"
|
43
45
|
end
|
44
46
|
end
|
data/lib/comma/version.rb
CHANGED
@@ -76,6 +76,20 @@ if defined?(ActionController) && defined?(Rails)
|
|
76
76
|
response.header["Content-Disposition"].should include('filename=my_custom_name.csv')
|
77
77
|
end
|
78
78
|
|
79
|
+
it 'should allow a file extension to be set' do
|
80
|
+
get :with_custom_options, :format => :csv, :custom_options => { :extension => :txt }
|
81
|
+
|
82
|
+
response.status.should == 200
|
83
|
+
response.content_type.should == 'text/csv'
|
84
|
+
response.header["Content-Disposition"].should include('filename=data.txt')
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'should allow mime type to be set' do
|
88
|
+
get :with_custom_options, :format => :csv, :custom_options => { :mime_type => Mime::TEXT }
|
89
|
+
response.status.should == 200
|
90
|
+
response.content_type.should == 'text/plain'
|
91
|
+
end
|
92
|
+
|
79
93
|
describe 'headers' do
|
80
94
|
|
81
95
|
it 'should allow toggling on' do
|
@@ -143,4 +157,4 @@ if defined?(ActionController) && defined?(Rails)
|
|
143
157
|
end
|
144
158
|
|
145
159
|
end
|
146
|
-
end
|
160
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: comma
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-11-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|
17
|
-
requirement:
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
@@ -22,10 +22,15 @@ dependencies:
|
|
22
22
|
version: 0.9.2
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
|
-
version_requirements:
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ~>
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 0.9.2
|
26
31
|
- !ruby/object:Gem::Dependency
|
27
32
|
name: sqlite3
|
28
|
-
requirement:
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
29
34
|
none: false
|
30
35
|
requirements:
|
31
36
|
- - ~>
|
@@ -33,10 +38,15 @@ dependencies:
|
|
33
38
|
version: 1.3.4
|
34
39
|
type: :development
|
35
40
|
prerelease: false
|
36
|
-
version_requirements:
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ~>
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 1.3.4
|
37
47
|
- !ruby/object:Gem::Dependency
|
38
48
|
name: appraisal
|
39
|
-
requirement:
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
40
50
|
none: false
|
41
51
|
requirements:
|
42
52
|
- - ~>
|
@@ -44,10 +54,15 @@ dependencies:
|
|
44
54
|
version: 0.4.1
|
45
55
|
type: :development
|
46
56
|
prerelease: false
|
47
|
-
version_requirements:
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ~>
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 0.4.1
|
48
63
|
- !ruby/object:Gem::Dependency
|
49
64
|
name: rspec
|
50
|
-
requirement:
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
51
66
|
none: false
|
52
67
|
requirements:
|
53
68
|
- - ~>
|
@@ -55,10 +70,15 @@ dependencies:
|
|
55
70
|
version: 2.8.0
|
56
71
|
type: :development
|
57
72
|
prerelease: false
|
58
|
-
version_requirements:
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ~>
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 2.8.0
|
59
79
|
- !ruby/object:Gem::Dependency
|
60
80
|
name: simplecov
|
61
|
-
requirement:
|
81
|
+
requirement: !ruby/object:Gem::Requirement
|
62
82
|
none: false
|
63
83
|
requirements:
|
64
84
|
- - ! '>='
|
@@ -66,7 +86,12 @@ dependencies:
|
|
66
86
|
version: '0'
|
67
87
|
type: :development
|
68
88
|
prerelease: false
|
69
|
-
version_requirements:
|
89
|
+
version_requirements: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ! '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
70
95
|
description: Ruby Comma Seperated Values generation library
|
71
96
|
email:
|
72
97
|
- crafterm@redartisan.com
|
@@ -91,12 +116,14 @@ files:
|
|
91
116
|
- gemfiles/active3.1.1.gemfile.lock
|
92
117
|
- gemfiles/active3.2.1.gemfile
|
93
118
|
- gemfiles/active3.2.1.gemfile.lock
|
119
|
+
- gemfiles/active3.2.8.gemfile
|
120
|
+
- gemfiles/active3.2.8.gemfile.lock
|
94
121
|
- gemfiles/rails3.0.9.gemfile
|
95
122
|
- gemfiles/rails3.0.9.gemfile.lock
|
96
123
|
- gemfiles/rails3.1.1.gemfile
|
97
124
|
- gemfiles/rails3.1.1.gemfile.lock
|
98
|
-
- gemfiles/rails3.2.
|
99
|
-
- gemfiles/rails3.2.
|
125
|
+
- gemfiles/rails3.2.8.gemfile
|
126
|
+
- gemfiles/rails3.2.8.gemfile.lock
|
100
127
|
- init.rb
|
101
128
|
- lib/comma.rb
|
102
129
|
- lib/comma/array.rb
|
@@ -153,7 +180,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
153
180
|
version: '0'
|
154
181
|
segments:
|
155
182
|
- 0
|
156
|
-
hash:
|
183
|
+
hash: -692163950360334906
|
157
184
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
158
185
|
none: false
|
159
186
|
requirements:
|
@@ -162,10 +189,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
162
189
|
version: '0'
|
163
190
|
segments:
|
164
191
|
- 0
|
165
|
-
hash:
|
192
|
+
hash: -692163950360334906
|
166
193
|
requirements: []
|
167
194
|
rubyforge_project: comma
|
168
|
-
rubygems_version: 1.8.
|
195
|
+
rubygems_version: 1.8.23
|
169
196
|
signing_key:
|
170
197
|
specification_version: 3
|
171
198
|
summary: Ruby Comma Seperated Values generation library
|