comma 2.1.3 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/{.rvmrc.example → .rvmrc} +1 -1
- data/Appraisals +2 -2
- data/Gemfile.lock +13 -15
- data/README.markdown +10 -10
- data/comma.gemspec +3 -5
- data/gemfiles/active3.0.9.gemfile +8 -0
- data/gemfiles/active3.0.9.gemfile.lock +48 -0
- data/gemfiles/active3.1.1.gemfile +8 -0
- data/gemfiles/active3.1.1.gemfile.lock +50 -0
- data/gemfiles/active3.2.1.gemfile +8 -0
- data/gemfiles/active3.2.1.gemfile.lock +50 -0
- data/gemfiles/{rails2.3.7.gemfile → rails3.0.9.gemfile} +1 -1
- data/gemfiles/rails3.0.9.gemfile.lock +99 -0
- data/gemfiles/{rails2.3.2.gemfile → rails3.1.1.gemfile} +1 -1
- data/gemfiles/rails3.1.1.gemfile.lock +110 -0
- data/gemfiles/{rails2.3.15.gemfile → rails3.2.1.gemfile} +1 -1
- data/gemfiles/rails3.2.1.gemfile.lock +108 -0
- data/lib/comma.rb +12 -29
- data/lib/comma/object.rb +1 -1
- data/lib/comma/{named_scope.rb → relation.rb} +2 -2
- data/lib/comma/version.rb +1 -1
- data/spec/comma/ar_spec.rb +1 -8
- metadata +32 -79
- data/.travis.yml +0 -9
- data/gemfiles/active2.3.14.gemfile +0 -8
- data/gemfiles/active2.3.14.gemfile.lock +0 -39
- data/gemfiles/active2.3.15.gemfile +0 -8
- data/gemfiles/active2.3.15.gemfile.lock +0 -39
- data/gemfiles/active2.3.2.gemfile +0 -8
- data/gemfiles/active2.3.2.gemfile.lock +0 -39
- data/gemfiles/active2.3.5.gemfile +0 -8
- data/gemfiles/active2.3.5.gemfile.lock +0 -39
- data/gemfiles/active2.3.7.gemfile +0 -8
- data/gemfiles/active2.3.7.gemfile.lock +0 -39
- data/gemfiles/rails2.3.14.gemfile +0 -7
- data/gemfiles/rails2.3.14.gemfile.lock +0 -53
- data/gemfiles/rails2.3.15.gemfile.lock +0 -53
- data/gemfiles/rails2.3.2.gemfile.lock +0 -51
- data/gemfiles/rails2.3.5.gemfile +0 -7
- data/gemfiles/rails2.3.5.gemfile.lock +0 -53
- data/gemfiles/rails2.3.7.gemfile.lock +0 -53
- data/lib/comma/association_proxy.rb +0 -6
- data/lib/comma/render_as_csv.rb +0 -49
@@ -1,6 +0,0 @@
|
|
1
|
-
class ActiveRecord::Associations::AssociationProxy
|
2
|
-
def to_comma(style = :default)
|
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
|
4
|
-
Comma::Generator.new(Array(self), style).run(:each)
|
5
|
-
end
|
6
|
-
end
|
data/lib/comma/render_as_csv.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
module RenderAsCSV
|
2
|
-
def self.included(base)
|
3
|
-
base.alias_method_chain :render, :csv
|
4
|
-
end
|
5
|
-
|
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?
|
8
|
-
|
9
|
-
content = options.delete(:csv)
|
10
|
-
style = options.delete(:style) || :default
|
11
|
-
filename = options.delete(:filename)
|
12
|
-
|
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)
|
20
|
-
|
21
|
-
@performed_render = false
|
22
|
-
|
23
|
-
render_stream :status => 200,
|
24
|
-
:content => Array(content),
|
25
|
-
:style => style
|
26
|
-
end
|
27
|
-
|
28
|
-
protected
|
29
|
-
|
30
|
-
def render_stream(options)
|
31
|
-
status = options[:status]
|
32
|
-
content = options[:content]
|
33
|
-
style = options[:style]
|
34
|
-
|
35
|
-
if self.respond_to?(:status=)
|
36
|
-
self.status = status
|
37
|
-
self.response_body = proc { |response, output|
|
38
|
-
output.write CSV_HANDLER.generate_line(content.first.to_comma_headers(style))
|
39
|
-
content.each { |line| output.write CSV_HANDLER.generate_line(line.to_comma(style)) }
|
40
|
-
}
|
41
|
-
else
|
42
|
-
render :status => status, :text => Proc.new { |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
|
-
}
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
#credit : http://ramblingsonrails.com/download-a-large-amount-of-data-in-csv-from-rails
|