send_csv 0.4 → 0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/send_csv.rb +15 -15
  2. metadata +30 -53
  3. data/.gemtest +0 -0
data/lib/send_csv.rb CHANGED
@@ -1,22 +1,24 @@
1
+ require 'iconv'
2
+
1
3
  module SendCsv
2
- VERSION = '0.4'
4
+ VERSION = '0.5'
3
5
 
4
6
  module_function
5
7
  def generate_csv(lines, options = {})
6
8
  require 'csv'
7
-
9
+
8
10
  options = options.dup
9
- encoding = options.delete(:encoding) || 'ISO-8859-1'
11
+ encoding = options.delete(:encoding) || 'ISO-8859-1//TRANSLIT'
10
12
 
11
13
  csv = lines.map { |values| CSV.generate_line(values, ';') + "\r\n" }.join
12
- csv = Iconv.conv(encoding, 'utf-8', csv)
14
+ csv = Iconv.conv(encoding, 'UTF-8', csv)
13
15
 
14
16
  csv
15
17
  end
16
18
 
17
19
  def send_csv(lines, options = {})
18
20
  options = options.dup
19
- encoding = options.delete(:encoding) || 'ISO-8859-1'
21
+ encoding = options.delete(:encoding) || 'ISO-8859-1//TRANSLIT'
20
22
 
21
23
  options = {
22
24
  :disposition => "attachment",
@@ -27,14 +29,12 @@ module SendCsv
27
29
 
28
30
  send_data csv, options
29
31
  end
30
- end
31
-
32
- # Based on http://stackoverflow.com/questions/3468858/rails-3-0-engine-execute-code-in-actioncontroller/3484141#3484141
33
-
34
- require 'action_controller' # Make sure ActionController::Base is defined
35
-
36
- ActionController::Base.class_eval do
37
- private
38
-
39
- include SendCsv
32
+
33
+ class Engine < Rails::Engine
34
+ initializer 'send_csv.controller' do |app|
35
+ ActiveSupport.on_load(:action_controller) do
36
+ include SendCsv
37
+ end
38
+ end
39
+ end
40
40
  end
metadata CHANGED
@@ -1,50 +1,37 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: send_csv
3
- version: !ruby/object:Gem::Version
4
- hash: 3
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.5'
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 4
9
- version: "0.4"
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Ouvrages
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2011-08-18 00:00:00 +02:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2011-06-24 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: hoe
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &82749930 !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- hash: 35
29
- segments:
30
- - 2
31
- - 9
32
- - 4
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
33
21
  version: 2.9.4
34
22
  type: :development
35
- version_requirements: *id001
23
+ prerelease: false
24
+ version_requirements: *82749930
36
25
  description: Adds to ApplicationController a send_csv method working like send_file.
37
- email:
26
+ email:
38
27
  - contact@ouvrages-web.fr
39
28
  executables: []
40
-
41
29
  extensions: []
42
-
43
- extra_rdoc_files:
30
+ extra_rdoc_files:
44
31
  - History.txt
45
32
  - Manifest.txt
46
33
  - README.txt
47
- files:
34
+ files:
48
35
  - .autotest
49
36
  - History.txt
50
37
  - Manifest.txt
@@ -52,41 +39,31 @@ files:
52
39
  - Rakefile
53
40
  - lib/send_csv.rb
54
41
  - test/test_send_csv.rb
55
- - .gemtest
56
- has_rdoc: true
57
42
  homepage: https://github.com/ouvrages/send_csv
58
43
  licenses: []
59
-
60
44
  post_install_message:
61
- rdoc_options:
45
+ rdoc_options:
62
46
  - --main
63
47
  - README.txt
64
- require_paths:
48
+ require_paths:
65
49
  - lib
66
- required_ruby_version: !ruby/object:Gem::Requirement
50
+ required_ruby_version: !ruby/object:Gem::Requirement
67
51
  none: false
68
- requirements:
69
- - - ">="
70
- - !ruby/object:Gem::Version
71
- hash: 3
72
- segments:
73
- - 0
74
- version: "0"
75
- required_rubygems_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
57
  none: false
77
- requirements:
78
- - - ">="
79
- - !ruby/object:Gem::Version
80
- hash: 3
81
- segments:
82
- - 0
83
- version: "0"
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
84
62
  requirements: []
85
-
86
63
  rubyforge_project: send_csv
87
- rubygems_version: 1.5.0
64
+ rubygems_version: 1.8.11
88
65
  signing_key:
89
66
  specification_version: 3
90
67
  summary: Adds to ApplicationController a send_csv method working like send_file.
91
- test_files:
68
+ test_files:
92
69
  - test/test_send_csv.rb
data/.gemtest DELETED
File without changes