| renamed AssetTagHelper to SparklineTagHelper - reportable - Fork of reportable … | |
| Log | |
| Files | |
| Refs | |
| README | |
| --- | |
| commit 811195e44a63b61df0a806e8f53c927a42ea6751 | |
| parent 683b03c8ae82c2ad348e5a6490aeafa5365c9cdb | |
| Author: Marco Otte-Witte <[email protected]> | |
| Date: Thu, 15 Jan 2009 15:34:59 +0100 | |
| renamed AssetTagHelper to SparklineTagHelper | |
| Diffstat: | |
| M init.rb | 2 +- | |
| D lib/kvlr/reports_as_sparkline/asse… | 33 ---------------------------… | |
| M lib/kvlr/reports_as_sparkline/repo… | 3 +-- | |
| A lib/kvlr/reports_as_sparkline/spar… | 33 +++++++++++++++++++++++++++… | |
| D spec/other/asset_tag_helper_spec.rb | 27 --------------------------- | |
| A spec/other/sparkline_tag_helper_sp… | 27 +++++++++++++++++++++++++++ | |
| 6 files changed, 62 insertions(+), 63 deletions(-) | |
| --- | |
| diff --git a/init.rb b/init.rb | |
| @@ -5,5 +5,5 @@ ActiveRecord::Base.class_eval do | |
| end | |
| ActionView::Base.class_eval do | |
| - include Kvlr::ReportsAsSparkline::AssetTagHelper | |
| + include Kvlr::ReportsAsSparkline::SparklineTagHelper | |
| end | |
| diff --git a/lib/kvlr/reports_as_sparkline/asset_tag_helper.rb b/lib/kvlr/repor… | |
| @@ -1,33 +0,0 @@ | |
| -module Kvlr #:nodoc: | |
| - | |
| - module ReportsAsSparkline #:nodoc: | |
| - | |
| - module AssetTagHelper | |
| - | |
| - # Renders a sparkline with the given data. | |
| - # | |
| - # ==== Parameters | |
| - # | |
| - # * <tt>data</tt> - The data to render the sparkline for | |
| - # | |
| - # ==== Options | |
| - # | |
| - # * <tt>width</tt> - The width of the generated image | |
| - # * <tt>height</tt> - The height of the generated image | |
| - # * <tt>color</tt> - The base color of the generated image (hex code) | |
| - # | |
| - # ==== Example | |
| - # <%= sparkline_tag(User.registrations_report, :width => 200, :height =>… | |
| - def sparkline_tag(data, options = {}) | |
| - options.reverse_merge!({:width => 300, :height => 34, :color => '0077c… | |
| - data.collect! { |d| d[1] } | |
| - image_tag( | |
| - "http://chart.apis.google.com/chart?cht=ls&chs=#{options[:width]}x#{… | |
| - ) | |
| - end | |
| - | |
| - end | |
| - | |
| - end | |
| - | |
| -end | |
| diff --git a/lib/kvlr/reports_as_sparkline/report.rb b/lib/kvlr/reports_as_spar… | |
| @@ -29,8 +29,7 @@ module Kvlr #:nodoc: | |
| @options = { | |
| :limit => options[:limit] || 100, | |
| :conditions => options[:conditions] || [], | |
| - :grouping => Grouping.new(options[:grouping] || :day), | |
| - :live_data => options[:live_data] || false | |
| + :grouping => Grouping.new(options[:grouping] || :day) | |
| } | |
| @options.merge!(options) | |
| @options.freeze | |
| diff --git a/lib/kvlr/reports_as_sparkline/sparkline_tag_helper.rb b/lib/kvlr/r… | |
| @@ -0,0 +1,33 @@ | |
| +module Kvlr #:nodoc: | |
| + | |
| + module ReportsAsSparkline #:nodoc: | |
| + | |
| + module SparklineTagHelper | |
| + | |
| + # Renders a sparkline with the given data. | |
| + # | |
| + # ==== Parameters | |
| + # | |
| + # * <tt>data</tt> - The data to render the sparkline for | |
| + # | |
| + # ==== Options | |
| + # | |
| + # * <tt>width</tt> - The width of the generated image | |
| + # * <tt>height</tt> - The height of the generated image | |
| + # * <tt>color</tt> - The base color of the generated image (hex code) | |
| + # | |
| + # ==== Example | |
| + # <%= sparkline_tag(User.registrations_report, :width => 200, :height =>… | |
| + def sparkline_tag(data, options = {}) | |
| + options.reverse_merge!({:width => 300, :height => 34, :color => '0077c… | |
| + data.collect! { |d| d[1] } | |
| + image_tag( | |
| + "http://chart.apis.google.com/chart?cht=ls&chs=#{options[:width]}x#{… | |
| + ) | |
| + end | |
| + | |
| + end | |
| + | |
| + end | |
| + | |
| +end | |
| diff --git a/spec/other/asset_tag_helper_spec.rb b/spec/other/asset_tag_helper_… | |
| @@ -1,27 +0,0 @@ | |
| -require File.join(File.dirname(__FILE__), '..', 'spec_helper') | |
| - | |
| -describe Kvlr::ReportsAsSparkline::AssetTagHelper do | |
| - | |
| - before do | |
| - @helper = TestHelper.new | |
| - end | |
| - | |
| - describe '#sparkline_tag' 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.… | |
| - ) | |
| - | |
| - @helper.sparkline_tag([[DateTime.now, 1.0], [DateTime.now, 2.0], [DateTi… | |
| - end | |
| - | |
| - end | |
| - | |
| -end | |
| - | |
| -class TestHelper | |
| - | |
| - include Kvlr::ReportsAsSparkline::AssetTagHelper | |
| - | |
| -end | |
| diff --git a/spec/other/sparkline_tag_helper_spec.rb b/spec/other/sparkline_tag… | |
| @@ -0,0 +1,27 @@ | |
| +require File.join(File.dirname(__FILE__), '..', 'spec_helper') | |
| + | |
| +describe Kvlr::ReportsAsSparkline::SparklineTagHelper do | |
| + | |
| + before do | |
| + @helper = TestHelper.new | |
| + end | |
| + | |
| + describe '#sparkline_tag' 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.… | |
| + ) | |
| + | |
| + @helper.sparkline_tag([[DateTime.now, 1.0], [DateTime.now, 2.0], [DateTi… | |
| + end | |
| + | |
| + end | |
| + | |
| +end | |
| + | |
| +class TestHelper | |
| + | |
| + include Kvlr::ReportsAsSparkline::SparklineTagHelper | |
| + | |
| +end |