Closed mattetti closed 12 years ago
Still looking for one? Clearly it does not work with Ruby 1.9 :(
I was running the test suite against 1.9 and it was working. @aderyabin has been maintaining the gem, but looking at list of issues, he might need some help. I didn't see any bug reports about 1.9 and I was using this gem on a 1.9.1 project, can you please file reports explaining what the problem is, and what version of Ruby you are using?
Thanks
I am using Ruby 1.9.2, googlechart 1.3.6
and the following clearly fails
Gchart.line(:data => [0, 40, 10, 70, 20]) => "http://chart.apis.google.com/chart?"
Looking into the query_builder now method are using symbols,not string
so
'@data' should be :@data
Yet even patching that is broken for some reason as the url does not work still
Gchart.line(:data => [0, 40, 10, 70, 20]) => "http://chart.apis.google.com/chart?chd=s:AiI9R"
You get a 400...
ok here is how I monkey patched it to work
def query_builder(options="") query_params = instance_variables.map do |var| case var # Set the graph size when '@width', :@width set_size unless @width.nil? || @height.nil? when '@type', :@type set_type when '@title', :@title set_title unless @title.nil? when '@legend', :@legend set_legend unless @legend.nil? when '@bg_color', :@bg_color set_colors when '@chart_color', :@chart_color set_colors if @bg_color.nil? when '@data', :@data set_data unless @data == [] when '@bar_colors', :@bar_colors set_bar_colors when '@bar_width_and_spacing', :@bar_width_and_spacing set_bar_width_and_spacing when '@axis_with_labels', :@axis_with_labels set_axis_with_labels when '@axis_labels', :@axis_labels set_axis_labels when '@custom', :@custom @custom end end.compact # Use ampersand as default delimiter unless options == :html delimiter = '&' # Escape ampersand for html image tags else delimiter = '&' end jstize(@@url + query_params.join(delimiter)) end
Also not sure what this jstize is trying to achieve, but if this is just to escape the params, the following seems to break too
string.gsub(' ', '+').gsub(/[|{|}||||^|[|]|`|]/) {|c| "%#{c[0].to_s(16).upcase}"}
ArgumentError: wrong number of arguments(1 for 0) from (irb):4:in `to_s'
Why not using CGI.escape directly on each of the param? or something like this
def url_encode(data) if data.is_a?(Hash) encoded = {} data.each{|key,val| encoded[escape(key)] = escape(val)} encoded elsif data.is_a?(Array) data.map do |i| i.split('&').map do |str| str.split('=').map{|val| escape(val)}.join('=') end.join('&') end.join('&') elsif data if data.index('&') || data.index('=') data.split('&').map do |str| str.split('=').map{|val| escape(val)}.join('=') end.join('&') else escape(data) end end end def escape(val) (val.blank?)? val : CGI.escape(val) end
Could I ask you to submit a PR and make sure the specs are passing?
On Tue, Feb 21, 2012 at 1:31 PM, epinault-ttc < reply@reply.github.com
wrote:
Also not sure what this jstize is trying to achieve, but if this is just to escape the params, the following seems to break too
string.gsub(' ', '+').gsub(/[|{|}||||^|[|]|`|]/) {|c| "%#{c[0].to_s(16).upcase}"}
ArgumentError: wrong number of arguments(1 for 0) from (irb):4:in `to_s'
Why not using CGI.escape directly on each of the param? or something like this
def url_encode(data) if data.is_a?(Hash) encoded = {} data.each{|key,val| encoded[escape(key)] = escape(val)} encoded elsif data.is_a?(Array) data.map do |i| i.split('&').map do |str| str.split('=').map{|val| escape(val)}.join('=') end.join('&') end.join('&') elsif data if data.index('&') || data.index('=') data.split('&').map do |str| str.split('=').map{|val| escape(val)}.join('=') end.join('&') else escape(data) end end end
Reply to this email directly or view it on GitHub: https://github.com/mattetti/googlecharts/issues/31#issuecomment-4089355
I ll do that later today then :) Now that I have it working , I need to get my real work done with it ;)
I'll review all issues tomorrow. Also I would like to add Travis CI widget, but I need some help from Matt
Just did a pull request with fixes
Andrey, let me know how I can help.
-m Sent from my iPhone
On Feb 21, 2012, at 18:38, Andrey Deryabinreply@reply.github.com wrote:
I'll review all issues tomorrow. Also I would like to add Travis CI widget, but I need some help from Matt
Reply to this email directly or view it on GitHub: https://github.com/mattetti/googlecharts/issues/31#issuecomment-4096771
@epinault-ttc . I tried with ruby 1.9.2 and googlecharts 1.6.8 and it works. I think you have to update googlecharts to last version. Please let me know if you have any problems.
believe me, without my patch, it does not work in the gem 1.3.6.. So what latest version are you talking about? trunk? If that's so, please rebuild the gem and upgrade it. I looked into the code in 1.3.6 and there is no way i tis working... Method are using symbol and not strings..
Also Themes.yml is gone from the gem ....which is a mistake as well (in 1.3.6 gem)
seems like my gemfile was locking it at 1.3.6.. or around that version .Let me try the 1.6 version and get back to you
Yes, probably problem in your Gemfile, because 1.6.8 was deployed to RubyGems.org year ago
I'm looking for a new maintainer for this gem, I don't have the time and bandwidth to keep on maintaining this gem and would appreciate if someone could setup up and take care of it.
Thanks,