send_csv 0.5 → 0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.txt +1 -0
  2. data/lib/send_csv.rb +4 -7
  3. metadata +4 -3
data/README.txt CHANGED
@@ -19,6 +19,7 @@ Adds to ApplicationController a send_csv method working like send_file.
19
19
 
20
20
  == REQUIREMENTS:
21
21
 
22
+ * since version 0.6: Ruby 1.9
22
23
  * csv (bundled with Ruby)
23
24
  * ApplicationController with a #send_file method (bundled with Rails)
24
25
 
@@ -1,24 +1,21 @@
1
- require 'iconv'
2
-
3
1
  module SendCsv
4
- VERSION = '0.5'
2
+ VERSION = '0.6'
5
3
 
6
4
  module_function
7
5
  def generate_csv(lines, options = {})
8
6
  require 'csv'
9
7
 
10
8
  options = options.dup
11
- encoding = options.delete(:encoding) || 'ISO-8859-1//TRANSLIT'
9
+ encoding = options.delete(:encoding) || 'ISO-8859-15'
12
10
 
13
- csv = lines.map { |values| CSV.generate_line(values, ';') + "\r\n" }.join
14
- csv = Iconv.conv(encoding, 'UTF-8', csv)
11
+ csv = lines.map { |values| CSV.generate_line(values, :col_sep => ';', :row_sep => "\r\n") }.join
12
+ csv = csv.encode(encoding, :invalid => :replace, :undef => :replace)
15
13
 
16
14
  csv
17
15
  end
18
16
 
19
17
  def send_csv(lines, options = {})
20
18
  options = options.dup
21
- encoding = options.delete(:encoding) || 'ISO-8859-1//TRANSLIT'
22
19
 
23
20
  options = {
24
21
  :disposition => "attachment",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: send_csv
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.5'
4
+ version: '0.6'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-06-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: hoe
16
- requirement: &82749930 !ruby/object:Gem::Requirement
16
+ requirement: &80452450 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: 2.9.4
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *82749930
24
+ version_requirements: *80452450
25
25
  description: Adds to ApplicationController a send_csv method working like send_file.
26
26
  email:
27
27
  - contact@ouvrages-web.fr
@@ -67,3 +67,4 @@ specification_version: 3
67
67
  summary: Adds to ApplicationController a send_csv method working like send_file.
68
68
  test_files:
69
69
  - test/test_send_csv.rb
70
+ has_rdoc: