to_csv-rails 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/CHANGELOG +5 -2
  2. data/VERSION +1 -1
  3. data/init.rb +1 -0
  4. data/lib/to_csv-rails.rb +9 -1
  5. metadata +2 -2
data/CHANGELOG CHANGED
@@ -2,7 +2,10 @@
2
2
  first commit
3
3
 
4
4
  0.1.1
5
- update document
5
+ Update document
6
6
 
7
7
  0.1.3
8
- added custom header column names
8
+ Added custom header column names
9
+
10
+ 0.1.4
11
+ Fixed commas not escaped
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4
data/init.rb CHANGED
@@ -1 +1,2 @@
1
+ # -*- encoding : utf-8 -*-
1
2
  require 'to_csv-rails'
data/lib/to_csv-rails.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # -*- encoding : utf-8 -*-
1
2
  class Array
2
3
 
3
4
  def to_csv(options = {})
@@ -22,7 +23,14 @@ class Array
22
23
  end
23
24
 
24
25
  self.each do |obj|
25
- data << columns.map{ |column| obj.send(column) }.join(',')
26
+ data << columns.map do |column|
27
+ begin
28
+ column_value = obj.send(column).to_s
29
+ column_value.include?(",") ? "\"#{column_value}\"" : column_value
30
+ rescue
31
+ ''
32
+ end
33
+ end.join(',')
26
34
  end
27
35
  data.join("\n")
28
36
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: to_csv-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-23 00:00:00.000000000 Z
12
+ date: 2013-03-30 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: This simple plugin gives you the ability to call to_csv to a collection
15
15
  of activerecords. The builder options are the same as to_json / to_xml, except for