* use the default google options * default to nil title and alt tag instead of blank - reportable - Fork of reportable required by WarVox, from hdm/reportable.
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
---
(DIR) commit cfb13be3fe3d6acdfb1d50ae49701bac363278fc
(DIR) parent 0bf0c988885cd667f6bc6c71b9ab2a5bc73d8967
(HTM) Author: Marco Otte-Witte <marco.otte-witte@simplabs.com>
Date: Wed, 21 Apr 2010 17:15:31 +0200
* use the default google options
* default to nil title and alt tag instead of blank
Diffstat:
M lib/saulabs/reportable/report_tag_… | 4 ++--
M spec/other/report_tag_helper_spec.… | 10 +++++-----
2 files changed, 7 insertions(+), 7 deletions(-)
---
(DIR) diff --git a/lib/saulabs/reportable/report_tag_helper.rb b/lib/saulabs/reportable/report_tag_helper.rb
@@ -36,7 +36,7 @@ module Saulabs
# <%= report_tag(User.registrations_report, :width => 200, :height => 100, :color => '000') %>
#
def google_report_tag(data, options = {})
- options.reverse_merge!({ :width => 300, :height => 34, :line_color => '0077cc', :fill_color => 'e6f2fa', :labels => [], :alt => '', :title => '' })
+ options.reverse_merge!(Config.google_options)
data = data.collect { |d| d[1] }
labels = ''
unless options[:labels].empty?
@@ -47,7 +47,7 @@ module Saulabs
labels = "&chxt=#{options[:labels].map(&:to_s).join(',')}&chxr=#{options[:labels].collect{|l| chxr[l]}.join('|')}"
end
title = ''
- unless options[:title].empty?
+ unless options[:title].blank?
title = "&chtt=#{options[:title]}"
end
image_tag(
(DIR) diff --git a/spec/other/report_tag_helper_spec.rb b/spec/other/report_tag_helper_spec.rb
@@ -35,7 +35,7 @@ describe Saulabs::Reportable::ReportTagHelper do
it 'should render an image with the correct source' do
@helper.should_receive(:image_tag).once.with(
'http://chart.apis.google.com/chart?cht=ls&chs=300x34&chd=t:1.0,2.0,3.0&chco=0077cc&chm=B,e6f2fa,0,0,0&chls=1,0,0&chds=1.0,3.0',
- { :title => '', :alt => '' }
+ { :title => nil, :alt => nil }
)
@helper.google_report_tag([[DateTime.now, 1.0], [DateTime.now, 2.0], [DateTime.now, 3.0]])
@@ -44,7 +44,7 @@ describe Saulabs::Reportable::ReportTagHelper do
it 'should add parameters for labels to the source of the image if rendering of lables is specified' do
@helper.should_receive(:image_tag).once.with(
'http://chart.apis.google.com/chart?cht=ls&chs=300x34&chd=t:1.0,2.0,3.0&chco=0077cc&chm=B,e6f2fa,0,0,0&chls=1,0,0&chds=1.0,3.0&chxt=x,y,r,t&chxr=0,0,3|1,0,3.0|2,0,3.0|3,0,3',
- { :title => '', :alt => '' }
+ { :title => nil, :alt => nil }
)
@helper.google_report_tag([[DateTime.now, 1.0], [DateTime.now, 2.0], [DateTime.now, 3.0]], :labels => [:x, :y, :r, :t])
@@ -53,7 +53,7 @@ describe Saulabs::Reportable::ReportTagHelper do
it 'should set the parameters for custom colors if custom colors are specified' do
@helper.should_receive(:image_tag).once.with(
'http://chart.apis.google.com/chart?cht=ls&chs=300x34&chd=t:1.0,2.0,3.0&chco=000000&chm=B,ffffff,0,0,0&chls=1,0,0&chds=1.0,3.0',
- { :title => '', :alt => '' }
+ { :title => nil, :alt => nil }
)
@helper.google_report_tag([[DateTime.now, 1.0], [DateTime.now, 2.0], [DateTime.now, 3.0]], :line_color => '000000', :fill_color => 'ffffff')
@@ -62,7 +62,7 @@ describe Saulabs::Reportable::ReportTagHelper do
it 'should set the parameters for a custom title if a title specified' do
@helper.should_receive(:image_tag).once.with(
'http://chart.apis.google.com/chart?cht=ls&chs=300x34&chd=t:1.0,2.0,3.0&chco=0077cc&chm=B,e6f2fa,0,0,0&chls=1,0,0&chds=1.0,3.0&chtt=title',
- { :title => 'title', :alt => '' }
+ { :title => 'title', :alt => nil }
)
@helper.google_report_tag([[DateTime.now, 1.0], [DateTime.now, 2.0], [DateTime.now, 3.0]], :title => 'title')
@@ -71,7 +71,7 @@ describe Saulabs::Reportable::ReportTagHelper do
it 'should use a specified alt text as alt text for the image' do
@helper.should_receive(:image_tag).once.with(
'http://chart.apis.google.com/chart?cht=ls&chs=300x34&chd=t:1.0,2.0,3.0&chco=0077cc&chm=B,e6f2fa,0,0,0&chls=1,0,0&chds=1.0,3.0',
- { :title => '', :alt => 'alt' }
+ { :title => nil, :alt => 'alt' }
)
@helper.google_report_tag([[DateTime.now, 1.0], [DateTime.now, 2.0], [DateTime.now, 3.0]], :alt => 'alt')