comma 3.0.3 → 3.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -3,4 +3,5 @@ pkg/*
3
3
  *~
4
4
  .bundle
5
5
  spec/rails_app/log
6
- spec/rails_app/db/development.sqlite3
6
+ spec/rails_app/db/development.sqlite*
7
+ .rbx/
data/.travis.yml CHANGED
@@ -4,5 +4,6 @@ rvm:
4
4
  - 1.8.7
5
5
  - 1.9.2
6
6
  - 1.9.3
7
+ - rbx-18mode
7
8
 
8
9
  script: "bundle exec rake appraisal:install && bundle exec rake appraisal spec"
data/Appraisals CHANGED
@@ -1,4 +1,4 @@
1
- ['3.0.9', '3.1.1', '~>3.2.1' ].each do |version_number|
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- comma (3.0.3)
4
+ comma (3.0.4)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
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, REE 1.8.7, 1.9.2, 1.9.3
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
  [![Build Status](https://secure.travis-ci.org/crafterm/comma.png)](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 appraisals:install
297
- bundle exec rake appraisals spec
314
+ bundle exec rake appraisal:install
315
+ bundle exec rake appraisal spec
298
316
 
299
317
  ```
300
318
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
- remote: /Users/tom/Development/Projects/comma
2
+ remote: /Users/tom/development/projects/current/comma
3
3
  specs:
4
- comma (3.0.2)
4
+ comma (3.0.3)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -1,7 +1,7 @@
1
1
  PATH
2
- remote: /Users/tom/Development/Projects/comma
2
+ remote: /Users/tom/development/projects/current/comma
3
3
  specs:
4
- comma (3.0.2)
4
+ comma (3.0.3)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/tom/Development/Projects/comma
3
3
  specs:
4
- comma (3.0.2)
4
+ comma (3.0.3)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "fastercsv", :platforms=>:ruby_18
6
+ gem "activesupport", "~>3.2.8"
7
+ gem "activerecord", "~>3.2.8"
8
+
9
+ gemspec :path=>"../"
@@ -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,7 +1,7 @@
1
1
  PATH
2
- remote: /Users/tom/Development/Projects/comma
2
+ remote: /Users/tom/development/projects/current/comma
3
3
  specs:
4
- comma (3.0.2)
4
+ comma (3.0.3)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -1,7 +1,7 @@
1
1
  PATH
2
- remote: /Users/tom/Development/Projects/comma
2
+ remote: /Users/tom/development/projects/current/comma
3
3
  specs:
4
- comma (3.0.2)
4
+ comma (3.0.3)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -3,7 +3,7 @@
3
3
  source "http://rubygems.org"
4
4
 
5
5
  gem "fastercsv", :platforms=>:ruby_18
6
- gem "rails", "~>3.2.1"
6
+ gem "rails", "~>3.2.8"
7
7
  gem "rspec-rails"
8
8
 
9
9
  gemspec :path=>"../"
@@ -1,79 +1,79 @@
1
1
  PATH
2
- remote: /Users/tom/Development/Projects/comma
2
+ remote: /Users/tom/development/projects/current/comma
3
3
  specs:
4
- comma (3.0.2)
4
+ comma (3.0.3)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
8
8
  specs:
9
- actionmailer (3.2.1)
10
- actionpack (= 3.2.1)
11
- mail (~> 2.4.0)
12
- actionpack (3.2.1)
13
- activemodel (= 3.2.1)
14
- activesupport (= 3.2.1)
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.1)
17
+ journey (~> 1.0.4)
18
18
  rack (~> 1.4.0)
19
- rack-cache (~> 1.1)
19
+ rack-cache (~> 1.2)
20
20
  rack-test (~> 0.6.1)
21
- sprockets (~> 2.1.2)
22
- activemodel (3.2.1)
23
- activesupport (= 3.2.1)
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.1)
26
- activemodel (= 3.2.1)
27
- activesupport (= 3.2.1)
28
- arel (~> 3.0.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.1)
31
- activemodel (= 3.2.1)
32
- activesupport (= 3.2.1)
33
- activesupport (3.2.1)
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.0)
40
+ builder (3.0.4)
41
41
  diff-lcs (1.1.3)
42
42
  erubis (2.7.0)
43
- fastercsv (1.5.4)
43
+ fastercsv (1.5.5)
44
44
  hike (1.2.1)
45
- i18n (0.6.0)
46
- journey (1.0.3)
47
- json (1.6.5)
48
- mail (2.4.1)
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.17.2)
53
- multi_json (1.1.0)
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.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.1)
60
+ rack-test (0.6.2)
61
61
  rack (>= 1.0)
62
- rails (3.2.1)
63
- actionmailer (= 3.2.1)
64
- actionpack (= 3.2.1)
65
- activerecord (= 3.2.1)
66
- activeresource (= 3.2.1)
67
- activesupport (= 3.2.1)
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.1)
70
- railties (3.2.1)
71
- actionpack (= 3.2.1)
72
- activesupport (= 3.2.1)
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 (~> 0.14.6)
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.6.1)
93
+ simplecov (0.7.1)
94
94
  multi_json (~> 1.0)
95
- simplecov-html (~> 0.5.3)
96
- simplecov-html (0.5.3)
97
- sprockets (2.1.2)
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.5)
102
- thor (0.14.6)
101
+ sqlite3 (1.3.6)
102
+ thor (0.16.0)
103
103
  tilt (1.3.3)
104
- treetop (1.4.10)
104
+ treetop (1.4.12)
105
105
  polyglot
106
106
  polyglot (>= 0.3.1)
107
- tzinfo (0.3.31)
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.1)
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] || 'data'
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 => Mime::CSV, :disposition => "attachment; filename=#{filename}.csv"
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
@@ -1,3 +1,3 @@
1
1
  module Comma
2
- VERSION = "3.0.3"
2
+ VERSION = "3.0.4"
3
3
  end
@@ -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.3
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-03-01 00:00:00.000000000Z
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: &70136624134040 !ruby/object:Gem::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: *70136624134040
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: &70136624133540 !ruby/object:Gem::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: *70136624133540
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: &70136624133060 !ruby/object:Gem::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: *70136624133060
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: &70136619239900 !ruby/object:Gem::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: *70136619239900
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: &70136619239520 !ruby/object:Gem::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: *70136619239520
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.1.gemfile
99
- - gemfiles/rails3.2.1.gemfile.lock
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: 1069179881687132397
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: 1069179881687132397
192
+ hash: -692163950360334906
166
193
  requirements: []
167
194
  rubyforge_project: comma
168
- rubygems_version: 1.8.17
195
+ rubygems_version: 1.8.23
169
196
  signing_key:
170
197
  specification_version: 3
171
198
  summary: Ruby Comma Seperated Values generation library