rgviz-rails 0.6 → 0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/rails/init.rb +27 -6
- metadata +3 -3
data/rails/init.rb
CHANGED
@@ -9,12 +9,33 @@ config.after_initialize do
|
|
9
9
|
else
|
10
10
|
model = hash[:rgviz]
|
11
11
|
query = params[:tq]
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
12
|
+
tqx = params[:tqx] || ''
|
13
|
+
pieces = tqx.split ';'
|
14
|
+
reqId = '0'
|
15
|
+
version = '0.6'
|
16
|
+
responseHandler = 'google.visualization.Query.setResponse'
|
17
|
+
pieces.each do |p|
|
18
|
+
key_value = p.split ':'
|
19
|
+
if key_value.length == 2
|
20
|
+
case key_value[0]
|
21
|
+
when 'reqId'
|
22
|
+
reqId = key_value[1]
|
23
|
+
when 'version'
|
24
|
+
version = key_value[1]
|
25
|
+
when 'responseHandler'
|
26
|
+
responseHandler = key_value[1]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
begin
|
32
|
+
executor = Rgviz::Executor.new model, Rgviz::Parser.new(query).parse
|
33
|
+
table = executor.execute
|
34
|
+
original_render :text => "#{responseHandler}({reqId:'#{reqId}',status:'ok',version:'#{version}',table:#{table.to_json}});"
|
35
|
+
rescue ParseException => e
|
36
|
+
msg = e.message.gsub("'", "\\'")
|
37
|
+
original_render :text => "#{responseHandler}({reqId:'#{reqId}',status:'error',version:'#{version}',errors:[{reason:'invalid_query', message:'#{msg}'}]});"
|
38
|
+
end
|
18
39
|
end
|
19
40
|
else
|
20
41
|
original_render *args, &block
|
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:
|
4
|
+
hash: 5
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: "0.
|
8
|
+
- 7
|
9
|
+
version: "0.7"
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Ary Borenszweig
|