crafterm-comma 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/comma.rb +6 -3
  2. metadata +2 -2
data/lib/comma.rb CHANGED
@@ -5,6 +5,7 @@ require 'comma/extractors'
5
5
  class Array
6
6
  def to_comma(style = :default)
7
7
  FasterCSV.generate do |csv|
8
+ return "" if empty?
8
9
  csv << first.to_comma_headers(style)
9
10
  each do |object|
10
11
  csv << object.to_comma(style)
@@ -41,12 +42,14 @@ if defined?(ActionController)
41
42
 
42
43
  module InstanceMethods
43
44
  def render_with_csv(options = nil, extra_options = {}, &block)
44
- return render_without_csv(options, extra_options, &block) unless options and options[:csv]
45
- send_data Array(options[:csv]).to_comma(options[:style] ||= :default)
45
+ return render_without_csv(options, extra_options, &block) unless (options.respond_to? '[]') and options[:csv]
46
+ data = options.delete(:csv)
47
+ style = options.delete(:style) || :default
48
+ send_data Array(data).to_comma(style), options.merge(:type => :csv)
46
49
  end
47
50
  end
48
51
 
49
52
  end
50
53
 
51
54
  ActionController::Base.send :include, RenderAsCSV
52
- end
55
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crafterm-comma
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcus Crafter
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-21 00:00:00 -07:00
12
+ date: 2009-04-08 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency