| * cleaned Readme * allow definition od title for the generated sparkline image … | |
| Log | |
| Files | |
| Refs | |
| README | |
| --- | |
| commit a0b40bc8924c92736fa148ff4625dccc2b4e8a6e | |
| parent 1fb6c00be0c30f0a4ce7c97035830c5506e5ffab | |
| Author: Marco Otte-Witte <[email protected]> | |
| Date: Wed, 24 Feb 2010 19:39:35 +0100 | |
| * cleaned Readme | |
| * allow definition od title for the generated sparkline image | |
| Diffstat: | |
| M HISTORY.rdoc | 32 +++--------------------------… | |
| M lib/saulabs/reportable/sparkline_t… | 10 +++++++--- | |
| M spec/other/sparkline_tag_helper_sp… | 18 ++++++++++++++++++ | |
| 3 files changed, 28 insertions(+), 32 deletions(-) | |
| --- | |
| diff --git a/HISTORY.rdoc b/HISTORY.rdoc | |
| @@ -1,29 +1,3 @@ | |
| -=== v1.3.2 | |
| +=== v1.0.0 | |
| -* the tag helper now support options for title and alt tags (thanks to jan (ht… | |
| -* reports are now cached also when conditions are specified (thanks to eric (h… | |
| - | |
| -=== v1.3.1 | |
| - | |
| -* fixed migration template | |
| -* fixed data type returned by the report methods | |
| - | |
| -=== v1.3 | |
| - | |
| -* Fixed another bug where two report runs with different :end_date values woul… | |
| -* Entries in the report cache entry are no longer identified by the :limit the… | |
| -* rewrote the data retrieval and processing code, it's now much more compact a… | |
| - | |
| -=== v1.2 | |
| - | |
| -* FIXED: duplicate key error when using custom time zones (thanks to myronmars… | |
| - | |
| -=== v1.1 | |
| - | |
| -* new :end_date option: if specified, only data for the reporting periods for … | |
| -* added rcov report and spec report | |
| - | |
| - | |
| -=== prior to v1.1 | |
| - | |
| -* cannot remember, should habe started a history file right from the beginning… | |
| -\ No newline at end of file | |
| +* Initial release of the new Reportable gem (this was formerly ReportsAsSparkl… | |
| +\ No newline at end of file | |
| diff --git a/lib/saulabs/reportable/sparkline_tag_helper.rb b/lib/saulabs/repor… | |
| @@ -25,7 +25,7 @@ module Saulabs #:nodoc: | |
| def sparkline_tag(data, options = {}) | |
| options.reverse_merge!({ :width => 300, :height => 34, :line_color => … | |
| data = data.collect { |d| d[1] } | |
| - labels = "" | |
| + labels = '' | |
| unless options[:labels].empty? | |
| chxr = {} | |
| options[:labels].each_with_index do |l, i| | |
| @@ -33,9 +33,13 @@ module Saulabs #:nodoc: | |
| end | |
| labels = "&chxt=#{options[:labels].map(&:to_s).join(',')}&chxr=#{opt… | |
| end | |
| + title = '' | |
| + unless options[:title].empty? | |
| + title = "&chtt=#{options[:title]}" | |
| + end | |
| image_tag( | |
| - "http://chart.apis.google.com/chart?cht=ls&chs=#{options[:width]}x#{… | |
| - :alt => options[:alt], | |
| + "http://chart.apis.google.com/chart?cht=ls&chs=#{options[:width]}x#{… | |
| + :alt => options[:alt], | |
| :title => options[:title] | |
| ) | |
| end | |
| diff --git a/spec/other/sparkline_tag_helper_spec.rb b/spec/other/sparkline_tag… | |
| @@ -35,6 +35,24 @@ describe Saulabs::Reportable::SparklineTagHelper do | |
| @helper.sparkline_tag([[DateTime.now, 1.0], [DateTime.now, 2.0], [DateTi… | |
| end | |
| + 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.… | |
| + { :title => 'title', :alt => '' } | |
| + ) | |
| + | |
| + @helper.sparkline_tag([[DateTime.now, 1.0], [DateTime.now, 2.0], [DateTi… | |
| + end | |
| + | |
| + 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.… | |
| + { :title => '', :alt => 'alt' } | |
| + ) | |
| + | |
| + @helper.sparkline_tag([[DateTime.now, 1.0], [DateTime.now, 2.0], [DateTi… | |
| + end | |
| + | |
| end | |
| end |