Introduction
Introduction Statistics Contact Development Disclaimer Help
moved DateTime#reporting_period to Date#to_reporting_period - reportable - Fork…
Log
Files
Refs
README
---
commit 4599dc5418a0154fa7a355cca293ed4cf538f3a0
parent 226d0448e906b0ed7ab0466519799650f7753c54
Author: Marco Otte-Witte <[email protected]>
Date: Wed, 14 Jan 2009 17:27:48 +0800
moved DateTime#reporting_period to Date#to_reporting_period
Signed-off-by: Marco Otte-Witte <[email protected]>
Diffstat:
M init.rb | 2 +-
D lib/kvlr/core_extensions/date_time… | 25 -------------------------
M lib/kvlr/reports_as_sparkline/repo… | 2 +-
D spec/classes/date_time_spec.rb | 27 ---------------------------
4 files changed, 2 insertions(+), 54 deletions(-)
---
diff --git a/init.rb b/init.rb
@@ -1,5 +1,5 @@
require 'kvlr/reports_as_sparkline'
-require 'kvlr/core_extensions/date_time'
+require 'kvlr/core_extensions/date'
ActiveRecord::Base.class_eval do
include Kvlr::ReportsAsSparkline
diff --git a/lib/kvlr/core_extensions/date_time.rb b/lib/kvlr/core_extensions/d…
@@ -1,25 +0,0 @@
-module Kvlr #:nodoc:
-
- module CoreExtensions #:nodoc:
-
- module DateTime
-
- ::DateTime.class_eval do
-
- # Converts the DateTime into a Kvlr::ReportsAsSparkline::ReportingPeri…
- def to_reporting_period(grouping)
- if grouping.is_a?(Symbol)
- grouping = Kvlr::ReportsAsSparkline::Grouping.new(grouping)
- elsif !grouping.is_a?(Kvlr::ReportsAsSparkline::Grouping)
- raise ArgumentError.new('grouping must be either an instance of Kv…
- end
- Kvlr::ReportsAsSparkline::ReportingPeriod.new(grouping, self)
- end
-
- end
-
- end
-
- end
-
-end
diff --git a/lib/kvlr/reports_as_sparkline/report_cache.rb b/lib/kvlr/reports_a…
@@ -23,7 +23,7 @@ module Kvlr #:nodoc:
:limit => limit,
:order => 'reporting_period ASC'
)
- last_reporting_period_to_read = ReportingPeriod.new(grouping, cach…
+ last_reporting_period_to_read = cached_data.last.reporting_period.…
end
new_data = yield(last_reporting_period_to_read.date_time)
prepare_result(new_data, cached_data, last_reporting_period_to_read,…
diff --git a/spec/classes/date_time_spec.rb b/spec/classes/date_time_spec.rb
@@ -1,27 +0,0 @@
-require File.join(File.dirname(__FILE__), '..', 'spec_helper')
-
-describe DateTime do
-
- describe '#to_reporting_period' do
-
- it 'should return a reporting period for the specified grouping and instan…
- date_time = DateTime.now
- grouping = Kvlr::ReportsAsSparkline::Grouping.new(:hour)
-
- date_time.to_reporting_period(grouping).should == Kvlr::ReportsAsSparkli…
- end
-
- it 'should return a reporting period for the specified grouping and instan…
- date_time = DateTime.now
- grouping = Kvlr::ReportsAsSparkline::Grouping.new(:hour)
-
- date_time.to_reporting_period(:hour).should == Kvlr::ReportsAsSparkline:…
- end
-
- it 'should raise an ArgumentError if the grouping is not specified as a sy…
- lambda { DateTime.now.to_reporting_period(1) }.should raise_error(Argume…
- end
-
- end
-
-end
You are viewing proxied material from jay.scot. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.