rgviz-rails 0.13 → 0.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/rails/init.rb +9 -1
  2. metadata +3 -3
data/rails/init.rb CHANGED
@@ -16,6 +16,7 @@ config.after_initialize do
16
16
  version = '0.6'
17
17
  responseHandler = 'google.visualization.Query.setResponse'
18
18
  out = 'json'
19
+ outFileName = nil
19
20
  pieces.each do |p|
20
21
  key_value = p.split ':'
21
22
  if key_value.length == 2
@@ -28,6 +29,8 @@ config.after_initialize do
28
29
  responseHandler = key_value[1]
29
30
  when 'out'
30
31
  out = key_value[1]
32
+ when 'outFileName'
33
+ outFileName = key_value[1]
31
34
  end
32
35
  end
33
36
  end
@@ -44,7 +47,12 @@ config.after_initialize do
44
47
  when 'html'
45
48
  original_render :text => Rgviz::HtmlRenderer.render(table)
46
49
  when 'csv'
47
- original_render :text => Rgviz::CsvRenderer.render(table)
50
+ csv_output = Rgviz::CsvRenderer.render(table)
51
+ if outFileName
52
+ send_data csv_output, :filename => outFileName, :type => 'text/csv'
53
+ else
54
+ original_render :text => csv_output
55
+ end
48
56
  else
49
57
  original_render :text => "#{responseHandler}({reqId:'#{reqId}',status:'error',version:'#{version}',errors:[{reason:'not_supported', message:'Unsupported output type: #{out}'}]});"
50
58
  end
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rgviz-rails
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 13
9
- version: "0.13"
8
+ - 14
9
+ version: "0.14"
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ary Borenszweig