comma 2.1.3 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/{.rvmrc.example → .rvmrc} +1 -1
  2. data/Appraisals +2 -2
  3. data/Gemfile.lock +13 -15
  4. data/README.markdown +10 -10
  5. data/comma.gemspec +3 -5
  6. data/gemfiles/active3.0.9.gemfile +8 -0
  7. data/gemfiles/active3.0.9.gemfile.lock +48 -0
  8. data/gemfiles/active3.1.1.gemfile +8 -0
  9. data/gemfiles/active3.1.1.gemfile.lock +50 -0
  10. data/gemfiles/active3.2.1.gemfile +8 -0
  11. data/gemfiles/active3.2.1.gemfile.lock +50 -0
  12. data/gemfiles/{rails2.3.7.gemfile → rails3.0.9.gemfile} +1 -1
  13. data/gemfiles/rails3.0.9.gemfile.lock +99 -0
  14. data/gemfiles/{rails2.3.2.gemfile → rails3.1.1.gemfile} +1 -1
  15. data/gemfiles/rails3.1.1.gemfile.lock +110 -0
  16. data/gemfiles/{rails2.3.15.gemfile → rails3.2.1.gemfile} +1 -1
  17. data/gemfiles/rails3.2.1.gemfile.lock +108 -0
  18. data/lib/comma.rb +12 -29
  19. data/lib/comma/object.rb +1 -1
  20. data/lib/comma/{named_scope.rb → relation.rb} +2 -2
  21. data/lib/comma/version.rb +1 -1
  22. data/spec/comma/ar_spec.rb +1 -8
  23. metadata +32 -79
  24. data/.travis.yml +0 -9
  25. data/gemfiles/active2.3.14.gemfile +0 -8
  26. data/gemfiles/active2.3.14.gemfile.lock +0 -39
  27. data/gemfiles/active2.3.15.gemfile +0 -8
  28. data/gemfiles/active2.3.15.gemfile.lock +0 -39
  29. data/gemfiles/active2.3.2.gemfile +0 -8
  30. data/gemfiles/active2.3.2.gemfile.lock +0 -39
  31. data/gemfiles/active2.3.5.gemfile +0 -8
  32. data/gemfiles/active2.3.5.gemfile.lock +0 -39
  33. data/gemfiles/active2.3.7.gemfile +0 -8
  34. data/gemfiles/active2.3.7.gemfile.lock +0 -39
  35. data/gemfiles/rails2.3.14.gemfile +0 -7
  36. data/gemfiles/rails2.3.14.gemfile.lock +0 -53
  37. data/gemfiles/rails2.3.15.gemfile.lock +0 -53
  38. data/gemfiles/rails2.3.2.gemfile.lock +0 -51
  39. data/gemfiles/rails2.3.5.gemfile +0 -7
  40. data/gemfiles/rails2.3.5.gemfile.lock +0 -53
  41. data/gemfiles/rails2.3.7.gemfile.lock +0 -53
  42. data/lib/comma/association_proxy.rb +0 -6
  43. 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
@@ -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