comma 3.0.1 → 3.0.2
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 +1 -0
- data/Gemfile.lock +1 -1
- data/gemfiles/active3.0.9.gemfile.lock +1 -1
- data/gemfiles/active3.1.1.gemfile.lock +1 -1
- data/gemfiles/active3.2.1.gemfile.lock +1 -1
- data/gemfiles/rails3.0.9.gemfile.lock +1 -1
- data/gemfiles/rails3.1.1.gemfile.lock +1 -1
- data/gemfiles/rails3.2.1.gemfile.lock +1 -1
- data/lib/comma.rb +9 -3
- data/lib/comma/generator.rb +1 -1
- data/lib/comma/version.rb +1 -1
- data/spec/controllers/users_controller_spec.rb +19 -0
- data/spec/rails_app/app/controllers/users_controller.rb +6 -0
- data/spec/rails_app/app/models/user.rb +1 -1
- data/spec/rails_app/config/routes.rb +1 -0
- metadata +13 -15
- data/spec/rails_app/db/development.sqlite3 +0 -0
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/lib/comma.rb
CHANGED
@@ -10,6 +10,13 @@ if defined? Rails and (Rails.version.split('.').map(&:to_i).first < 3)
|
|
10
10
|
raise "Error - This Comma version only supports Rails 3.x. Please use a 2.x version of Comma for use with earlier rails versions."
|
11
11
|
end
|
12
12
|
|
13
|
+
module Comma
|
14
|
+
DEFAULT_OPTIONS = {
|
15
|
+
:write_headers => true,
|
16
|
+
:style => :default
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
13
20
|
require 'active_support/core_ext/class/attribute'
|
14
21
|
require 'active_support/core_ext/module/delegation'
|
15
22
|
require 'comma/relation' if defined?(ActiveRecord::Relation)
|
@@ -23,9 +30,8 @@ require 'comma/object'
|
|
23
30
|
if defined?(ActionController::Renderers) && ActionController::Renderers.respond_to?(:add)
|
24
31
|
ActionController::Renderers.add :csv do |obj, options|
|
25
32
|
filename = options[:filename] || 'data'
|
26
|
-
#Capture any CSV optional settings passed to comma
|
27
|
-
csv_options = options.slice(*CSV_HANDLER::DEFAULT_OPTIONS.merge(
|
28
|
-
|
33
|
+
#Capture any CSV optional settings passed to comma or comma specific options
|
34
|
+
csv_options = options.slice(*CSV_HANDLER::DEFAULT_OPTIONS.merge(Comma::DEFAULT_OPTIONS).keys)
|
29
35
|
send_data obj.to_comma(csv_options), :type => Mime::CSV, :disposition => "attachment; filename=#{filename}.csv"
|
30
36
|
end
|
31
37
|
end
|
data/lib/comma/generator.rb
CHANGED
data/lib/comma/version.rb
CHANGED
@@ -47,6 +47,25 @@ if defined?(ActionController) && defined?(Rails)
|
|
47
47
|
response.body.should == expected_content
|
48
48
|
end
|
49
49
|
|
50
|
+
describe 'with comma options' do
|
51
|
+
|
52
|
+
it 'should allow the style to be chosen from the renderer' do
|
53
|
+
#Must be passed in same format (string/symbol) eg:
|
54
|
+
# format.csv { render User.all, :style => :shortened }
|
55
|
+
|
56
|
+
get :with_custom_style, :format => :csv
|
57
|
+
|
58
|
+
expected_content =<<-CSV.gsub(/^\s+/,'')
|
59
|
+
First name,Last name
|
60
|
+
Fred,Flintstone
|
61
|
+
Wilma,Flintstone
|
62
|
+
CSV
|
63
|
+
|
64
|
+
response.body.should == expected_content
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
50
69
|
describe 'with custom options' do
|
51
70
|
|
52
71
|
it 'should allow a filename to be set' do
|
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.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -14,7 +14,7 @@ date: 2012-02-26 00:00:00.000000000Z
|
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|
17
|
-
requirement: &
|
17
|
+
requirement: &70335467056500 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: 0.9.2
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *70335467056500
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: sqlite3
|
28
|
-
requirement: &
|
28
|
+
requirement: &70335467054900 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: 1.3.4
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *70335467054900
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: appraisal
|
39
|
-
requirement: &
|
39
|
+
requirement: &70335467054140 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ~>
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: 0.4.1
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *70335467054140
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: rspec
|
50
|
-
requirement: &
|
50
|
+
requirement: &70335467053480 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ~>
|
@@ -55,10 +55,10 @@ dependencies:
|
|
55
55
|
version: 2.8.0
|
56
56
|
type: :development
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *70335467053480
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: simplecov
|
61
|
-
requirement: &
|
61
|
+
requirement: &70335467052920 !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
64
64
|
- - ! '>='
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
version: '0'
|
67
67
|
type: :development
|
68
68
|
prerelease: false
|
69
|
-
version_requirements: *
|
69
|
+
version_requirements: *70335467052920
|
70
70
|
description: Ruby Comma Seperated Values generation library
|
71
71
|
email:
|
72
72
|
- crafterm@redartisan.com
|
@@ -133,7 +133,6 @@ files:
|
|
133
133
|
- spec/rails_app/config/initializers/inflections.rb
|
134
134
|
- spec/rails_app/config/initializers/secret_token.rb
|
135
135
|
- spec/rails_app/config/routes.rb
|
136
|
-
- spec/rails_app/db/development.sqlite3
|
137
136
|
- spec/rails_app/db/migrate/20120224085510_create_tables.rb
|
138
137
|
- spec/rails_app/db/schema.rb
|
139
138
|
- spec/rails_app/public/404.html
|
@@ -157,7 +156,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
157
156
|
version: '0'
|
158
157
|
segments:
|
159
158
|
- 0
|
160
|
-
hash: -
|
159
|
+
hash: -1006301303101993278
|
161
160
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
162
161
|
none: false
|
163
162
|
requirements:
|
@@ -166,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
166
165
|
version: '0'
|
167
166
|
segments:
|
168
167
|
- 0
|
169
|
-
hash: -
|
168
|
+
hash: -1006301303101993278
|
170
169
|
requirements: []
|
171
170
|
rubyforge_project: comma
|
172
171
|
rubygems_version: 1.8.10
|
@@ -199,7 +198,6 @@ test_files:
|
|
199
198
|
- spec/rails_app/config/initializers/inflections.rb
|
200
199
|
- spec/rails_app/config/initializers/secret_token.rb
|
201
200
|
- spec/rails_app/config/routes.rb
|
202
|
-
- spec/rails_app/db/development.sqlite3
|
203
201
|
- spec/rails_app/db/migrate/20120224085510_create_tables.rb
|
204
202
|
- spec/rails_app/db/schema.rb
|
205
203
|
- spec/rails_app/public/404.html
|
Binary file
|