Introduction
Introduction Statistics Contact Development Disclaimer Help
added ReportingPeriod#previous - reportable - Fork of reportable required by Wa…
Log
Files
Refs
README
---
commit b3c5f1a04b24429fe96a1b2eeb1dadc63214574d
parent a9b9ce2570cd9c6a5a64b562efebcf5d7b549a27
Author: Marco Otte-Witte <[email protected]>
Date: Mon, 19 Jan 2009 13:15:35 +0100
added ReportingPeriod#previous
Diffstat:
M lib/kvlr/reports_as_sparkline/repo… | 14 ++++++++++++++
M rdoc/classes/Kvlr/ReportsAsSparkli… | 2 +-
M rdoc/classes/Kvlr/ReportsAsSparkli… | 2 +-
M rdoc/classes/Kvlr/ReportsAsSparkli… | 24 ++++++++++++------------
M rdoc/classes/Kvlr/ReportsAsSparkli… | 38 +++++++++++++++++++++++++++…
M rdoc/created.rid | 2 +-
M rdoc/files/lib/kvlr/reports_as_spa… | 2 +-
M rdoc/fr_method_index.html | 5 +++--
M spec/classes/reporting_period_spec… | 36 +++++++++++++++++++++++++++…
9 files changed, 107 insertions(+), 18 deletions(-)
---
diff --git a/lib/kvlr/reports_as_sparkline/reporting_period.rb b/lib/kvlr/repor…
@@ -64,6 +64,20 @@ module Kvlr #:nodoc:
end
end
+ # Returns the previous reporting period (that is next hour/day/month/yea…
+ def previous
+ return case @grouping.identifier
+ when :hour
+ self.class.new(@grouping, @date_time - 1.hour)
+ when :day
+ self.class.new(@grouping, @date_time - 1.day)
+ when :week
+ self.class.new(@grouping, @date_time - 1.week)
+ when :month
+ self.class.new(@grouping, @date_time - 1.month)
+ end
+ end
+
def ==(other) #:nodoc:
if other.class == Kvlr::ReportsAsSparkline::ReportingPeriod
return @date_time.to_s == other.date_time.to_s && @grouping.identifi…
diff --git a/rdoc/classes/Kvlr/ReportsAsSparkline/ClassMethods.html b/rdoc/clas…
@@ -115,7 +115,7 @@
<p>
Generates a report on a model. That report can then be executed via the new
method &lt;name&gt;_report (see documentation of <a
-href="Report.html#M000010">Kvlr::ReportsAsSparkline::Report#run</a>).
+href="Report.html#M000011">Kvlr::ReportsAsSparkline::Report#run</a>).
</p>
<h4>Parameters</h4>
<ul>
diff --git a/rdoc/classes/Kvlr/ReportsAsSparkline/CumulatedReport.html b/rdoc/c…
@@ -139,7 +139,7 @@ href="Report.html">Kvlr::ReportsAsSparkline::Report</a>)
<div class="method-description">
<p>
Runs the report (see <a
-href="Report.html#M000010">Kvlr::ReportsAsSparkline::Report#run</a>)
+href="Report.html#M000011">Kvlr::ReportsAsSparkline::Report#run</a>)
</p>
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000003-source');return false;">[Source]</a><…
diff --git a/rdoc/classes/Kvlr/ReportsAsSparkline/Report.html b/rdoc/classes/Kv…
@@ -93,8 +93,8 @@ and calculations
<h3 class="section-bar">Methods</h3>
<div class="name-list">
- <a href="#M000009">new</a>&nbsp;&nbsp;
- <a href="#M000010">run</a>&nbsp;&nbsp;
+ <a href="#M000010">new</a>&nbsp;&nbsp;
+ <a href="#M000011">run</a>&nbsp;&nbsp;
</div>
</div>
@@ -154,11 +154,11 @@ and calculations
<div id="methods">
<h3 class="section-bar">Public Class methods</h3>
- <div id="method-M000009" class="method-detail">
- <a name="M000009"></a>
+ <div id="method-M000010" class="method-detail">
+ <a name="M000010"></a>
<div class="method-heading">
- <a href="#M000009" class="method-signature">
+ <a href="#M000010" class="method-signature">
<span class="method-name">new</span><span class="method-args">(klass…
</a>
</div>
@@ -210,8 +210,8 @@ false)
</li>
</ul>
<p><a class="source-toggle" href="#"
- onclick="toggleCode('M000009-source');return false;">[Source]</a><…
- <div class="method-source-code" id="M000009-source">
+ onclick="toggleCode('M000010-source');return false;">[Source]</a><…
+ <div class="method-source-code" id="M000010-source">
<pre>
<span class="ruby-comment cmt"># File lib/kvlr/reports_as_sparkline/report…
23: <span class="ruby-keyword kw">def</span> <span class="ruby-identifie…
@@ -237,11 +237,11 @@ false)
<h3 class="section-bar">Public Instance methods</h3>
- <div id="method-M000010" class="method-detail">
- <a name="M000010"></a>
+ <div id="method-M000011" class="method-detail">
+ <a name="M000011"></a>
<div class="method-heading">
- <a href="#M000010" class="method-signature">
+ <a href="#M000011" class="method-signature">
<span class="method-name">run</span><span class="method-args">(optio…
</a>
</div>
@@ -272,8 +272,8 @@ false)
</li>
</ul>
<p><a class="source-toggle" href="#"
- onclick="toggleCode('M000010-source');return false;">[Source]</a><…
- <div class="method-source-code" id="M000010-source">
+ onclick="toggleCode('M000011-source');return false;">[Source]</a><…
+ <div class="method-source-code" id="M000011-source">
<pre>
<span class="ruby-comment cmt"># File lib/kvlr/reports_as_sparkline/report…
47: <span class="ruby-keyword kw">def</span> <span class="ruby-identifie…
diff --git a/rdoc/classes/Kvlr/ReportsAsSparkline/ReportingPeriod.html b/rdoc/c…
@@ -98,6 +98,7 @@ together.
<a href="#M000007">first</a>&nbsp;&nbsp;
<a href="#M000006">new</a>&nbsp;&nbsp;
<a href="#M000008">next</a>&nbsp;&nbsp;
+ <a href="#M000009">previous</a>&nbsp;&nbsp;
</div>
</div>
@@ -264,6 +265,43 @@ hour/day/month/year)
</div>
</div>
+ <div id="method-M000009" class="method-detail">
+ <a name="M000009"></a>
+
+ <div class="method-heading">
+ <a href="#M000009" class="method-signature">
+ <span class="method-name">previous</span><span class="method-args">(…
+ </a>
+ </div>
+
+ <div class="method-description">
+ <p>
+Returns the <a href="ReportingPeriod.html#M000009">previous</a> reporting
+period (that is <a href="ReportingPeriod.html#M000008">next</a>
+hour/day/month/year)
+</p>
+ <p><a class="source-toggle" href="#"
+ onclick="toggleCode('M000009-source');return false;">[Source]</a><…
+ <div class="method-source-code" id="M000009-source">
+<pre>
+ <span class="ruby-comment cmt"># File lib/kvlr/reports_as_sparkline/report…
+68: <span class="ruby-keyword kw">def</span> <span class="ruby-identifie…
+69: <span class="ruby-keyword kw">return</span> <span class="ruby-keyw…
+70: <span class="ruby-keyword kw">when</span> <span class="ruby-iden…
+71: <span class="ruby-keyword kw">self</span>.<span class="ruby-id…
+72: <span class="ruby-keyword kw">when</span> <span class="ruby-iden…
+73: <span class="ruby-keyword kw">self</span>.<span class="ruby-id…
+74: <span class="ruby-keyword kw">when</span> <span class="ruby-iden…
+75: <span class="ruby-keyword kw">self</span>.<span class="ruby-id…
+76: <span class="ruby-keyword kw">when</span> <span class="ruby-iden…
+77: <span class="ruby-keyword kw">self</span>.<span class="ruby-id…
+78: <span class="ruby-keyword kw">end</span>
+79: <span class="ruby-keyword kw">end</span>
+</pre>
+ </div>
+ </div>
+ </div>
+
</div>
diff --git a/rdoc/created.rid b/rdoc/created.rid
@@ -1 +1 @@
-Mon, 19 Jan 2009 13:09:50 +0100
+Mon, 19 Jan 2009 13:15:23 +0100
diff --git a/rdoc/files/lib/kvlr/reports_as_sparkline/reporting_period_rb.html …
@@ -56,7 +56,7 @@
</tr>
<tr class="top-aligned-row">
<td><strong>Last Update:</strong></td>
- <td>Thu Jan 15 11:36:51 +0100 2009</td>
+ <td>Mon Jan 19 13:11:39 +0100 2009</td>
</tr>
</table>
</div>
diff --git a/rdoc/fr_method_index.html b/rdoc/fr_method_index.html
@@ -24,11 +24,12 @@
<a href="classes/Kvlr/ReportsAsSparkline/Grouping.html#M000005">identifier…
<a href="classes/Kvlr/ReportsAsSparkline/ReportingPeriod.html#M000006">new…
<a href="classes/Kvlr/ReportsAsSparkline/Grouping.html#M000004">new (Kvlr:…
- <a href="classes/Kvlr/ReportsAsSparkline/Report.html#M000009">new (Kvlr::R…
+ <a href="classes/Kvlr/ReportsAsSparkline/Report.html#M000010">new (Kvlr::R…
<a href="classes/Kvlr/ReportsAsSparkline/ReportingPeriod.html#M000008">nex…
+ <a href="classes/Kvlr/ReportsAsSparkline/ReportingPeriod.html#M000009">pre…
<a href="classes/Kvlr/ReportsAsSparkline/ClassMethods.html#M000002">report…
<a href="classes/Kvlr/ReportsAsSparkline/CumulatedReport.html#M000003">run…
- <a href="classes/Kvlr/ReportsAsSparkline/Report.html#M000010">run (Kvlr::R…
+ <a href="classes/Kvlr/ReportsAsSparkline/Report.html#M000011">run (Kvlr::R…
<a href="classes/Kvlr/ReportsAsSparkline/SparklineTagHelper.html#M000001">…
</div>
</div>
diff --git a/spec/classes/reporting_period_spec.rb b/spec/classes/reporting_per…
@@ -127,6 +127,42 @@ describe Kvlr::ReportsAsSparkline::ReportingPeriod do
end
+ describe '#previous' do
+
+ it 'should return a reporting period with date and time one hour before th…
+ now = Time.now
+ reporting_period = Kvlr::ReportsAsSparkline::ReportingPeriod.new(Kvlr::R…
+ expected = now - 1.hour
+
+ reporting_period.previous.date_time.should == DateTime.new(expected.year…
+ end
+
+ it 'should return a reporting period with date one day before the current …
+ now = Time.now
+ reporting_period = Kvlr::ReportsAsSparkline::ReportingPeriod.new(Kvlr::R…
+ expected = now - 1.day
+
+ reporting_period.previous.date_time.should == Date.new(expected.year, ex…
+ end
+
+ it 'should return a reporting period with date one week before the current…
+ now = DateTime.now
+ reporting_period = Kvlr::ReportsAsSparkline::ReportingPeriod.new(Kvlr::R…
+ expected = reporting_period.date_time - 1.week
+
+ reporting_period.previous.date_time.should == Date.new(expected.year, ex…
+ end
+
+ it 'should return a reporting period with date of the first day in the mon…
+ now = Time.now
+ reporting_period = Kvlr::ReportsAsSparkline::ReportingPeriod.new(Kvlr::R…
+ expected = reporting_period.date_time - 1.month
+
+ reporting_period.previous.date_time.should == Date.new(expected.year, ex…
+ end
+
+ end
+
describe '#==' do
it 'should return true for 2 reporting periods with the same date_time and…
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.