Introduction
Introduction Statistics Contact Development Disclaimer Help
it's all about the Sau - reportable - Fork of reportable required by WarVox, fr…
Log
Files
Refs
README
---
commit 0411548e003b4d667dba9a57bc29a6d52f6b7f04
parent 117dc0a6cde2483aa164b7994857acea11fa657f
Author: Marco Otte-Witte <[email protected]>
Date: Mon, 8 Feb 2010 18:13:39 +0100
it's all about the Sau
Diffstat:
M README.rdoc | 12 ++++++------
M doc/classes/Simplabs/ReportsAsSpar… | 16 ++++++++--------
M doc/classes/Simplabs/ReportsAsSpar… | 22 +++++++++++-----------
M doc/classes/Simplabs/ReportsAsSpar… | 16 ++++++++--------
M doc/classes/Simplabs/ReportsAsSpar… | 12 ++++++------
M doc/classes/Simplabs/ReportsAsSpar… | 10 +++++-----
M doc/files/README_rdoc.html | 10 +++++-----
M doc/files/lib/simplabs/reports_as_… | 2 +-
M doc/files/lib/simplabs/reports_as_… | 2 +-
M doc/files/lib/simplabs/reports_as_… | 2 +-
M doc/files/lib/simplabs/reports_as_… | 2 +-
M doc/files/lib/simplabs/reports_as_… | 2 +-
M doc/files/lib/simplabs/reports_as_… | 2 +-
M doc/files/lib/simplabs/reports_as_… | 2 +-
M doc/fr_class_index.html | 10 +++++-----
M doc/fr_file_index.html | 14 +++++++-------
M doc/fr_method_index.html | 16 ++++++++--------
M init.rb | 6 +++---
A lib/saulabs/reports_as_sparkline.rb | 54 +++++++++++++++++++++++++++++…
A lib/saulabs/reports_as_sparkline/c… | 45 +++++++++++++++++++++++++++…
A lib/saulabs/reports_as_sparkline/g… | 115 +++++++++++++++++++++++++++…
A lib/saulabs/reports_as_sparkline/r… | 119 +++++++++++++++++++++++++++…
A lib/saulabs/reports_as_sparkline/r… | 139 +++++++++++++++++++++++++++…
A lib/saulabs/reports_as_sparkline/r… | 103 +++++++++++++++++++++++++++…
A lib/saulabs/reports_as_sparkline/s… | 47 +++++++++++++++++++++++++++…
D lib/simplabs/reports_as_sparkline.… | 54 ---------------------------…
D lib/simplabs/reports_as_sparkline/… | 45 ---------------------------…
D lib/simplabs/reports_as_sparkline/… | 115 ---------------------------…
D lib/simplabs/reports_as_sparkline/… | 119 ---------------------------…
D lib/simplabs/reports_as_sparkline/… | 139 ---------------------------…
D lib/simplabs/reports_as_sparkline/… | 103 ---------------------------…
D lib/simplabs/reports_as_sparkline/… | 47 ---------------------------…
M spec/classes/cumulated_report_spec… | 28 ++++++++++++++--------------
M spec/classes/grouping_spec.rb | 38 ++++++++++++++++-------------…
M spec/classes/report_cache_spec.rb | 112 ++++++++++++++++-------------…
M spec/classes/report_spec.rb | 70 ++++++++++++++++-------------…
M spec/classes/reporting_period_spec… | 92 ++++++++++++++++-----------…
M spec/other/report_method_spec.rb | 4 ++--
M spec/other/sparkline_tag_helper_sp… | 4 ++--
39 files changed, 875 insertions(+), 875 deletions(-)
---
diff --git a/README.rdoc b/README.rdoc
@@ -4,7 +4,7 @@ ReportsAsSparkline enables you to generate sparkline reports fr…
See the API docs at http://docs.github.com/marcoow/reports_as_sparkline.
-The CI server is at http://ci.simplabs.com/reportsassparkline.
+The CI server is at http://ci.saulabs.com/reportsassparkline.
== Usage
@@ -49,8 +49,8 @@ When invoking the report, you can override some of the option…
=== The Report cache
-Unless you specify parameters that make it impossible to cache report results,…
-<b>Beware that when you modify data in the cache, report results may be incorr…
+Unless you specify parameters that make it impossible to cache report results,…
+<b>Beware that when you modify data in the cache, report results may be incorr…
method.
<b>Example</b>
@@ -63,7 +63,7 @@ For a report defined as
you can clear the cache with
- Simplabs::ReportsAsSparkline::ReportCache.clear_for(User, :registrations)
+ Saulabs::ReportsAsSparkline::ReportCache.clear_for(User, :registrations)
=== In your views
@@ -104,7 +104,7 @@ If you are on Rails < 2.1, do this from your RAILS_ROOT
== Performance
To achieve best performance, you should add indices to your tables on the date…
-used for grouping the records (see Simplabs::ReportsAsSparkline::ClassMethods.…
+used for grouping the records (see Saulabs::ReportsAsSparkline::ClassMethods.r…
add_index :[table], :[date_column]
@@ -140,4 +140,4 @@ If you want to suggest any new features or report bugs, do …
== Author
-© 2008-2010 Marco Otte-Witte (http://simplabs.com), Martin Kavalar, released …
+© 2008-2010 Marco Otte-Witte (http://saulabs.com), Martin Kavalar, released u…
diff --git a/doc/classes/Simplabs/ReportsAsSparkline/ClassMethods.html b/doc/cl…
@@ -5,7 +5,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
- <title>Module: Simplabs::ReportsAsSparkline::ClassMethods</title>
+ <title>Module: Saulabs::ReportsAsSparkline::ClassMethods</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" medi…
@@ -50,13 +50,13 @@
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Module</strong></td>
- <td class="class-name-in-header">Simplabs::ReportsAsSparkline::Class…
+ <td class="class-name-in-header">Saulabs::ReportsAsSparkline::ClassM…
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
- <a href="../../../files/lib/simplabs/reports_as_sparkline_rb.h…
- lib/simplabs/reports_as_sparkline.rb
+ <a href="../../../files/lib/saulabs/reports_as_sparkline_rb.ht…
+ lib/saulabs/reports_as_sparkline.rb
</a>
<br />
</td>
@@ -115,7 +115,7 @@
<p>
Generates a report on a model. That report can then be executed via the new
method <tt>&lt;name&gt;_report</tt> (see documentation of <a
-href="Report.html#M000008">Simplabs::ReportsAsSparkline::Report#run</a>).
+href="Report.html#M000008">Saulabs::ReportsAsSparkline::Report#run</a>).
</p>
<h4>Parameters</h4>
<ul>
@@ -181,14 +181,14 @@ the <tt>:limit</tt> reporting periods until this date.
onclick="toggleCode('M000002-source');return false;">[Source]</a><…
<div class="method-source-code" id="M000002-source">
<pre>
- <span class="ruby-comment cmt"># File lib/simplabs/reports_as_sparkline.rb…
+ <span class="ruby-comment cmt"># File lib/saulabs/reports_as_sparkline.rb,…
36: <span class="ruby-keyword kw">def</span> <span class="ruby-identifie…
37: (<span class="ruby-keyword kw">class</span> <span class="ruby-oper…
38: <span class="ruby-identifier">define_method</span> <span class="…
39: <span class="ruby-keyword kw">if</span> <span class="ruby-iden…
-40: <span class="ruby-identifier">report</span> = <span class="r…
+40: <span class="ruby-identifier">report</span> = <span class="r…
41: <span class="ruby-keyword kw">else</span>
-42: <span class="ruby-identifier">report</span> = <span class="r…
+42: <span class="ruby-identifier">report</span> = <span class="r…
43: <span class="ruby-keyword kw">end</span>
44: <span class="ruby-identifier">raise</span> <span class="ruby-c…
45: <span class="ruby-identifier">report</span>.<span class="ruby-…
diff --git a/doc/classes/Simplabs/ReportsAsSparkline/CumulatedReport.html b/doc…
@@ -5,7 +5,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
- <title>Class: Simplabs::ReportsAsSparkline::CumulatedReport</title>
+ <title>Class: Saulabs::ReportsAsSparkline::CumulatedReport</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" medi…
@@ -50,13 +50,13 @@
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
- <td class="class-name-in-header">Simplabs::ReportsAsSparkline::Cumul…
+ <td class="class-name-in-header">Saulabs::ReportsAsSparkline::Cumula…
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
- <a href="../../../files/lib/simplabs/reports_as_sparkline/cumu…
- lib/simplabs/reports_as_sparkline/cumulated_report.rb
+ <a href="../../../files/lib/saulabs/reports_as_sparkline/cumul…
+ lib/saulabs/reports_as_sparkline/cumulated_report.rb
</a>
<br />
</td>
@@ -83,18 +83,18 @@
<div id="description">
<p>
A special report class that cumulates all data (see <a
-href="Report.html">Simplabs::ReportsAsSparkline::Report</a>)
+href="Report.html">Saulabs::ReportsAsSparkline::Report</a>)
</p>
<h4>Examples</h4>
<p>
-When <a href="Report.html">Simplabs::ReportsAsSparkline::Report</a> returns
+When <a href="Report.html">Saulabs::ReportsAsSparkline::Report</a> returns
</p>
<pre>
[[&lt;DateTime today&gt;, 1], [&lt;DateTime yesterday&gt;, 2], etc.]
</pre>
<p>
<a
-href="CumulatedReport.html">Simplabs::ReportsAsSparkline::CumulatedReport</a>
+href="CumulatedReport.html">Saulabs::ReportsAsSparkline::CumulatedReport</a>
returns
</p>
<pre>
@@ -146,13 +146,13 @@ returns
<div class="method-description">
<p>
Runs the report (see <a
-href="Report.html#M000008">Simplabs::ReportsAsSparkline::Report#run</a>)
+href="Report.html#M000008">Saulabs::ReportsAsSparkline::Report#run</a>)
</p>
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000003-source');return false;">[Source]</a><…
<div class="method-source-code" id="M000003-source">
<pre>
- <span class="ruby-comment cmt"># File lib/simplabs/reports_as_sparkline/cu…
+ <span class="ruby-comment cmt"># File lib/saulabs/reports_as_sparkline/cum…
19: <span class="ruby-keyword kw">def</span> <span class="ruby-identifie…
20: <span class="ruby-identifier">cumulate</span>(<span class="ruby-ke…
21: <span class="ruby-keyword kw">end</span>
@@ -177,7 +177,7 @@ href="Report.html#M000008">Simplabs::ReportsAsSparkline::Re…
onclick="toggleCode('M000004-source');return false;">[Source]</a><…
<div class="method-source-code" id="M000004-source">
<pre>
- <span class="ruby-comment cmt"># File lib/simplabs/reports_as_sparkline/cu…
+ <span class="ruby-comment cmt"># File lib/saulabs/reports_as_sparkline/cum…
25: <span class="ruby-keyword kw">def</span> <span class="ruby-identif…
26: <span class="ruby-identifier">first_reporting_period</span> = <s…
27: <span class="ruby-identifier">acc</span> = <span class="ruby-ide…
@@ -207,7 +207,7 @@ href="Report.html#M000008">Simplabs::ReportsAsSparkline::Re…
onclick="toggleCode('M000005-source');return false;">[Source]</a><…
<div class="method-source-code" id="M000005-source">
<pre>
- <span class="ruby-comment cmt"># File lib/simplabs/reports_as_sparkline/cu…
+ <span class="ruby-comment cmt"># File lib/saulabs/reports_as_sparkline/cum…
36: <span class="ruby-keyword kw">def</span> <span class="ruby-identif…
37: <span class="ruby-identifier">conditions</span> = <span class="r…
38: <span class="ruby-ivar">@klass</span>.<span class="ruby-identifi…
diff --git a/doc/classes/Simplabs/ReportsAsSparkline/Report.html b/doc/classes/…
@@ -5,7 +5,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
- <title>Class: Simplabs::ReportsAsSparkline::Report</title>
+ <title>Class: Saulabs::ReportsAsSparkline::Report</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" medi…
@@ -50,13 +50,13 @@
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
- <td class="class-name-in-header">Simplabs::ReportsAsSparkline::Repor…
+ <td class="class-name-in-header">Saulabs::ReportsAsSparkline::Report…
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
- <a href="../../../files/lib/simplabs/reports_as_sparkline/repo…
- lib/simplabs/reports_as_sparkline/report.rb
+ <a href="../../../files/lib/saulabs/reports_as_sparkline/repor…
+ lib/saulabs/reports_as_sparkline/report.rb
</a>
<br />
</td>
@@ -168,12 +168,12 @@ and calculations
<ul>
<li><tt>klass</tt> - The model the report works on (This is the class you
invoke <a
-href="ClassMethods.html#M000002">Simplabs::ReportsAsSparkline::ClassMethods#re…
+href="ClassMethods.html#M000002">Saulabs::ReportsAsSparkline::ClassMethods#rep…
on)
</li>
<li><tt>name</tt> - The name of the report (as in <a
-href="ClassMethods.html#M000002">Simplabs::ReportsAsSparkline::ClassMethods#re…
+href="ClassMethods.html#M000002">Saulabs::ReportsAsSparkline::ClassMethods#rep…
</li>
</ul>
@@ -224,7 +224,7 @@ the <tt>:limit</tt> reporting periods until this date.
onclick="toggleCode('M000007-source');return false;">[Source]</a><…
<div class="method-source-code" id="M000007-source">
<pre>
- <span class="ruby-comment cmt"># File lib/simplabs/reports_as_sparkline/re…
+ <span class="ruby-comment cmt"># File lib/saulabs/reports_as_sparkline/rep…
24: <span class="ruby-keyword kw">def</span> <span class="ruby-identifie…
25: <span class="ruby-identifier">ensure_valid_options</span>(<span cl…
26: <span class="ruby-ivar">@klass</span> = <span class="ruby-i…
@@ -293,7 +293,7 @@ the <tt>:limit</tt> reporting periods until this date.
onclick="toggleCode('M000008-source');return false;">[Source]</a><…
<div class="method-source-code" id="M000008-source">
<pre>
- <span class="ruby-comment cmt"># File lib/simplabs/reports_as_sparkline/re…
+ <span class="ruby-comment cmt"># File lib/saulabs/reports_as_sparkline/rep…
50: <span class="ruby-keyword kw">def</span> <span class="ruby-identifie…
51: <span class="ruby-identifier">custom_conditions</span> = <span cla…
52: <span class="ruby-identifier">options</span> = <span class="ruby-i…
diff --git a/doc/classes/Simplabs/ReportsAsSparkline/ReportCache.html b/doc/cla…
@@ -5,7 +5,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
- <title>Class: Simplabs::ReportsAsSparkline::ReportCache</title>
+ <title>Class: Saulabs::ReportsAsSparkline::ReportCache</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" medi…
@@ -50,13 +50,13 @@
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
- <td class="class-name-in-header">Simplabs::ReportsAsSparkline::Repor…
+ <td class="class-name-in-header">Saulabs::ReportsAsSparkline::Report…
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
- <a href="../../../files/lib/simplabs/reports_as_sparkline/repo…
- lib/simplabs/reports_as_sparkline/report_cache.rb
+ <a href="../../../files/lib/saulabs/reports_as_sparkline/repor…
+ lib/saulabs/reports_as_sparkline/report_cache.rb
</a>
<br />
</td>
@@ -154,13 +154,13 @@ To clear the cache for a report defined as
just do
</p>
<pre>
- Simplabs::ReportsAsSparkline::ReportCache.clear_for(User, :registrations)
+ Saulabs::ReportsAsSparkline::ReportCache.clear_for(User, :registrations)
</pre>
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000006-source');return false;">[Source]</a><…
<div class="method-source-code" id="M000006-source">
<pre>
- <span class="ruby-comment cmt"># File lib/simplabs/reports_as_sparkline/re…
+ <span class="ruby-comment cmt"># File lib/saulabs/reports_as_sparkline/rep…
26: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword k…
27: <span class="ruby-keyword kw">self</span>.<span class="ruby-identi…
28: <span class="ruby-identifier">:model_name</span> =<span class="…
diff --git a/doc/classes/Simplabs/ReportsAsSparkline/SparklineTagHelper.html b/…
@@ -5,7 +5,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
- <title>Module: Simplabs::ReportsAsSparkline::SparklineTagHelper</title>
+ <title>Module: Saulabs::ReportsAsSparkline::SparklineTagHelper</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" medi…
@@ -50,13 +50,13 @@
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Module</strong></td>
- <td class="class-name-in-header">Simplabs::ReportsAsSparkline::Spark…
+ <td class="class-name-in-header">Saulabs::ReportsAsSparkline::Sparkl…
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
- <a href="../../../files/lib/simplabs/reports_as_sparkline/spar…
- lib/simplabs/reports_as_sparkline/sparkline_tag_helper.rb
+ <a href="../../../files/lib/saulabs/reports_as_sparkline/spark…
+ lib/saulabs/reports_as_sparkline/sparkline_tag_helper.rb
</a>
<br />
</td>
@@ -153,7 +153,7 @@ href="SparklineTagHelper.html#M000001">sparkline_tag</a>(Us…
onclick="toggleCode('M000001-source');return false;">[Source]</a><…
<div class="method-source-code" id="M000001-source">
<pre>
- <span class="ruby-comment cmt"># File lib/simplabs/reports_as_sparkline/sp…
+ <span class="ruby-comment cmt"># File lib/saulabs/reports_as_sparkline/spa…
23: <span class="ruby-keyword kw">def</span> <span class="ruby-identifie…
24: <span class="ruby-identifier">options</span>.<span class="ruby-ide…
25: <span class="ruby-identifier">data</span> = <span class="ruby-iden…
diff --git a/doc/files/README_rdoc.html b/doc/files/README_rdoc.html
@@ -182,11 +182,11 @@ the <tt>:limit</tt> reporting periods until this date.
Unless you specify parameters that make it impossible to cache report
results, all results will be cached. You can access the cache via the
<tt><a
-href="../classes/Simplabs/ReportsAsSparkline/ReportCache.html">Simplabs::Repor…
+href="../classes/Saulabs/ReportsAsSparkline/ReportCache.html">Saulabs::Reports…
class. <b>Beware that when you modify data in the cache, report results may
be incorrect or execurting reports may even fail completely!</b> To clear
the cache for a specific report, use the
-<tt>Simplabs::ReportsAsSparkline::ReportCache.clear_for</tt> method.
+<tt>Saulabs::ReportsAsSparkline::ReportCache.clear_for</tt> method.
</p>
<p>
<b>Example</b>
@@ -203,7 +203,7 @@ For a report defined as
you can clear the cache with
</p>
<pre>
- Simplabs::ReportsAsSparkline::ReportCache.clear_for(User, :registrations)
+ Saulabs::ReportsAsSparkline::ReportCache.clear_for(User, :registrations)
</pre>
<h3>In your views</h3>
<p>
@@ -270,7 +270,7 @@ If you are on Rails &lt; 2.1, do this from your RAILS_ROOT
<p>
To achieve best performance, you should add indices to your tables on the
date columns that are used for grouping the records (see
-Simplabs::ReportsAsSparkline::ClassMethods.reports_as_sparkline):
+Saulabs::ReportsAsSparkline::ClassMethods.reports_as_sparkline):
</p>
<pre>
add_index :[table], :[date_column]
@@ -323,7 +323,7 @@ href="http://github.com/myronmarston">github.com/myronmarst…
<h2>Author</h2>
<p>
© 2008-2009 Marco Otte-Witte (<a
-href="http://simplabs.com">simplabs.com</a>), Martin Kavalar, released
+href="http://saulabs.com">saulabs.com</a>), Martin Kavalar, released
under the MIT license
</p>
diff --git a/doc/files/lib/simplabs/reports_as_sparkline/cumulated_report_rb.ht…
@@ -51,7 +51,7 @@
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Path:</strong></td>
- <td>lib/simplabs/reports_as_sparkline/cumulated_report.rb
+ <td>lib/saulabs/reports_as_sparkline/cumulated_report.rb
</td>
</tr>
<tr class="top-aligned-row">
diff --git a/doc/files/lib/simplabs/reports_as_sparkline/grouping_rb.html b/doc…
@@ -51,7 +51,7 @@
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Path:</strong></td>
- <td>lib/simplabs/reports_as_sparkline/grouping.rb
+ <td>lib/saulabs/reports_as_sparkline/grouping.rb
</td>
</tr>
<tr class="top-aligned-row">
diff --git a/doc/files/lib/simplabs/reports_as_sparkline/report_cache_rb.html b…
@@ -51,7 +51,7 @@
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Path:</strong></td>
- <td>lib/simplabs/reports_as_sparkline/report_cache.rb
+ <td>lib/saulabs/reports_as_sparkline/report_cache.rb
</td>
</tr>
<tr class="top-aligned-row">
diff --git a/doc/files/lib/simplabs/reports_as_sparkline/report_rb.html b/doc/f…
@@ -51,7 +51,7 @@
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Path:</strong></td>
- <td>lib/simplabs/reports_as_sparkline/report.rb
+ <td>lib/saulabs/reports_as_sparkline/report.rb
</td>
</tr>
<tr class="top-aligned-row">
diff --git a/doc/files/lib/simplabs/reports_as_sparkline/reporting_period_rb.ht…
@@ -51,7 +51,7 @@
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Path:</strong></td>
- <td>lib/simplabs/reports_as_sparkline/reporting_period.rb
+ <td>lib/saulabs/reports_as_sparkline/reporting_period.rb
</td>
</tr>
<tr class="top-aligned-row">
diff --git a/doc/files/lib/simplabs/reports_as_sparkline/sparkline_tag_helper_r…
@@ -51,7 +51,7 @@
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Path:</strong></td>
- <td>lib/simplabs/reports_as_sparkline/sparkline_tag_helper.rb
+ <td>lib/saulabs/reports_as_sparkline/sparkline_tag_helper.rb
</td>
</tr>
<tr class="top-aligned-row">
diff --git a/doc/files/lib/simplabs/reports_as_sparkline_rb.html b/doc/files/li…
@@ -51,7 +51,7 @@
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Path:</strong></td>
- <td>lib/simplabs/reports_as_sparkline.rb
+ <td>lib/saulabs/reports_as_sparkline.rb
</td>
</tr>
<tr class="top-aligned-row">
diff --git a/doc/fr_class_index.html b/doc/fr_class_index.html
@@ -20,11 +20,11 @@
<div id="index">
<h1 class="section-bar">Classes</h1>
<div id="index-entries">
- <a href="classes/Simplabs/ReportsAsSparkline/ClassMethods.html">Simplabs::…
- <a href="classes/Simplabs/ReportsAsSparkline/CumulatedReport.html">Simplab…
- <a href="classes/Simplabs/ReportsAsSparkline/Report.html">Simplabs::Report…
- <a href="classes/Simplabs/ReportsAsSparkline/ReportCache.html">Simplabs::R…
- <a href="classes/Simplabs/ReportsAsSparkline/SparklineTagHelper.html">Simp…
+ <a href="classes/Saulabs/ReportsAsSparkline/ClassMethods.html">Saulabs::Re…
+ <a href="classes/Saulabs/ReportsAsSparkline/CumulatedReport.html">Saulabs:…
+ <a href="classes/Saulabs/ReportsAsSparkline/Report.html">Saulabs::ReportsA…
+ <a href="classes/Saulabs/ReportsAsSparkline/ReportCache.html">Saulabs::Rep…
+ <a href="classes/Saulabs/ReportsAsSparkline/SparklineTagHelper.html">Saula…
</div>
</div>
</body>
diff --git a/doc/fr_file_index.html b/doc/fr_file_index.html
@@ -21,13 +21,13 @@
<h1 class="section-bar">Files</h1>
<div id="index-entries">
<a href="files/README_rdoc.html">README.rdoc</a><br />
- <a href="files/lib/simplabs/reports_as_sparkline_rb.html">lib/simplabs/rep…
- <a href="files/lib/simplabs/reports_as_sparkline/cumulated_report_rb.html"…
- <a href="files/lib/simplabs/reports_as_sparkline/grouping_rb.html">lib/sim…
- <a href="files/lib/simplabs/reports_as_sparkline/report_rb.html">lib/simpl…
- <a href="files/lib/simplabs/reports_as_sparkline/report_cache_rb.html">lib…
- <a href="files/lib/simplabs/reports_as_sparkline/reporting_period_rb.html"…
- <a href="files/lib/simplabs/reports_as_sparkline/sparkline_tag_helper_rb.h…
+ <a href="files/lib/saulabs/reports_as_sparkline_rb.html">lib/saulabs/repor…
+ <a href="files/lib/saulabs/reports_as_sparkline/cumulated_report_rb.html">…
+ <a href="files/lib/saulabs/reports_as_sparkline/grouping_rb.html">lib/saul…
+ <a href="files/lib/saulabs/reports_as_sparkline/report_rb.html">lib/saulab…
+ <a href="files/lib/saulabs/reports_as_sparkline/report_cache_rb.html">lib/…
+ <a href="files/lib/saulabs/reports_as_sparkline/reporting_period_rb.html">…
+ <a href="files/lib/saulabs/reports_as_sparkline/sparkline_tag_helper_rb.ht…
</div>
</div>
</body>
diff --git a/doc/fr_method_index.html b/doc/fr_method_index.html
@@ -20,14 +20,14 @@
<div id="index">
<h1 class="section-bar">Methods</h1>
<div id="index-entries">
- <a href="classes/Simplabs/ReportsAsSparkline/ReportCache.html#M000006">cle…
- <a href="classes/Simplabs/ReportsAsSparkline/CumulatedReport.html#M000004"…
- <a href="classes/Simplabs/ReportsAsSparkline/CumulatedReport.html#M000005"…
- <a href="classes/Simplabs/ReportsAsSparkline/Report.html#M000007">new (Sim…
- <a href="classes/Simplabs/ReportsAsSparkline/ClassMethods.html#M000002">re…
- <a href="classes/Simplabs/ReportsAsSparkline/CumulatedReport.html#M000003"…
- <a href="classes/Simplabs/ReportsAsSparkline/Report.html#M000008">run (Sim…
- <a href="classes/Simplabs/ReportsAsSparkline/SparklineTagHelper.html#M0000…
+ <a href="classes/Saulabs/ReportsAsSparkline/ReportCache.html#M000006">clea…
+ <a href="classes/Saulabs/ReportsAsSparkline/CumulatedReport.html#M000004">…
+ <a href="classes/Saulabs/ReportsAsSparkline/CumulatedReport.html#M000005">…
+ <a href="classes/Saulabs/ReportsAsSparkline/Report.html#M000007">new (Saul…
+ <a href="classes/Saulabs/ReportsAsSparkline/ClassMethods.html#M000002">rep…
+ <a href="classes/Saulabs/ReportsAsSparkline/CumulatedReport.html#M000003">…
+ <a href="classes/Saulabs/ReportsAsSparkline/Report.html#M000008">run (Saul…
+ <a href="classes/Saulabs/ReportsAsSparkline/SparklineTagHelper.html#M00000…
</div>
</div>
</body>
diff --git a/init.rb b/init.rb
@@ -1,9 +1,9 @@
-require 'simplabs/reports_as_sparkline'
+require 'saulabs/reports_as_sparkline'
ActiveRecord::Base.class_eval do
- include Simplabs::ReportsAsSparkline
+ include Saulabs::ReportsAsSparkline
end
ActionView::Base.class_eval do
- include Simplabs::ReportsAsSparkline::SparklineTagHelper
+ include Saulabs::ReportsAsSparkline::SparklineTagHelper
end
diff --git a/lib/saulabs/reports_as_sparkline.rb b/lib/saulabs/reports_as_spark…
@@ -0,0 +1,54 @@
+module Saulabs #:nodoc:
+
+ module ReportsAsSparkline
+
+ def self.included(base) #:nodoc:
+ base.extend ClassMethods
+ end
+
+ module ClassMethods
+
+ # Generates a report on a model. That report can then be executed via th…
+ #
+ # ==== Parameters
+ #
+ # * <tt>name</tt> - The name of the report, defines the name of the gene…
+ #
+ # ==== Options
+ #
+ # * <tt>:date_column</tt> - The name of the date column over that the re…
+ # * <tt>:value_column</tt> - The name of the column that holds the value…
+ # * <tt>:aggregation</tt> - The aggregation to use (one of <tt>:count</t…
+ # * <tt>:grouping</tt> - The period records are grouped on (<tt>:hour</t…
+ # * <tt>:limit</tt> - The number of reporting periods to get (see <tt>:g…
+ # * <tt>:conditions</tt> - Conditions like in <tt>ActiveRecord::Base#fin…
+ # * <tt>:live_data</tt> - Specifies whether data for the current reporti…
+ # * <tt>:end_date</tt> - When specified, the report will only include da…
+ #
+ # ==== Examples
+ #
+ # class User < ActiveRecord::Base
+ # reports_as_sparkline :registrations, :aggregation => :count
+ # reports_as_sparkline :activations, :aggregation => :count, :date_…
+ # reports_as_sparkline :total_users, :cumulate => true
+ # reports_as_sparkline :rake, :aggregation => :sum, :value…
+ # end
+ def reports_as_sparkline(name, options = {})
+ (class << self; self; end).instance_eval do
+ define_method "#{name.to_s}_report".to_sym do |*args|
+ if options.delete(:cumulate)
+ report = Saulabs::ReportsAsSparkline::CumulatedReport.new(self, …
+ else
+ report = Saulabs::ReportsAsSparkline::Report.new(self, name, opt…
+ end
+ raise ArgumentError.new unless args.length == 0 || (args.length ==…
+ report.run(args.length == 0 ? {} : args[0])
+ end
+ end
+ end
+
+ end
+
+ end
+
+end
diff --git a/lib/saulabs/reports_as_sparkline/cumulated_report.rb b/lib/saulabs…
@@ -0,0 +1,45 @@
+module Saulabs #:nodoc:
+
+ module ReportsAsSparkline #:nodoc:
+
+ # A special report class that cumulates all data (see Saulabs::ReportsAsSp…
+ #
+ # ==== Examples
+ #
+ # When Saulabs::ReportsAsSparkline::Report returns
+ #
+ # [[<DateTime today>, 1], [<DateTime yesterday>, 2], etc.]
+ #
+ # Saulabs::ReportsAsSparkline::CumulatedReport returns
+ #
+ # [[<DateTime today>, 3], [<DateTime yesterday>, 2], etc.]
+ class CumulatedReport < Report
+
+ # Runs the report (see Saulabs::ReportsAsSparkline::Report#run)
+ def run(options = {})
+ cumulate(super, options_for_run(options))
+ end
+
+ protected
+
+ def cumulate(data, options)
+ first_reporting_period = ReportingPeriod.first(options[:grouping], o…
+ acc = initial_cumulative_value(first_reporting_period.date_time, opt…
+ result = []
+ data.each do |element|
+ acc += element[1].to_f
+ result << [element[0], acc]
+ end
+ result
+ end
+
+ def initial_cumulative_value(date, options)
+ conditions = setup_conditions(nil, date, options[:conditions])
+ @klass.send(@aggregation, @value_column, :conditions => conditions)
+ end
+
+ end
+
+ end
+
+end
diff --git a/lib/saulabs/reports_as_sparkline/grouping.rb b/lib/saulabs/reports…
@@ -0,0 +1,115 @@
+module Saulabs #:nodoc:
+
+ module ReportsAsSparkline #:nodoc:
+
+ class Grouping #:nodoc:
+
+ def initialize(identifier)
+ raise ArgumentError.new("Invalid grouping #{identifier}") unless [:hou…
+ @identifier = identifier
+ end
+
+ def identifier
+ @identifier
+ end
+
+ def date_parts_from_db_string(db_string)
+ case ActiveRecord::Base.connection.adapter_name
+ when /mysql/i
+ from_mysql_db_string(db_string)
+ when /sqlite/i
+ from_sqlite_db_string(db_string)
+ when /postgres/i
+ from_postgresql_db_string(db_string)
+ end
+ end
+
+ def to_sql(date_column) #:nodoc:
+ case ActiveRecord::Base.connection.adapter_name
+ when /mysql/i
+ mysql_format(date_column)
+ when /sqlite/i
+ sqlite_format(date_column)
+ when /postgres/i
+ postgresql_format(date_column)
+ end
+ end
+
+ private
+
+ def from_mysql_db_string(db_string)
+ if @identifier == :week
+ parts = [db_string[0..3], db_string[4..5]].map(&:to_i)
+ else
+ db_string.split('/').map(&:to_i)
+ end
+ end
+
+ def from_sqlite_db_string(db_string)
+ if @identifier == :week
+ parts = db_string.split('-').map(&:to_i)
+ date = Date.new(parts[0], parts[1], parts[2])
+ return [date.cwyear, date.cweek]
+ end
+ db_string.split('/').map(&:to_i)
+ end
+
+ def from_postgresql_db_string(db_string)
+ case @identifier
+ when :hour
+ return (db_string[0..9].split('-') + [db_string[11..12]]).map(&:…
+ when :day
+ return db_string[0..9].split('-').map(&:to_i)
+ when :week
+ parts = db_string[0..9].split('-').map(&:to_i)
+ date = Date.new(parts[0], parts[1], parts[2])
+ return [date.cwyear, date.cweek]
+ when :month
+ return db_string[0..6].split('-')[0..1].map(&:to_i)
+ end
+ end
+
+ def mysql_format(date_column)
+ case @identifier
+ when :hour
+ "DATE_FORMAT(#{date_column}, '%Y/%m/%d/%H')"
+ when :day
+ "DATE_FORMAT(#{date_column}, '%Y/%m/%d')"
+ when :week
+ "YEARWEEK(#{date_column}, 3)"
+ when :month
+ "DATE_FORMAT(#{date_column}, '%Y/%m')"
+ end
+ end
+
+ def sqlite_format(date_column)
+ case @identifier
+ when :hour
+ "strftime('%Y/%m/%d/%H', #{date_column})"
+ when :day
+ "strftime('%Y/%m/%d', #{date_column})"
+ when :week
+ "date(#{date_column}, 'weekday 0')"
+ when :month
+ "strftime('%Y/%m', #{date_column})"
+ end
+ end
+
+ def postgresql_format(date_column)
+ case @identifier
+ when :hour
+ "date_trunc('hour', #{date_column})"
+ when :day
+ "date_trunc('day', #{date_column})"
+ when :week
+ "date_trunc('week', #{date_column})"
+ when :month
+ "date_trunc('month', #{date_column})"
+ end
+ end
+
+ end
+
+ end
+
+end
diff --git a/lib/saulabs/reports_as_sparkline/report.rb b/lib/saulabs/reports_a…
@@ -0,0 +1,119 @@
+module Saulabs #:nodoc:
+
+ module ReportsAsSparkline #:nodoc:
+
+ # The Report class that does all the data retrieval and calculations
+ class Report
+
+ attr_reader :klass, :name, :date_column, :value_column, :aggregation, :o…
+
+ # ==== Parameters
+ # * <tt>klass</tt> - The model the report works on (This is the class yo…
+ # * <tt>name</tt> - The name of the report (as in Saulabs::ReportsAsSpar…
+ #
+ # ==== Options
+ #
+ # * <tt>:date_column</tt> - The name of the date column over that the re…
+ # * <tt>:value_column</tt> - The name of the column that holds the value…
+ # * <tt>:aggregation</tt> - The aggregation to use (one of <tt>:count</t…
+ # * <tt>:grouping</tt> - The period records are grouped on (<tt>:hour</t…
+ # * <tt>:limit</tt> - The number of reporting periods to get (see <tt>:g…
+ # * <tt>:conditions</tt> - Conditions like in <tt>ActiveRecord::Base#fin…
+ # * <tt>:live_data</tt> - Specifies whether data for the current reporti…
+ # * <tt>:end_date</tt> - When specified, the report will only include da…
+ def initialize(klass, name, options = {})
+ ensure_valid_options(options)
+ @klass = klass
+ @name = name
+ @date_column = (options[:date_column] || 'created_at').to_s
+ @aggregation = options[:aggregation] || :count
+ @value_column = (options[:value_column] || (@aggregation == :count ? '…
+ @options = {
+ :limit => options[:limit] || 100,
+ :conditions => options[:conditions] || [],
+ :grouping => Grouping.new(options[:grouping] || :day),
+ :live_data => options[:live_data] || false,
+ :end_date => options[:end_date] || false
+ }
+ @options.merge!(options)
+ @options.freeze
+ end
+
+ # Runs the report and returns an array of array of DateTimes and Floats
+ #
+ # ==== Options
+ # * <tt>:grouping</tt> - The period records are grouped on (<tt>:hour</t…
+ # * <tt>:limit</tt> - The number of reporting periods to get (see <tt>:g…
+ # * <tt>:conditions</tt> - Conditions like in <tt>ActiveRecord::Base#fin…
+ # * <tt>:live_data</tt> - Specifies whether data for the current reporti…
+ # * <tt>:end_date</tt> - When specified, the report will only include da…
+ def run(options = {})
+ options = options_for_run(options)
+ ReportCache.process(self, options) do |begin_at, end_at|
+ read_data(begin_at, end_at, options)
+ end
+ end
+
+ private
+
+ def options_for_run(options = {})
+ options = options.dup
+ ensure_valid_options(options, :run)
+ options.reverse_merge!(@options)
+ options[:grouping] = Grouping.new(options[:grouping]) unless options…
+ return options
+ end
+
+ def read_data(begin_at, end_at, options)
+ conditions = setup_conditions(begin_at, end_at, options[:conditions])
+ @klass.send(@aggregation,
+ @value_column,
+ :conditions => conditions,
+ :group => options[:grouping].to_sql(@date_column),
+ :order => "#{options[:grouping].to_sql(@date_column)} ASC",
+ :limit => options[:limit]
+ )
+ end
+
+ def setup_conditions(begin_at, end_at, custom_conditions = [])
+ conditions = [@klass.send(:sanitize_sql_for_conditions, custom_condi…
+ conditions[0] += "#{(conditions[0].blank? ? '' : ' AND ')}#{ActiveRe…
+ conditions[0] += if begin_at && end_at
+ 'BETWEEN ? AND ?'
+ elsif begin_at
+ '>= ?'
+ elsif end_at
+ '<= ?'
+ else
+ raise ArgumentError.new('You must pass either begin_at, end_at or …
+ end
+ conditions << begin_at if begin_at
+ conditions << end_at if end_at
+ conditions
+ end
+
+ def ensure_valid_options(options, context = :initialize)
+ case context
+ when :initialize
+ options.each_key do |k|
+ raise ArgumentError.new("Invalid option #{k}!") unless [:limit…
+ end
+ raise ArgumentError.new("Invalid aggregation #{options[:aggregat…
+ raise ArgumentError.new('The name of the column holding the valu…
+ when :run
+ options.each_key do |k|
+ raise ArgumentError.new("Invalid option #{k}!") unless [:limit…
+ end
+ end
+ raise ArgumentError.new('Options :live_data and :end_date may not bo…
+ raise ArgumentError.new("Invalid grouping #{options[:grouping]}!") i…
+ raise ArgumentError.new("Invalid conditions: #{options[:conditions].…
+ raise ArgumentError.new("Invalid end date: #{options[:end_date].insp…
+ raise ArgumentError.new('End date may not be in the future!') if opt…
+ end
+
+ end
+
+ end
+
+end
diff --git a/lib/saulabs/reports_as_sparkline/report_cache.rb b/lib/saulabs/rep…
@@ -0,0 +1,139 @@
+module Saulabs #:nodoc:
+
+ module ReportsAsSparkline #:nodoc:
+
+ # The ReportCache class is a regular +ActiveRecord+ model and represents c…
+ # ReportCache instances are identified by the combination of +model_name+,…
+ class ReportCache < ActiveRecord::Base
+
+ set_table_name :reports_as_sparkline_cache
+
+ self.skip_time_zone_conversion_for_attributes = [:reporting_period]
+
+ # Clears the cache for the specified +klass+ and +report+
+ #
+ # === Parameters
+ # * <tt>klass</tt> - The model the report to clear the cache for works on
+ # * <tt>report</tt> - The name of the report to clear the cache for
+ #
+ # === Example
+ # To clear the cache for a report defined as
+ # class User < ActiveRecord::Base
+ # reports_as_sparkline :registrations
+ # end
+ # just do
+ # Saulabs::ReportsAsSparkline::ReportCache.clear_for(User, :registratio…
+ def self.clear_for(klass, report)
+ self.delete_all(:conditions => {
+ :model_name => klass.name,
+ :report_name => report.to_s
+ })
+ end
+
+ def self.process(report, options, &block) #:nodoc:
+ raise ArgumentError.new('A block must be given') unless block_given?
+ self.transaction do
+ cached_data = read_cached_data(report, options)
+ new_data = read_new_data(cached_data, options, &block)
+ prepare_result(new_data, cached_data, report, options)
+ end
+ end
+
+ private
+
+ def self.prepare_result(new_data, cached_data, report, options)
+ new_data = new_data.map { |data| [ReportingPeriod.from_db_string(opt…
+ cached_data.map! { |cached| [ReportingPeriod.new(options[:grouping],…
+ current_reporting_period = ReportingPeriod.current(options[:grouping…
+ reporting_period = get_first_reporting_period(options)
+ result = []
+ while reporting_period < (options[:end_date] ? ReportingPeriod.new(o…
+ if cached = cached_data.find { |cached| reporting_period == cached…
+ result << [cached[0].date_time, cached[1]]
+ else
+ new_cached = build_cached_data(report, options[:grouping], optio…
+ new_cached.save!
+ result << [reporting_period.date_time, new_cached.value]
+ end
+ reporting_period = reporting_period.next
+ end
+ if options[:live_data]
+ result << [current_reporting_period.date_time, find_value(new_data…
+ end
+ result
+ end
+
+ def self.find_value(data, reporting_period)
+ data = data.detect { |d| d[0] == reporting_period }
+ data ? data[1] : 0.0
+ end
+
+ def self.build_cached_data(report, grouping, condition, reporting_peri…
+ self.new(
+ :model_name => report.klass.to_s,
+ :report_name => report.name.to_s,
+ :grouping => grouping.identifier.to_s,
+ :aggregation => report.aggregation.to_s,
+ :condition => condition.to_s,
+ :reporting_period => reporting_period.date_time,
+ :value => value
+ )
+ end
+
+ def self.read_cached_data(report, options)
+ conditions = [
+ 'model_name = ? AND report_name = ? AND grouping = ? AND aggregati…
+ report.klass.to_s,
+ report.name.to_s,
+ options[:grouping].identifier.to_s,
+ report.aggregation.to_s,
+ options[:conditions].to_s
+ ]
+ first_reporting_period = get_first_reporting_period(options)
+ last_reporting_period = get_last_reporting_period(options)
+ if last_reporting_period
+ conditions.first << ' AND reporting_period BETWEEN ? AND ?'
+ conditions << first_reporting_period.date_time
+ conditions << last_reporting_period.date_time
+ else
+ conditions.first << ' AND reporting_period >= ?'
+ conditions << first_reporting_period.date_time
+ end
+ self.all(
+ :conditions => conditions,
+ :limit => options[:limit],
+ :order => 'reporting_period ASC'
+ )
+ end
+
+ def self.read_new_data(cached_data, options, &block)
+ if !options[:live_data] && cached_data.length == options[:limit]
+ []
+ else
+ first_reporting_period_to_read = if cached_data.length < options[:…
+ get_first_reporting_period(options)
+ else
+ ReportingPeriod.new(options[:grouping], cached_data.last.reporti…
+ end
+ last_reporting_period_to_read = options[:end_date] ? ReportingPeri…
+ yield(first_reporting_period_to_read.date_time, last_reporting_per…
+ end
+ end
+
+ def self.get_first_reporting_period(options)
+ if options[:end_date]
+ ReportingPeriod.first(options[:grouping], options[:limit] - 1, opt…
+ else
+ ReportingPeriod.first(options[:grouping], options[:limit])
+ end
+ end
+
+ def self.get_last_reporting_period(options)
+ return ReportingPeriod.new(options[:grouping], options[:end_date]) i…
+ end
+
+ end
+
+ end
+
+end
diff --git a/lib/saulabs/reports_as_sparkline/reporting_period.rb b/lib/saulabs…
@@ -0,0 +1,103 @@
+module Saulabs #:nodoc:
+
+ module ReportsAsSparkline #:nodoc:
+
+ class ReportingPeriod #:nodoc:
+
+ attr_reader :date_time, :grouping
+
+ def initialize(grouping, date_time = nil)
+ @grouping = grouping
+ @date_time = parse_date_time(date_time || DateTime.now)
+ end
+
+ def offset(offset)
+ self.class.new(@grouping, @date_time + offset.send(@grouping.identifie…
+ end
+
+ def self.first(grouping, limit, end_date = nil)
+ self.new(grouping, end_date).offset(-limit)
+ end
+
+ def self.current(grouping)
+ self.new(grouping, Time.now)
+ end
+
+ def self.from_db_string(grouping, db_string)
+ parts = grouping.date_parts_from_db_string(db_string)
+ result = case grouping.identifier
+ when :hour
+ self.new(grouping, DateTime.new(parts[0], parts[1], parts[2], part…
+ when :day
+ self.new(grouping, Date.new(parts[0], parts[1], parts[2]))
+ when :week
+ self.new(grouping, Date.commercial(parts[0], parts[1], 1))
+ when :month
+ self.new(grouping, Date.new(parts[0], parts[1], 1))
+ end
+ result
+ end
+
+ def next
+ self.offset(1)
+ end
+
+ def previous
+ self.offset(-1)
+ end
+
+ def ==(other)
+ if other.is_a?(Saulabs::ReportsAsSparkline::ReportingPeriod)
+ @date_time.to_s == other.date_time.to_s && @grouping.identifier.to_s…
+ elsif other.is_a?(Time) || other.is_a?(DateTime)
+ @date_time == parse_date_time(other)
+ else
+ raise ArgumentError.new("Can only compare instances of #{self.class.…
+ end
+ end
+
+ def <(other)
+ if other.is_a?(Saulabs::ReportsAsSparkline::ReportingPeriod)
+ return @date_time < other.date_time
+ elsif other.is_a?(Time) || other.is_a?(DateTime)
+ @date_time < parse_date_time(other)
+ else
+ raise ArgumentError.new("Can only compare instances of #{self.class.…
+ end
+ end
+
+ def last_date_time
+ case @grouping.identifier
+ when :hour
+ DateTime.new(@date_time.year, @date_time.month, @date_time.day, @d…
+ when :day
+ DateTime.new(@date_time.year, @date_time.month, @date_time.day, 23…
+ when :week
+ date_time = (@date_time - @date_time.wday.days) + 7.days
+ Date.new(date_time.year, date_time.month, date_time.day)
+ when :month
+ Date.new(@date_time.year, @date_time.month, (Date.new(@date_time.y…
+ end
+ end
+
+ private
+
+ def parse_date_time(date_time)
+ case @grouping.identifier
+ when :hour
+ DateTime.new(date_time.year, date_time.month, date_time.day, dat…
+ when :day
+ date_time.to_date
+ when :week
+ date_time = (date_time - date_time.wday.days) + 1.day
+ Date.new(date_time.year, date_time.month, date_time.day)
+ when :month
+ Date.new(date_time.year, date_time.month, 1)
+ end
+ end
+
+ end
+
+ end
+
+end
diff --git a/lib/saulabs/reports_as_sparkline/sparkline_tag_helper.rb b/lib/sau…
@@ -0,0 +1,47 @@
+module Saulabs #:nodoc:
+
+ module ReportsAsSparkline #:nodoc:
+
+ module SparklineTagHelper
+
+ # Renders a sparkline with the given data.
+ #
+ # ==== Parameters
+ #
+ # * <tt>data</tt> - The data to render the sparkline for, is retrieved f…
+ #
+ # ==== Options
+ #
+ # * <tt>width</tt> - The width of the generated image
+ # * <tt>height</tt> - The height of the generated image
+ # * <tt>line_color</tt> - The line color of the sparkline (hex code)
+ # * <tt>fill_color</tt> - The color to fill the area below the sparkline…
+ # * <tt>labels</tt> - The axes to render lables for (Array of <tt>:x</tt…
+ # * <tt>alt</tt> - The HTML img alt tag
+ # * <tt>title</tt> - The HTML img title tag
+ #
+ # ==== Example
+ # <tt><%= sparkline_tag(User.registrations_report, :width => 200, :heigh…
+ def sparkline_tag(data, options = {})
+ options.reverse_merge!({ :width => 300, :height => 34, :line_color => …
+ data = data.collect { |d| d[1] }
+ labels = ""
+ unless options[:labels].empty?
+ chxr = {}
+ options[:labels].each_with_index do |l, i|
+ chxr[l] = "#{i}," + ([:x, :t].include?(l) ? "0,#{data.length}" : "…
+ end
+ labels = "&chxt=#{options[:labels].map(&:to_s).join(',')}&chxr=#{opt…
+ end
+ image_tag(
+ "http://chart.apis.google.com/chart?cht=ls&chs=#{options[:width]}x#{…
+ :alt => options[:alt],
+ :title => options[:title]
+ )
+ end
+
+ end
+
+ end
+
+end
diff --git a/lib/simplabs/reports_as_sparkline.rb b/lib/simplabs/reports_as_spa…
@@ -1,54 +0,0 @@
-module Simplabs #:nodoc:
-
- module ReportsAsSparkline
-
- def self.included(base) #:nodoc:
- base.extend ClassMethods
- end
-
- module ClassMethods
-
- # Generates a report on a model. That report can then be executed via th…
- #
- # ==== Parameters
- #
- # * <tt>name</tt> - The name of the report, defines the name of the gene…
- #
- # ==== Options
- #
- # * <tt>:date_column</tt> - The name of the date column over that the re…
- # * <tt>:value_column</tt> - The name of the column that holds the value…
- # * <tt>:aggregation</tt> - The aggregation to use (one of <tt>:count</t…
- # * <tt>:grouping</tt> - The period records are grouped on (<tt>:hour</t…
- # * <tt>:limit</tt> - The number of reporting periods to get (see <tt>:g…
- # * <tt>:conditions</tt> - Conditions like in <tt>ActiveRecord::Base#fin…
- # * <tt>:live_data</tt> - Specifies whether data for the current reporti…
- # * <tt>:end_date</tt> - When specified, the report will only include da…
- #
- # ==== Examples
- #
- # class User < ActiveRecord::Base
- # reports_as_sparkline :registrations, :aggregation => :count
- # reports_as_sparkline :activations, :aggregation => :count, :date_…
- # reports_as_sparkline :total_users, :cumulate => true
- # reports_as_sparkline :rake, :aggregation => :sum, :value…
- # end
- def reports_as_sparkline(name, options = {})
- (class << self; self; end).instance_eval do
- define_method "#{name.to_s}_report".to_sym do |*args|
- if options.delete(:cumulate)
- report = Simplabs::ReportsAsSparkline::CumulatedReport.new(self,…
- else
- report = Simplabs::ReportsAsSparkline::Report.new(self, name, op…
- end
- raise ArgumentError.new unless args.length == 0 || (args.length ==…
- report.run(args.length == 0 ? {} : args[0])
- end
- end
- end
-
- end
-
- end
-
-end
diff --git a/lib/simplabs/reports_as_sparkline/cumulated_report.rb b/lib/simpla…
@@ -1,45 +0,0 @@
-module Simplabs #:nodoc:
-
- module ReportsAsSparkline #:nodoc:
-
- # A special report class that cumulates all data (see Simplabs::ReportsAsS…
- #
- # ==== Examples
- #
- # When Simplabs::ReportsAsSparkline::Report returns
- #
- # [[<DateTime today>, 1], [<DateTime yesterday>, 2], etc.]
- #
- # Simplabs::ReportsAsSparkline::CumulatedReport returns
- #
- # [[<DateTime today>, 3], [<DateTime yesterday>, 2], etc.]
- class CumulatedReport < Report
-
- # Runs the report (see Simplabs::ReportsAsSparkline::Report#run)
- def run(options = {})
- cumulate(super, options_for_run(options))
- end
-
- protected
-
- def cumulate(data, options)
- first_reporting_period = ReportingPeriod.first(options[:grouping], o…
- acc = initial_cumulative_value(first_reporting_period.date_time, opt…
- result = []
- data.each do |element|
- acc += element[1].to_f
- result << [element[0], acc]
- end
- result
- end
-
- def initial_cumulative_value(date, options)
- conditions = setup_conditions(nil, date, options[:conditions])
- @klass.send(@aggregation, @value_column, :conditions => conditions)
- end
-
- end
-
- end
-
-end
diff --git a/lib/simplabs/reports_as_sparkline/grouping.rb b/lib/simplabs/repor…
@@ -1,115 +0,0 @@
-module Simplabs #:nodoc:
-
- module ReportsAsSparkline #:nodoc:
-
- class Grouping #:nodoc:
-
- def initialize(identifier)
- raise ArgumentError.new("Invalid grouping #{identifier}") unless [:hou…
- @identifier = identifier
- end
-
- def identifier
- @identifier
- end
-
- def date_parts_from_db_string(db_string)
- case ActiveRecord::Base.connection.adapter_name
- when /mysql/i
- from_mysql_db_string(db_string)
- when /sqlite/i
- from_sqlite_db_string(db_string)
- when /postgres/i
- from_postgresql_db_string(db_string)
- end
- end
-
- def to_sql(date_column) #:nodoc:
- case ActiveRecord::Base.connection.adapter_name
- when /mysql/i
- mysql_format(date_column)
- when /sqlite/i
- sqlite_format(date_column)
- when /postgres/i
- postgresql_format(date_column)
- end
- end
-
- private
-
- def from_mysql_db_string(db_string)
- if @identifier == :week
- parts = [db_string[0..3], db_string[4..5]].map(&:to_i)
- else
- db_string.split('/').map(&:to_i)
- end
- end
-
- def from_sqlite_db_string(db_string)
- if @identifier == :week
- parts = db_string.split('-').map(&:to_i)
- date = Date.new(parts[0], parts[1], parts[2])
- return [date.cwyear, date.cweek]
- end
- db_string.split('/').map(&:to_i)
- end
-
- def from_postgresql_db_string(db_string)
- case @identifier
- when :hour
- return (db_string[0..9].split('-') + [db_string[11..12]]).map(&:…
- when :day
- return db_string[0..9].split('-').map(&:to_i)
- when :week
- parts = db_string[0..9].split('-').map(&:to_i)
- date = Date.new(parts[0], parts[1], parts[2])
- return [date.cwyear, date.cweek]
- when :month
- return db_string[0..6].split('-')[0..1].map(&:to_i)
- end
- end
-
- def mysql_format(date_column)
- case @identifier
- when :hour
- "DATE_FORMAT(#{date_column}, '%Y/%m/%d/%H')"
- when :day
- "DATE_FORMAT(#{date_column}, '%Y/%m/%d')"
- when :week
- "YEARWEEK(#{date_column}, 3)"
- when :month
- "DATE_FORMAT(#{date_column}, '%Y/%m')"
- end
- end
-
- def sqlite_format(date_column)
- case @identifier
- when :hour
- "strftime('%Y/%m/%d/%H', #{date_column})"
- when :day
- "strftime('%Y/%m/%d', #{date_column})"
- when :week
- "date(#{date_column}, 'weekday 0')"
- when :month
- "strftime('%Y/%m', #{date_column})"
- end
- end
-
- def postgresql_format(date_column)
- case @identifier
- when :hour
- "date_trunc('hour', #{date_column})"
- when :day
- "date_trunc('day', #{date_column})"
- when :week
- "date_trunc('week', #{date_column})"
- when :month
- "date_trunc('month', #{date_column})"
- end
- end
-
- end
-
- end
-
-end
diff --git a/lib/simplabs/reports_as_sparkline/report.rb b/lib/simplabs/reports…
@@ -1,119 +0,0 @@
-module Simplabs #:nodoc:
-
- module ReportsAsSparkline #:nodoc:
-
- # The Report class that does all the data retrieval and calculations
- class Report
-
- attr_reader :klass, :name, :date_column, :value_column, :aggregation, :o…
-
- # ==== Parameters
- # * <tt>klass</tt> - The model the report works on (This is the class yo…
- # * <tt>name</tt> - The name of the report (as in Simplabs::ReportsAsSpa…
- #
- # ==== Options
- #
- # * <tt>:date_column</tt> - The name of the date column over that the re…
- # * <tt>:value_column</tt> - The name of the column that holds the value…
- # * <tt>:aggregation</tt> - The aggregation to use (one of <tt>:count</t…
- # * <tt>:grouping</tt> - The period records are grouped on (<tt>:hour</t…
- # * <tt>:limit</tt> - The number of reporting periods to get (see <tt>:g…
- # * <tt>:conditions</tt> - Conditions like in <tt>ActiveRecord::Base#fin…
- # * <tt>:live_data</tt> - Specifies whether data for the current reporti…
- # * <tt>:end_date</tt> - When specified, the report will only include da…
- def initialize(klass, name, options = {})
- ensure_valid_options(options)
- @klass = klass
- @name = name
- @date_column = (options[:date_column] || 'created_at').to_s
- @aggregation = options[:aggregation] || :count
- @value_column = (options[:value_column] || (@aggregation == :count ? '…
- @options = {
- :limit => options[:limit] || 100,
- :conditions => options[:conditions] || [],
- :grouping => Grouping.new(options[:grouping] || :day),
- :live_data => options[:live_data] || false,
- :end_date => options[:end_date] || false
- }
- @options.merge!(options)
- @options.freeze
- end
-
- # Runs the report and returns an array of array of DateTimes and Floats
- #
- # ==== Options
- # * <tt>:grouping</tt> - The period records are grouped on (<tt>:hour</t…
- # * <tt>:limit</tt> - The number of reporting periods to get (see <tt>:g…
- # * <tt>:conditions</tt> - Conditions like in <tt>ActiveRecord::Base#fin…
- # * <tt>:live_data</tt> - Specifies whether data for the current reporti…
- # * <tt>:end_date</tt> - When specified, the report will only include da…
- def run(options = {})
- options = options_for_run(options)
- ReportCache.process(self, options) do |begin_at, end_at|
- read_data(begin_at, end_at, options)
- end
- end
-
- private
-
- def options_for_run(options = {})
- options = options.dup
- ensure_valid_options(options, :run)
- options.reverse_merge!(@options)
- options[:grouping] = Grouping.new(options[:grouping]) unless options…
- return options
- end
-
- def read_data(begin_at, end_at, options)
- conditions = setup_conditions(begin_at, end_at, options[:conditions])
- @klass.send(@aggregation,
- @value_column,
- :conditions => conditions,
- :group => options[:grouping].to_sql(@date_column),
- :order => "#{options[:grouping].to_sql(@date_column)} ASC",
- :limit => options[:limit]
- )
- end
-
- def setup_conditions(begin_at, end_at, custom_conditions = [])
- conditions = [@klass.send(:sanitize_sql_for_conditions, custom_condi…
- conditions[0] += "#{(conditions[0].blank? ? '' : ' AND ')}#{ActiveRe…
- conditions[0] += if begin_at && end_at
- 'BETWEEN ? AND ?'
- elsif begin_at
- '>= ?'
- elsif end_at
- '<= ?'
- else
- raise ArgumentError.new('You must pass either begin_at, end_at or …
- end
- conditions << begin_at if begin_at
- conditions << end_at if end_at
- conditions
- end
-
- def ensure_valid_options(options, context = :initialize)
- case context
- when :initialize
- options.each_key do |k|
- raise ArgumentError.new("Invalid option #{k}!") unless [:limit…
- end
- raise ArgumentError.new("Invalid aggregation #{options[:aggregat…
- raise ArgumentError.new('The name of the column holding the valu…
- when :run
- options.each_key do |k|
- raise ArgumentError.new("Invalid option #{k}!") unless [:limit…
- end
- end
- raise ArgumentError.new('Options :live_data and :end_date may not bo…
- raise ArgumentError.new("Invalid grouping #{options[:grouping]}!") i…
- raise ArgumentError.new("Invalid conditions: #{options[:conditions].…
- raise ArgumentError.new("Invalid end date: #{options[:end_date].insp…
- raise ArgumentError.new('End date may not be in the future!') if opt…
- end
-
- end
-
- end
-
-end
diff --git a/lib/simplabs/reports_as_sparkline/report_cache.rb b/lib/simplabs/r…
@@ -1,139 +0,0 @@
-module Simplabs #:nodoc:
-
- module ReportsAsSparkline #:nodoc:
-
- # The ReportCache class is a regular +ActiveRecord+ model and represents c…
- # ReportCache instances are identified by the combination of +model_name+,…
- class ReportCache < ActiveRecord::Base
-
- set_table_name :reports_as_sparkline_cache
-
- self.skip_time_zone_conversion_for_attributes = [:reporting_period]
-
- # Clears the cache for the specified +klass+ and +report+
- #
- # === Parameters
- # * <tt>klass</tt> - The model the report to clear the cache for works on
- # * <tt>report</tt> - The name of the report to clear the cache for
- #
- # === Example
- # To clear the cache for a report defined as
- # class User < ActiveRecord::Base
- # reports_as_sparkline :registrations
- # end
- # just do
- # Simplabs::ReportsAsSparkline::ReportCache.clear_for(User, :registrati…
- def self.clear_for(klass, report)
- self.delete_all(:conditions => {
- :model_name => klass.name,
- :report_name => report.to_s
- })
- end
-
- def self.process(report, options, &block) #:nodoc:
- raise ArgumentError.new('A block must be given') unless block_given?
- self.transaction do
- cached_data = read_cached_data(report, options)
- new_data = read_new_data(cached_data, options, &block)
- prepare_result(new_data, cached_data, report, options)
- end
- end
-
- private
-
- def self.prepare_result(new_data, cached_data, report, options)
- new_data = new_data.map { |data| [ReportingPeriod.from_db_string(opt…
- cached_data.map! { |cached| [ReportingPeriod.new(options[:grouping],…
- current_reporting_period = ReportingPeriod.current(options[:grouping…
- reporting_period = get_first_reporting_period(options)
- result = []
- while reporting_period < (options[:end_date] ? ReportingPeriod.new(o…
- if cached = cached_data.find { |cached| reporting_period == cached…
- result << [cached[0].date_time, cached[1]]
- else
- new_cached = build_cached_data(report, options[:grouping], optio…
- new_cached.save!
- result << [reporting_period.date_time, new_cached.value]
- end
- reporting_period = reporting_period.next
- end
- if options[:live_data]
- result << [current_reporting_period.date_time, find_value(new_data…
- end
- result
- end
-
- def self.find_value(data, reporting_period)
- data = data.detect { |d| d[0] == reporting_period }
- data ? data[1] : 0.0
- end
-
- def self.build_cached_data(report, grouping, condition, reporting_peri…
- self.new(
- :model_name => report.klass.to_s,
- :report_name => report.name.to_s,
- :grouping => grouping.identifier.to_s,
- :aggregation => report.aggregation.to_s,
- :condition => condition.to_s,
- :reporting_period => reporting_period.date_time,
- :value => value
- )
- end
-
- def self.read_cached_data(report, options)
- conditions = [
- 'model_name = ? AND report_name = ? AND grouping = ? AND aggregati…
- report.klass.to_s,
- report.name.to_s,
- options[:grouping].identifier.to_s,
- report.aggregation.to_s,
- options[:conditions].to_s
- ]
- first_reporting_period = get_first_reporting_period(options)
- last_reporting_period = get_last_reporting_period(options)
- if last_reporting_period
- conditions.first << ' AND reporting_period BETWEEN ? AND ?'
- conditions << first_reporting_period.date_time
- conditions << last_reporting_period.date_time
- else
- conditions.first << ' AND reporting_period >= ?'
- conditions << first_reporting_period.date_time
- end
- self.all(
- :conditions => conditions,
- :limit => options[:limit],
- :order => 'reporting_period ASC'
- )
- end
-
- def self.read_new_data(cached_data, options, &block)
- if !options[:live_data] && cached_data.length == options[:limit]
- []
- else
- first_reporting_period_to_read = if cached_data.length < options[:…
- get_first_reporting_period(options)
- else
- ReportingPeriod.new(options[:grouping], cached_data.last.reporti…
- end
- last_reporting_period_to_read = options[:end_date] ? ReportingPeri…
- yield(first_reporting_period_to_read.date_time, last_reporting_per…
- end
- end
-
- def self.get_first_reporting_period(options)
- if options[:end_date]
- ReportingPeriod.first(options[:grouping], options[:limit] - 1, opt…
- else
- ReportingPeriod.first(options[:grouping], options[:limit])
- end
- end
-
- def self.get_last_reporting_period(options)
- return ReportingPeriod.new(options[:grouping], options[:end_date]) i…
- end
-
- end
-
- end
-
-end
diff --git a/lib/simplabs/reports_as_sparkline/reporting_period.rb b/lib/simpla…
@@ -1,103 +0,0 @@
-module Simplabs #:nodoc:
-
- module ReportsAsSparkline #:nodoc:
-
- class ReportingPeriod #:nodoc:
-
- attr_reader :date_time, :grouping
-
- def initialize(grouping, date_time = nil)
- @grouping = grouping
- @date_time = parse_date_time(date_time || DateTime.now)
- end
-
- def offset(offset)
- self.class.new(@grouping, @date_time + offset.send(@grouping.identifie…
- end
-
- def self.first(grouping, limit, end_date = nil)
- self.new(grouping, end_date).offset(-limit)
- end
-
- def self.current(grouping)
- self.new(grouping, Time.now)
- end
-
- def self.from_db_string(grouping, db_string)
- parts = grouping.date_parts_from_db_string(db_string)
- result = case grouping.identifier
- when :hour
- self.new(grouping, DateTime.new(parts[0], parts[1], parts[2], part…
- when :day
- self.new(grouping, Date.new(parts[0], parts[1], parts[2]))
- when :week
- self.new(grouping, Date.commercial(parts[0], parts[1], 1))
- when :month
- self.new(grouping, Date.new(parts[0], parts[1], 1))
- end
- result
- end
-
- def next
- self.offset(1)
- end
-
- def previous
- self.offset(-1)
- end
-
- def ==(other)
- if other.is_a?(Simplabs::ReportsAsSparkline::ReportingPeriod)
- @date_time.to_s == other.date_time.to_s && @grouping.identifier.to_s…
- elsif other.is_a?(Time) || other.is_a?(DateTime)
- @date_time == parse_date_time(other)
- else
- raise ArgumentError.new("Can only compare instances of #{self.class.…
- end
- end
-
- def <(other)
- if other.is_a?(Simplabs::ReportsAsSparkline::ReportingPeriod)
- return @date_time < other.date_time
- elsif other.is_a?(Time) || other.is_a?(DateTime)
- @date_time < parse_date_time(other)
- else
- raise ArgumentError.new("Can only compare instances of #{self.class.…
- end
- end
-
- def last_date_time
- case @grouping.identifier
- when :hour
- DateTime.new(@date_time.year, @date_time.month, @date_time.day, @d…
- when :day
- DateTime.new(@date_time.year, @date_time.month, @date_time.day, 23…
- when :week
- date_time = (@date_time - @date_time.wday.days) + 7.days
- Date.new(date_time.year, date_time.month, date_time.day)
- when :month
- Date.new(@date_time.year, @date_time.month, (Date.new(@date_time.y…
- end
- end
-
- private
-
- def parse_date_time(date_time)
- case @grouping.identifier
- when :hour
- DateTime.new(date_time.year, date_time.month, date_time.day, dat…
- when :day
- date_time.to_date
- when :week
- date_time = (date_time - date_time.wday.days) + 1.day
- Date.new(date_time.year, date_time.month, date_time.day)
- when :month
- Date.new(date_time.year, date_time.month, 1)
- end
- end
-
- end
-
- end
-
-end
diff --git a/lib/simplabs/reports_as_sparkline/sparkline_tag_helper.rb b/lib/si…
@@ -1,47 +0,0 @@
-module Simplabs #:nodoc:
-
- module ReportsAsSparkline #:nodoc:
-
- module SparklineTagHelper
-
- # Renders a sparkline with the given data.
- #
- # ==== Parameters
- #
- # * <tt>data</tt> - The data to render the sparkline for, is retrieved f…
- #
- # ==== Options
- #
- # * <tt>width</tt> - The width of the generated image
- # * <tt>height</tt> - The height of the generated image
- # * <tt>line_color</tt> - The line color of the sparkline (hex code)
- # * <tt>fill_color</tt> - The color to fill the area below the sparkline…
- # * <tt>labels</tt> - The axes to render lables for (Array of <tt>:x</tt…
- # * <tt>alt</tt> - The HTML img alt tag
- # * <tt>title</tt> - The HTML img title tag
- #
- # ==== Example
- # <tt><%= sparkline_tag(User.registrations_report, :width => 200, :heigh…
- def sparkline_tag(data, options = {})
- options.reverse_merge!({ :width => 300, :height => 34, :line_color => …
- data = data.collect { |d| d[1] }
- labels = ""
- unless options[:labels].empty?
- chxr = {}
- options[:labels].each_with_index do |l, i|
- chxr[l] = "#{i}," + ([:x, :t].include?(l) ? "0,#{data.length}" : "…
- end
- labels = "&chxt=#{options[:labels].map(&:to_s).join(',')}&chxr=#{opt…
- end
- image_tag(
- "http://chart.apis.google.com/chart?cht=ls&chs=#{options[:width]}x#{…
- :alt => options[:alt],
- :title => options[:title]
- )
- end
-
- end
-
- end
-
-end
diff --git a/spec/classes/cumulated_report_spec.rb b/spec/classes/cumulated_rep…
@@ -1,9 +1,9 @@
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
-describe Simplabs::ReportsAsSparkline::CumulatedReport do
+describe Saulabs::ReportsAsSparkline::CumulatedReport do
before do
- @report = Simplabs::ReportsAsSparkline::CumulatedReport.new(User, :cumulat…
+ @report = Saulabs::ReportsAsSparkline::CumulatedReport.new(User, :cumulate…
end
describe '#run' do
@@ -15,13 +15,13 @@ describe Simplabs::ReportsAsSparkline::CumulatedReport do
end
it 'should return an array of the same length as the specified limit when …
- @report = Simplabs::ReportsAsSparkline::CumulatedReport.new(User, :cumul…
+ @report = Saulabs::ReportsAsSparkline::CumulatedReport.new(User, :cumula…
@report.run.length.should == 10
end
it 'should return an array of the same length as the specified limit + 1 w…
- @report = Simplabs::ReportsAsSparkline::CumulatedReport.new(User, :cumul…
+ @report = Saulabs::ReportsAsSparkline::CumulatedReport.new(User, :cumula…
@report.run.length.should == 11
end
@@ -45,8 +45,8 @@ describe Simplabs::ReportsAsSparkline::CumulatedReport do
describe 'the returned result' do
before do
- @grouping = Simplabs::ReportsAsSparkline::Grouping.new(groupin…
- @report = Simplabs::ReportsAsSparkline::CumulatedReport.new(Us…
+ @grouping = Saulabs::ReportsAsSparkline::Grouping.new(grouping)
+ @report = Saulabs::ReportsAsSparkline::CumulatedReport.new(Use…
:grouping => grouping,
:limit => 10,
:live_data => live_data
@@ -55,23 +55,23 @@ describe Simplabs::ReportsAsSparkline::CumulatedReport do
end
it "should be an array starting reporting period (Time.now - lim…
- @result.first[0].should == Simplabs::ReportsAsSparkline::Repor…
+ @result.first[0].should == Saulabs::ReportsAsSparkline::Report…
end
if live_data
it "should be data ending with the current reporting period" do
- @result.last[0].should == Simplabs::ReportsAsSparkline::Repo…
+ @result.last[0].should == Saulabs::ReportsAsSparkline::Repor…
end
else
it "should be data ending with the reporting period before the…
- @result.last[0].should == Simplabs::ReportsAsSparkline::Repo…
+ @result.last[0].should == Saulabs::ReportsAsSparkline::Repor…
end
end
end
it 'should return correct data for aggregation :count' do
- @report = Simplabs::ReportsAsSparkline::CumulatedReport.new(User…
+ @report = Saulabs::ReportsAsSparkline::CumulatedReport.new(User,…
:aggregation => :count,
:grouping => grouping,
:limit => 10,
@@ -87,7 +87,7 @@ describe Simplabs::ReportsAsSparkline::CumulatedReport do
end
it 'should return correct data for aggregation :sum' do
- @report = Simplabs::ReportsAsSparkline::CumulatedReport.new(User…
+ @report = Saulabs::ReportsAsSparkline::CumulatedReport.new(User,…
:aggregation => :sum,
:grouping => grouping,
:value_column => :profile_visits,
@@ -104,7 +104,7 @@ describe Simplabs::ReportsAsSparkline::CumulatedReport do
end
it 'should return correct data for aggregation :count when custom …
- @report = Simplabs::ReportsAsSparkline::CumulatedReport.new(User…
+ @report = Saulabs::ReportsAsSparkline::CumulatedReport.new(User,…
:aggregation => :count,
:grouping => grouping,
:limit => 10,
@@ -120,7 +120,7 @@ describe Simplabs::ReportsAsSparkline::CumulatedReport do
end
it 'should return correct data for aggregation :sum when custom co…
- @report = Simplabs::ReportsAsSparkline::CumulatedReport.new(User…
+ @report = Saulabs::ReportsAsSparkline::CumulatedReport.new(User,…
:aggregation => :sum,
:grouping => grouping,
:value_column => :profile_visits,
@@ -149,7 +149,7 @@ describe Simplabs::ReportsAsSparkline::CumulatedReport do
end
after(:each) do
- Simplabs::ReportsAsSparkline::ReportCache.destroy_all
+ Saulabs::ReportsAsSparkline::ReportCache.destroy_all
end
end
diff --git a/spec/classes/grouping_spec.rb b/spec/classes/grouping_spec.rb
@@ -1,11 +1,11 @@
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
-describe Simplabs::ReportsAsSparkline::Grouping do
+describe Saulabs::ReportsAsSparkline::Grouping do
describe '#new' do
it 'should raise an error if an unsupported grouping is specified' do
- lambda { Simplabs::ReportsAsSparkline::Grouping.new(:unsupported) }.shou…
+ lambda { Saulabs::ReportsAsSparkline::Grouping.new(:unsupported) }.shoul…
end
end
@@ -19,19 +19,19 @@ describe Simplabs::ReportsAsSparkline::Grouping do
end
it 'should use DATE_FORMAT with format string "%Y/%m/%d/%H" for grouping…
- Simplabs::ReportsAsSparkline::Grouping.new(:hour).send(:to_sql, 'creat…
+ Saulabs::ReportsAsSparkline::Grouping.new(:hour).send(:to_sql, 'create…
end
it 'should use DATE_FORMAT with format string "%Y/%m/%d" for grouping :d…
- Simplabs::ReportsAsSparkline::Grouping.new(:day).send(:to_sql, 'create…
+ Saulabs::ReportsAsSparkline::Grouping.new(:day).send(:to_sql, 'created…
end
it 'should use YEARWEEK with mode 3 for grouping :week' do
- Simplabs::ReportsAsSparkline::Grouping.new(:week).send(:to_sql, 'creat…
+ Saulabs::ReportsAsSparkline::Grouping.new(:week).send(:to_sql, 'create…
end
it 'should use DATE_FORMAT with format string "%Y/%m" for grouping :mont…
- Simplabs::ReportsAsSparkline::Grouping.new(:month).send(:to_sql, 'crea…
+ Saulabs::ReportsAsSparkline::Grouping.new(:month).send(:to_sql, 'creat…
end
end
@@ -45,7 +45,7 @@ describe Simplabs::ReportsAsSparkline::Grouping do
for grouping in [:hour, :day, :week, :month] do
it "should use date_trunc with truncation identifier \"#{grouping.to_s…
- Simplabs::ReportsAsSparkline::Grouping.new(grouping).send(:to_sql, '…
+ Saulabs::ReportsAsSparkline::Grouping.new(grouping).send(:to_sql, 'c…
end
end
@@ -59,19 +59,19 @@ describe Simplabs::ReportsAsSparkline::Grouping do
end
it 'should use strftime with format string "%Y/%m/%d/%H" for grouping :h…
- Simplabs::ReportsAsSparkline::Grouping.new(:hour).send(:to_sql, 'creat…
+ Saulabs::ReportsAsSparkline::Grouping.new(:hour).send(:to_sql, 'create…
end
it 'should use strftime with format string "%Y/%m/%d" for grouping :day'…
- Simplabs::ReportsAsSparkline::Grouping.new(:day).send(:to_sql, 'create…
+ Saulabs::ReportsAsSparkline::Grouping.new(:day).send(:to_sql, 'created…
end
it 'should use date with mode "weekday 0" for grouping :week' do
- Simplabs::ReportsAsSparkline::Grouping.new(:week).send(:to_sql, 'creat…
+ Saulabs::ReportsAsSparkline::Grouping.new(:week).send(:to_sql, 'create…
end
it 'should use strftime with format string "%Y/%m" for grouping :month' …
- Simplabs::ReportsAsSparkline::Grouping.new(:month).send(:to_sql, 'crea…
+ Saulabs::ReportsAsSparkline::Grouping.new(:month).send(:to_sql, 'creat…
end
end
@@ -89,7 +89,7 @@ describe Simplabs::ReportsAsSparkline::Grouping do
for grouping in [[:hour, '2008/12/31/12'], [:day, '2008/12/31'], [:month…
it "should split the string with '/' for grouping :#{grouping[0].to_s}…
- Simplabs::ReportsAsSparkline::Grouping.new(grouping[0]).date_parts_f…
+ Saulabs::ReportsAsSparkline::Grouping.new(grouping[0]).date_parts_fr…
end
end
@@ -98,7 +98,7 @@ describe Simplabs::ReportsAsSparkline::Grouping do
db_string = '2008-2-1'
expected = [2008, 5]
- Simplabs::ReportsAsSparkline::Grouping.new(:week).date_parts_from_db_s…
+ Saulabs::ReportsAsSparkline::Grouping.new(:week).date_parts_from_db_st…
end
end
@@ -110,19 +110,19 @@ describe Simplabs::ReportsAsSparkline::Grouping do
end
it 'should split the date part of the string with "-" and read out the h…
- Simplabs::ReportsAsSparkline::Grouping.new(:hour).date_parts_from_db_s…
+ Saulabs::ReportsAsSparkline::Grouping.new(:hour).date_parts_from_db_st…
end
it 'should split the date part of the string with "-" for grouping :day'…
- Simplabs::ReportsAsSparkline::Grouping.new(:day).date_parts_from_db_st…
+ Saulabs::ReportsAsSparkline::Grouping.new(:day).date_parts_from_db_str…
end
it 'should split the date part of the string with "-" and calculate the …
- Simplabs::ReportsAsSparkline::Grouping.new(:week).date_parts_from_db_s…
+ Saulabs::ReportsAsSparkline::Grouping.new(:week).date_parts_from_db_st…
end
it 'should split the date part of the string with "-" and return year an…
- Simplabs::ReportsAsSparkline::Grouping.new(:month).date_parts_from_db_…
+ Saulabs::ReportsAsSparkline::Grouping.new(:month).date_parts_from_db_s…
end
end
@@ -136,7 +136,7 @@ describe Simplabs::ReportsAsSparkline::Grouping do
for grouping in [[:hour, '2008/12/31/12'], [:day, '2008/12/31'], [:month…
it "should split the string with '/' for grouping :#{grouping[0].to_s}…
- Simplabs::ReportsAsSparkline::Grouping.new(grouping[0]).date_parts_f…
+ Saulabs::ReportsAsSparkline::Grouping.new(grouping[0]).date_parts_fr…
end
end
@@ -145,7 +145,7 @@ describe Simplabs::ReportsAsSparkline::Grouping do
db_string = '200852'
expected = [2008, 52]
- Simplabs::ReportsAsSparkline::Grouping.new(:week).date_parts_from_db_s…
+ Saulabs::ReportsAsSparkline::Grouping.new(:week).date_parts_from_db_st…
end
end
diff --git a/spec/classes/report_cache_spec.rb b/spec/classes/report_cache_spec…
@@ -1,20 +1,20 @@
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
-describe Simplabs::ReportsAsSparkline::ReportCache do
+describe Saulabs::ReportsAsSparkline::ReportCache do
before do
- @report = Simplabs::ReportsAsSparkline::Report.new(User, :registrations, :…
+ @report = Saulabs::ReportsAsSparkline::Report.new(User, :registrations, :l…
end
describe '.clear_for' do
it 'should delete all entries in the cache for the klass and report name' …
- Simplabs::ReportsAsSparkline::ReportCache.should_receive(:delete_all).on…
+ Saulabs::ReportsAsSparkline::ReportCache.should_receive(:delete_all).onc…
:model_name => User.name,
:report_name => 'registrations'
})
- Simplabs::ReportsAsSparkline::ReportCache.clear_for(User, :registrations)
+ Saulabs::ReportsAsSparkline::ReportCache.clear_for(User, :registrations)
end
end
@@ -22,20 +22,20 @@ describe Simplabs::ReportsAsSparkline::ReportCache do
describe '.process' do
before do
- Simplabs::ReportsAsSparkline::ReportCache.stub!(:find).and_return([])
- Simplabs::ReportsAsSparkline::ReportCache.stub!(:prepare_result).and_ret…
+ Saulabs::ReportsAsSparkline::ReportCache.stub!(:find).and_return([])
+ Saulabs::ReportsAsSparkline::ReportCache.stub!(:prepare_result).and_retu…
end
it 'should raise an ArgumentError if no block is given' do
lambda do
- Simplabs::ReportsAsSparkline::ReportCache.process(@report, @report.opt…
+ Saulabs::ReportsAsSparkline::ReportCache.process(@report, @report.opti…
end.should raise_error(ArgumentError)
end
it 'sould start a transaction' do
- Simplabs::ReportsAsSparkline::ReportCache.should_receive(:transaction)
+ Saulabs::ReportsAsSparkline::ReportCache.should_receive(:transaction)
- Simplabs::ReportsAsSparkline::ReportCache.process(@report, @report.optio…
+ Saulabs::ReportsAsSparkline::ReportCache.process(@report, @report.option…
end
describe 'with :live_data = true' do
@@ -46,34 +46,34 @@ describe Simplabs::ReportsAsSparkline::ReportCache do
it 'should yield to the given block' do
lambda {
- Simplabs::ReportsAsSparkline::ReportCache.process(@report, @options)…
+ Saulabs::ReportsAsSparkline::ReportCache.process(@report, @options) …
}.should raise_error(YieldMatchException)
end
it 'should yield the first reporting period if not all required data cou…
- reporting_period = Simplabs::ReportsAsSparkline::ReportingPeriod.new(
+ reporting_period = Saulabs::ReportsAsSparkline::ReportingPeriod.new(
@report.options[:grouping],
Time.now - 3.send(@report.options[:grouping].identifier)
)
- Simplabs::ReportsAsSparkline::ReportCache.stub!(:all).and_return([Simp…
+ Saulabs::ReportsAsSparkline::ReportCache.stub!(:all).and_return([Saula…
- Simplabs::ReportsAsSparkline::ReportCache.process(@report, @options) d…
- begin_at.should == Simplabs::ReportsAsSparkline::ReportingPeriod.fir…
+ Saulabs::ReportsAsSparkline::ReportCache.process(@report, @options) do…
+ begin_at.should == Saulabs::ReportsAsSparkline::ReportingPeriod.firs…
end_at.should == nil
[]
end
end
it 'should yield the reporting period after the last one in the cache if…
- reporting_period = Simplabs::ReportsAsSparkline::ReportingPeriod.new(
+ reporting_period = Saulabs::ReportsAsSparkline::ReportingPeriod.new(
@report.options[:grouping],
Time.now - @report.options[:limit].send(@report.options[:grouping].i…
)
- cached = Simplabs::ReportsAsSparkline::ReportCache.new
+ cached = Saulabs::ReportsAsSparkline::ReportCache.new
cached.stub!(:reporting_period).and_return(reporting_period.date_time)
- Simplabs::ReportsAsSparkline::ReportCache.stub!(:all).and_return(Array…
+ Saulabs::ReportsAsSparkline::ReportCache.stub!(:all).and_return(Array.…
- Simplabs::ReportsAsSparkline::ReportCache.process(@report, @options) d…
+ Saulabs::ReportsAsSparkline::ReportCache.process(@report, @options) do…
begin_at.should == reporting_period.date_time
end_at.should == nil
[]
@@ -85,18 +85,18 @@ describe Simplabs::ReportsAsSparkline::ReportCache do
describe 'with :live_data = false' do
it 'should not yield if all required data could be retrieved from the ca…
- Simplabs::ReportsAsSparkline::ReportCache.stub!(:all).and_return(Array…
+ Saulabs::ReportsAsSparkline::ReportCache.stub!(:all).and_return(Array.…
lambda {
- Simplabs::ReportsAsSparkline::ReportCache.process(@report, @report.o…
+ Saulabs::ReportsAsSparkline::ReportCache.process(@report, @report.op…
}.should_not raise_error(YieldMatchException)
end
it 'should yield to the block if no data could be retrieved from the cac…
- Simplabs::ReportsAsSparkline::ReportCache.stub!(:all).and_return([])
+ Saulabs::ReportsAsSparkline::ReportCache.stub!(:all).and_return([])
lambda {
- Simplabs::ReportsAsSparkline::ReportCache.process(@report, @report.o…
+ Saulabs::ReportsAsSparkline::ReportCache.process(@report, @report.op…
}.should raise_error(YieldMatchException)
end
@@ -107,9 +107,9 @@ describe Simplabs::ReportsAsSparkline::ReportCache do
end
it 'should yield the last date and time of the reporting period for th…
- reporting_period = Simplabs::ReportsAsSparkline::ReportingPeriod.new…
+ reporting_period = Saulabs::ReportsAsSparkline::ReportingPeriod.new(…
- Simplabs::ReportsAsSparkline::ReportCache.process(@report, @options)…
+ Saulabs::ReportsAsSparkline::ReportCache.process(@report, @options) …
end_at.should == reporting_period.last_date_time
[]
end
@@ -120,7 +120,7 @@ describe Simplabs::ReportsAsSparkline::ReportCache do
end
it 'should read existing data from the cache' do
- Simplabs::ReportsAsSparkline::ReportCache.should_receive(:all).once.with(
+ Saulabs::ReportsAsSparkline::ReportCache.should_receive(:all).once.with(
:conditions => [
'model_name = ? AND report_name = ? AND grouping = ? AND aggregation…
@report.klass.to_s,
@@ -128,18 +128,18 @@ describe Simplabs::ReportsAsSparkline::ReportCache do
@report.options[:grouping].identifier.to_s,
@report.aggregation.to_s,
@report.options[:conditions].to_s,
- Simplabs::ReportsAsSparkline::ReportingPeriod.first(@report.options[…
+ Saulabs::ReportsAsSparkline::ReportingPeriod.first(@report.options[:…
],
:limit => 10,
:order => 'reporting_period ASC'
).and_return([])
- Simplabs::ReportsAsSparkline::ReportCache.process(@report, @report.optio…
+ Saulabs::ReportsAsSparkline::ReportCache.process(@report, @report.option…
end
it 'should utilize the end_date in the conditions' do
end_date = Time.now
- Simplabs::ReportsAsSparkline::ReportCache.should_receive(:all).once.with(
+ Saulabs::ReportsAsSparkline::ReportCache.should_receive(:all).once.with(
:conditions => [
'model_name = ? AND report_name = ? AND grouping = ? AND aggregation…
@report.klass.to_s,
@@ -147,19 +147,19 @@ describe Simplabs::ReportsAsSparkline::ReportCache do
@report.options[:grouping].identifier.to_s,
@report.aggregation.to_s,
@report.options[:conditions].to_s,
- Simplabs::ReportsAsSparkline::ReportingPeriod.first(@report.options[…
- Simplabs::ReportsAsSparkline::ReportingPeriod.new(@report.options[:g…
+ Saulabs::ReportsAsSparkline::ReportingPeriod.first(@report.options[:…
+ Saulabs::ReportsAsSparkline::ReportingPeriod.new(@report.options[:gr…
],
:limit => 10,
:order => 'reporting_period ASC'
).and_return([])
- Simplabs::ReportsAsSparkline::ReportCache.process(@report, @report.optio…
+ Saulabs::ReportsAsSparkline::ReportCache.process(@report, @report.option…
end
it "should read existing data from the cache for the correct grouping if o…
- grouping = Simplabs::ReportsAsSparkline::Grouping.new(:month)
- Simplabs::ReportsAsSparkline::ReportCache.should_receive(:find).once.wit…
+ grouping = Saulabs::ReportsAsSparkline::Grouping.new(:month)
+ Saulabs::ReportsAsSparkline::ReportCache.should_receive(:find).once.with(
:all,
:conditions => [
'model_name = ? AND report_name = ? AND grouping = ? AND aggregation…
@@ -168,18 +168,18 @@ describe Simplabs::ReportsAsSparkline::ReportCache do
grouping.identifier.to_s,
@report.aggregation.to_s,
@report.options[:conditions].to_s,
- Simplabs::ReportsAsSparkline::ReportingPeriod.first(grouping, 10).da…
+ Saulabs::ReportsAsSparkline::ReportingPeriod.first(grouping, 10).dat…
],
:limit => 10,
:order => 'reporting_period ASC'
).and_return([])
- Simplabs::ReportsAsSparkline::ReportCache.process(@report, { :limit => 1…
+ Saulabs::ReportsAsSparkline::ReportCache.process(@report, { :limit => 10…
end
it 'should yield the first reporting period if the cache is empty' do
- Simplabs::ReportsAsSparkline::ReportCache.process(@report, @report.optio…
- begin_at.should == Simplabs::ReportsAsSparkline::ReportingPeriod.first…
+ Saulabs::ReportsAsSparkline::ReportCache.process(@report, @report.option…
+ begin_at.should == Saulabs::ReportsAsSparkline::ReportingPeriod.first(…
end_at.should == nil
[]
end
@@ -189,16 +189,16 @@ describe Simplabs::ReportsAsSparkline::ReportCache do
describe '.prepare_result' do
before do
- @current_reporting_period = Simplabs::ReportsAsSparkline::ReportingPerio…
+ @current_reporting_period = Saulabs::ReportsAsSparkline::ReportingPeriod…
@new_data = [[@current_reporting_period.previous.date_time, 1.0]]
- Simplabs::ReportsAsSparkline::ReportingPeriod.stub!(:from_db_string).and…
- @cached = Simplabs::ReportsAsSparkline::ReportCache.new
+ Saulabs::ReportsAsSparkline::ReportingPeriod.stub!(:from_db_string).and_…
+ @cached = Saulabs::ReportsAsSparkline::ReportCache.new
@cached.stub!(:save!)
- Simplabs::ReportsAsSparkline::ReportCache.stub!(:build_cached_data).and_…
+ Saulabs::ReportsAsSparkline::ReportCache.stub!(:build_cached_data).and_r…
end
- it 'should create :limit instances of Simplabs::ReportsAsSparkline::Report…
- Simplabs::ReportsAsSparkline::ReportCache.should_receive(:build_cached_d…
+ it 'should create :limit instances of Saulabs::ReportsAsSparkline::ReportC…
+ Saulabs::ReportsAsSparkline::ReportCache.should_receive(:build_cached_da…
@report,
@report.options[:grouping],
@report.options[:conditions],
@@ -206,18 +206,18 @@ describe Simplabs::ReportsAsSparkline::ReportCache do
0.0
).and_return(@cached)
- Simplabs::ReportsAsSparkline::ReportCache.send(:prepare_result, [], [], …
+ Saulabs::ReportsAsSparkline::ReportCache.send(:prepare_result, [], [], @…
end
- it 'should create a new Simplabs::ReportsAsSparkline::ReportCache with the…
- Simplabs::ReportsAsSparkline::ReportCache.should_receive(:build_cached_d…
+ it 'should create a new Saulabs::ReportsAsSparkline::ReportCache with the …
+ Saulabs::ReportsAsSparkline::ReportCache.should_receive(:build_cached_da…
@report,
@report.options[:grouping],
@report.options[:conditions],
anything(),
0.0
).and_return(@cached)
- Simplabs::ReportsAsSparkline::ReportCache.should_receive(:build_cached_d…
+ Saulabs::ReportsAsSparkline::ReportCache.should_receive(:build_cached_da…
@report,
@report.options[:grouping],
@report.options[:conditions],
@@ -225,17 +225,17 @@ describe Simplabs::ReportsAsSparkline::ReportCache do
1.0
).and_return(@cached)
- Simplabs::ReportsAsSparkline::ReportCache.send(:prepare_result, @new_dat…
+ Saulabs::ReportsAsSparkline::ReportCache.send(:prepare_result, @new_data…
end
- it 'should save the created Simplabs::ReportsAsSparkline::ReportCache' do
+ it 'should save the created Saulabs::ReportsAsSparkline::ReportCache' do
@cached.should_receive(:save!).once
- Simplabs::ReportsAsSparkline::ReportCache.send(:prepare_result, @new_dat…
+ Saulabs::ReportsAsSparkline::ReportCache.send(:prepare_result, @new_data…
end
it 'should return an array of arrays of Dates and Floats' do
- result = Simplabs::ReportsAsSparkline::ReportCache.send(:prepare_result,…
+ result = Saulabs::ReportsAsSparkline::ReportCache.send(:prepare_result, …
result.should be_kind_of(Array)
result[0].should be_kind_of(Array)
@@ -246,7 +246,7 @@ describe Simplabs::ReportsAsSparkline::ReportCache do
describe 'with :live_data = false' do
before do
- @result = Simplabs::ReportsAsSparkline::ReportCache.send(:prepare_resu…
+ @result = Saulabs::ReportsAsSparkline::ReportCache.send(:prepare_resul…
end
it 'should return an array of length :limit' do
@@ -263,7 +263,7 @@ describe Simplabs::ReportsAsSparkline::ReportCache do
before do
options = @report.options.merge(:live_data => true)
- @result = Simplabs::ReportsAsSparkline::ReportCache.send(:prepare_resu…
+ @result = Saulabs::ReportsAsSparkline::ReportCache.send(:prepare_resul…
end
it 'should return an array of length (:limit + 1)' do
@@ -280,15 +280,15 @@ describe Simplabs::ReportsAsSparkline::ReportCache do
describe '.find_value' do
before do
- @data = [[Simplabs::ReportsAsSparkline::ReportingPeriod.new(Simplabs::Re…
+ @data = [[Saulabs::ReportsAsSparkline::ReportingPeriod.new(Saulabs::Repo…
end
it 'should return the correct value when new data has been read for the re…
- Simplabs::ReportsAsSparkline::ReportCache.send(:find_value, @data, @data…
+ Saulabs::ReportsAsSparkline::ReportCache.send(:find_value, @data, @data[…
end
it 'should return 0.0 when no data has been read for the reporting period'…
- Simplabs::ReportsAsSparkline::ReportCache.send(:find_value, @data, @data…
+ Saulabs::ReportsAsSparkline::ReportCache.send(:find_value, @data, @data[…
end
end
diff --git a/spec/classes/report_spec.rb b/spec/classes/report_spec.rb
@@ -1,9 +1,9 @@
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
-describe Simplabs::ReportsAsSparkline::Report do
+describe Saulabs::ReportsAsSparkline::Report do
before do
- @report = Simplabs::ReportsAsSparkline::Report.new(User, :registrations)
+ @report = Saulabs::ReportsAsSparkline::Report.new(User, :registrations)
@now = Time.now
DateTime.stub!(:now).and_return(@now)
end
@@ -19,7 +19,7 @@ describe Simplabs::ReportsAsSparkline::Report do
describe '#run' do
it 'should process the data with the report cache' do
- Simplabs::ReportsAsSparkline::ReportCache.should_receive(:process).once.…
+ Saulabs::ReportsAsSparkline::ReportCache.should_receive(:process).once.w…
@report,
{ :limit => 100, :grouping => @report.options[:grouping], :conditions …
)
@@ -28,7 +28,7 @@ describe Simplabs::ReportsAsSparkline::Report do
end
it 'should process the data with the report cache when custom conditions a…
- Simplabs::ReportsAsSparkline::ReportCache.should_receive(:process).once.…
+ Saulabs::ReportsAsSparkline::ReportCache.should_receive(:process).once.w…
@report,
{ :limit => 100, :grouping => @report.options[:grouping], :conditions …
)
@@ -43,9 +43,9 @@ describe Simplabs::ReportsAsSparkline::Report do
end
it 'should use a custom grouping if one is specified' do
- grouping = Simplabs::ReportsAsSparkline::Grouping.new(:month)
- Simplabs::ReportsAsSparkline::Grouping.should_receive(:new).once.with(:m…
- Simplabs::ReportsAsSparkline::ReportCache.should_receive(:process).once.…
+ grouping = Saulabs::ReportsAsSparkline::Grouping.new(:month)
+ Saulabs::ReportsAsSparkline::Grouping.should_receive(:new).once.with(:mo…
+ Saulabs::ReportsAsSparkline::ReportCache.should_receive(:process).once.w…
@report,
{ :limit => 100, :grouping => grouping, :conditions => [], :live_data …
)
@@ -54,13 +54,13 @@ describe Simplabs::ReportsAsSparkline::Report do
end
it 'should return an array of the same length as the specified limit when …
- @report = Simplabs::ReportsAsSparkline::Report.new(User, :cumulated_regi…
+ @report = Saulabs::ReportsAsSparkline::Report.new(User, :cumulated_regis…
@report.run.length.should == 10
end
it 'should return an array of the same length as the specified limit + 1 w…
- @report = Simplabs::ReportsAsSparkline::Report.new(User, :cumulated_regi…
+ @report = Saulabs::ReportsAsSparkline::Report.new(User, :cumulated_regis…
@report.run.length.should == 11
end
@@ -79,7 +79,7 @@ describe Simplabs::ReportsAsSparkline::Report do
describe 'when :end_date is specified' do
it 'should not raise a SQL duplicate key error after multiple runs' …
- @report = Simplabs::ReportsAsSparkline::Report.new(User, :registra…
+ @report = Saulabs::ReportsAsSparkline::Report.new(User, :registrat…
:limit => 2,
:grouping => grouping,
:end_date => Date.yesterday.to_datetime
@@ -92,8 +92,8 @@ describe Simplabs::ReportsAsSparkline::Report do
before do
@end_date = DateTime.now - 1.send(grouping)
- @grouping = Simplabs::ReportsAsSparkline::Grouping.new(grouping)
- @report = Simplabs::ReportsAsSparkline::Report.new(User, :regist…
+ @grouping = Saulabs::ReportsAsSparkline::Grouping.new(grouping)
+ @report = Saulabs::ReportsAsSparkline::Report.new(User, :registr…
:grouping => grouping,
:limit => 10,
:end_date => @end_date
@@ -102,11 +102,11 @@ describe Simplabs::ReportsAsSparkline::Report do
end
it "should start with the reporting period (end_date - limit.#{gro…
- @result.first[0].should == Simplabs::ReportsAsSparkline::Reporti…
+ @result.first[0].should == Saulabs::ReportsAsSparkline::Reportin…
end
it "should end with the reporting period of the specified end date…
- @result.last[0].should == Simplabs::ReportsAsSparkline::Reportin…
+ @result.last[0].should == Saulabs::ReportsAsSparkline::Reporting…
end
end
@@ -120,9 +120,9 @@ describe Simplabs::ReportsAsSparkline::Report do
describe 'the returned result' do
before do
- Simplabs::ReportsAsSparkline::ReportCache.delete_all
- @grouping = Simplabs::ReportsAsSparkline::Grouping.new(groupin…
- @report = Simplabs::ReportsAsSparkline::Report.new(User, :regi…
+ Saulabs::ReportsAsSparkline::ReportCache.delete_all
+ @grouping = Saulabs::ReportsAsSparkline::Grouping.new(grouping)
+ @report = Saulabs::ReportsAsSparkline::Report.new(User, :regis…
:grouping => grouping,
:limit => 10,
:live_data => live_data
@@ -131,23 +131,23 @@ describe Simplabs::ReportsAsSparkline::Report do
end
it "should be an array starting reporting period (Time.now - lim…
- @result.first[0].should == Simplabs::ReportsAsSparkline::Repor…
+ @result.first[0].should == Saulabs::ReportsAsSparkline::Report…
end
if live_data
it "should be data ending with the current reporting period" do
- @result.last[0].should == Simplabs::ReportsAsSparkline::Repo…
+ @result.last[0].should == Saulabs::ReportsAsSparkline::Repor…
end
else
it "should be data ending with the reporting period before the…
- @result.last[0].should == Simplabs::ReportsAsSparkline::Repo…
+ @result.last[0].should == Saulabs::ReportsAsSparkline::Repor…
end
end
end
it 'should return correct data for aggregation :count' do
- @report = Simplabs::ReportsAsSparkline::Report.new(User, :regist…
+ @report = Saulabs::ReportsAsSparkline::Report.new(User, :registr…
:aggregation => :count,
:grouping => grouping,
:limit => 10,
@@ -163,7 +163,7 @@ describe Simplabs::ReportsAsSparkline::Report do
end
it 'should return correct data for aggregation :sum' do
- @report = Simplabs::ReportsAsSparkline::Report.new(User, :regist…
+ @report = Saulabs::ReportsAsSparkline::Report.new(User, :registr…
:aggregation => :sum,
:grouping => grouping,
:value_column => :profile_visits,
@@ -180,7 +180,7 @@ describe Simplabs::ReportsAsSparkline::Report do
end
it 'should return correct data for aggregation :maximum' do
- @report = Simplabs::ReportsAsSparkline::Report.new(User, :regist…
+ @report = Saulabs::ReportsAsSparkline::Report.new(User, :registr…
:aggregation => :maximum,
:grouping => grouping,
:value_column => :profile_visits,
@@ -197,7 +197,7 @@ describe Simplabs::ReportsAsSparkline::Report do
end
it 'should return correct data for aggregation :minimum' do
- @report = Simplabs::ReportsAsSparkline::Report.new(User, :regist…
+ @report = Saulabs::ReportsAsSparkline::Report.new(User, :registr…
:aggregation => :minimum,
:grouping => grouping,
:value_column => :profile_visits,
@@ -214,7 +214,7 @@ describe Simplabs::ReportsAsSparkline::Report do
end
it 'should return correct data for aggregation :average' do
- @report = Simplabs::ReportsAsSparkline::Report.new(User, :regist…
+ @report = Saulabs::ReportsAsSparkline::Report.new(User, :registr…
:aggregation => :average,
:grouping => grouping,
:value_column => :profile_visits,
@@ -231,7 +231,7 @@ describe Simplabs::ReportsAsSparkline::Report do
end
it 'should return correct data for aggregation :count when custom …
- @report = Simplabs::ReportsAsSparkline::Report.new(User, :regist…
+ @report = Saulabs::ReportsAsSparkline::Report.new(User, :registr…
:aggregation => :count,
:grouping => grouping,
:limit => 10,
@@ -247,7 +247,7 @@ describe Simplabs::ReportsAsSparkline::Report do
end
it 'should return correct data for aggregation :sum when custom co…
- @report = Simplabs::ReportsAsSparkline::Report.new(User, :regist…
+ @report = Saulabs::ReportsAsSparkline::Report.new(User, :registr…
:aggregation => :sum,
:grouping => grouping,
:value_column => :profile_visits,
@@ -264,7 +264,7 @@ describe Simplabs::ReportsAsSparkline::Report do
end
it 'should return correct results when run twice in a row with a h…
- @report = Simplabs::ReportsAsSparkline::Report.new(User, :regist…
+ @report = Saulabs::ReportsAsSparkline::Report.new(User, :registr…
:aggregation => :count,
:grouping => grouping,
:limit => 10,
@@ -288,7 +288,7 @@ describe Simplabs::ReportsAsSparkline::Report do
unless live_data
it 'should return correct data for aggregation :count when :end_…
- @report = Simplabs::ReportsAsSparkline::Report.new(User, :regi…
+ @report = Saulabs::ReportsAsSparkline::Report.new(User, :regis…
:aggregation => :count,
:grouping => grouping,
:limit => 10,
@@ -303,7 +303,7 @@ describe Simplabs::ReportsAsSparkline::Report do
end
it 'should return correct data for aggregation :sum when :end_da…
- @report = Simplabs::ReportsAsSparkline::Report.new(User, :regi…
+ @report = Saulabs::ReportsAsSparkline::Report.new(User, :regis…
:aggregation => :sum,
:grouping => grouping,
:value_column => :profile_visits,
@@ -319,7 +319,7 @@ describe Simplabs::ReportsAsSparkline::Report do
end
it 'should return correct results when run twice in a row with a…
- @report = Simplabs::ReportsAsSparkline::Report.new(User, :regi…
+ @report = Saulabs::ReportsAsSparkline::Report.new(User, :regis…
:aggregation => :count,
:grouping => grouping,
:limit => 10,
@@ -367,7 +367,7 @@ describe Simplabs::ReportsAsSparkline::Report do
end
it 'should return correct data for aggregation :count' do
- @report = Simplabs::ReportsAsSparkline::Report.new(User, :registrati…
+ @report = Saulabs::ReportsAsSparkline::Report.new(User, :registratio…
:aggregation => :count,
:grouping => :week,
:limit => 10
@@ -396,7 +396,7 @@ describe Simplabs::ReportsAsSparkline::Report do
end
it 'should return correct data for aggregation :count' do
- @report = Simplabs::ReportsAsSparkline::Report.new(User, :registrati…
+ @report = Saulabs::ReportsAsSparkline::Report.new(User, :registratio…
:aggregation => :count,
:grouping => :week,
:limit => 10
@@ -415,7 +415,7 @@ describe Simplabs::ReportsAsSparkline::Report do
end
after do
- Simplabs::ReportsAsSparkline::ReportCache.destroy_all
+ Saulabs::ReportsAsSparkline::ReportCache.destroy_all
end
after(:all) do
@@ -427,7 +427,7 @@ describe Simplabs::ReportsAsSparkline::Report do
describe '#read_data' do
it 'should invoke the aggregation method on the model' do
- @report = Simplabs::ReportsAsSparkline::Report.new(User, :registrations,…
+ @report = Saulabs::ReportsAsSparkline::Report.new(User, :registrations, …
User.should_receive(:count).once.and_return([])
@report.send(:read_data, Time.now, 5.days.from_now, { :grouping => @repo…
diff --git a/spec/classes/reporting_period_spec.rb b/spec/classes/reporting_per…
@@ -1,19 +1,19 @@
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
-describe Simplabs::ReportsAsSparkline::ReportingPeriod do
+describe Saulabs::ReportsAsSparkline::ReportingPeriod do
describe '#date_time' do
it 'should return the date and time with minutes = seconds = 0 for groupin…
date_time = DateTime.now
- reporting_period = Simplabs::ReportsAsSparkline::ReportingPeriod.new(Sim…
+ reporting_period = Saulabs::ReportsAsSparkline::ReportingPeriod.new(Saul…
reporting_period.date_time.should == DateTime.new(date_time.year, date_t…
end
it 'should return the date part only for grouping :day' do
date_time = DateTime.now
- reporting_period = Simplabs::ReportsAsSparkline::ReportingPeriod.new(Sim…
+ reporting_period = Saulabs::ReportsAsSparkline::ReportingPeriod.new(Saul…
reporting_period.date_time.should == date_time.to_date
end
@@ -22,28 +22,28 @@ describe Simplabs::ReportsAsSparkline::ReportingPeriod do
it 'should return the date of the monday of the week date_time is in for…
date_time = DateTime.new(2008, 11, 27)
- reporting_period = Simplabs::ReportsAsSparkline::ReportingPeriod.new(S…
+ reporting_period = Saulabs::ReportsAsSparkline::ReportingPeriod.new(Sa…
reporting_period.date_time.should == Date.new(date_time.year, date_tim…
end
it 'should return the date of the monday of the week date_time is in whe…
date_time = DateTime.new(2008, 11, 24)
- reporting_period = Simplabs::ReportsAsSparkline::ReportingPeriod.new(S…
+ reporting_period = Saulabs::ReportsAsSparkline::ReportingPeriod.new(Sa…
reporting_period.date_time.should == Date.new(date_time.year, date_tim…
end
it 'should return the date of the monday of the week date_time is in whe…
date_time = DateTime.new(2008, 11, 1)
- reporting_period = Simplabs::ReportsAsSparkline::ReportingPeriod.new(S…
+ reporting_period = Saulabs::ReportsAsSparkline::ReportingPeriod.new(Sa…
reporting_period.date_time.should == Date.new(2008, 10, 27)
end
it 'should return the date of the monday of the week date_time is in whe…
date_time = DateTime.new(2009, 1, 1)
- reporting_period = Simplabs::ReportsAsSparkline::ReportingPeriod.new(S…
+ reporting_period = Saulabs::ReportsAsSparkline::ReportingPeriod.new(Sa…
reporting_period.date_time.should == Date.new(2008, 12, 29)
end
@@ -52,7 +52,7 @@ describe Simplabs::ReportsAsSparkline::ReportingPeriod do
it 'should return the date with day = 1 for grouping :month' do
date_time = Time.now
- reporting_period = Simplabs::ReportsAsSparkline::ReportingPeriod.new(Sim…
+ reporting_period = Saulabs::ReportsAsSparkline::ReportingPeriod.new(Saul…
reporting_period.date_time.should == Date.new(date_time.year, date_time.…
end
@@ -63,14 +63,14 @@ describe Simplabs::ReportsAsSparkline::ReportingPeriod do
it 'should return the date and time with minutes = seconds = 59 for groupi…
date_time = DateTime.now
- reporting_period = Simplabs::ReportsAsSparkline::ReportingPeriod.new(Sim…
+ reporting_period = Saulabs::ReportsAsSparkline::ReportingPeriod.new(Saul…
reporting_period.last_date_time.should == DateTime.new(date_time.year, d…
end
it 'should return the date part with hour = 23 and minute = seconds = 59 f…
date_time = DateTime.now
- reporting_period = Simplabs::ReportsAsSparkline::ReportingPeriod.new(Sim…
+ reporting_period = Saulabs::ReportsAsSparkline::ReportingPeriod.new(Saul…
reporting_period.last_date_time.should == DateTime.new(date_time.year, d…
end
@@ -79,21 +79,21 @@ describe Simplabs::ReportsAsSparkline::ReportingPeriod do
it 'should return the date of the sunday of the week date_time is in for…
date_time = DateTime.new(2008, 11, 27)
- reporting_period = Simplabs::ReportsAsSparkline::ReportingPeriod.new(S…
+ reporting_period = Saulabs::ReportsAsSparkline::ReportingPeriod.new(Sa…
reporting_period.last_date_time.should == Date.new(date_time.year, dat…
end
it 'should return the date of the sunday of the week date_time is in whe…
date_time = DateTime.new(2008, 10, 30)
- reporting_period = Simplabs::ReportsAsSparkline::ReportingPeriod.new(S…
+ reporting_period = Saulabs::ReportsAsSparkline::ReportingPeriod.new(Sa…
reporting_period.last_date_time.should == Date.new(2008, 11, 2)
end
it 'should return the date of the sunday of the week date_time is in whe…
date_time = DateTime.new(2008, 12, 29)
- reporting_period = Simplabs::ReportsAsSparkline::ReportingPeriod.new(S…
+ reporting_period = Saulabs::ReportsAsSparkline::ReportingPeriod.new(Sa…
reporting_period.last_date_time.should == Date.new(2009, 1, 4)
end
@@ -102,7 +102,7 @@ describe Simplabs::ReportsAsSparkline::ReportingPeriod do
it 'should return the date of the last day of the month for grouping :mont…
date_time = DateTime.new(2009, 4, 29)
- reporting_period = Simplabs::ReportsAsSparkline::ReportingPeriod.new(Sim…
+ reporting_period = Saulabs::ReportsAsSparkline::ReportingPeriod.new(Saul…
reporting_period.last_date_time.should == Date.new(date_time.year, date_…
end
@@ -112,31 +112,31 @@ describe Simplabs::ReportsAsSparkline::ReportingPeriod do
describe '.from_db_string' do
it 'should return a reporting period with the correct date and time and wi…
- grouping = Simplabs::ReportsAsSparkline::Grouping.new(:hour)
+ grouping = Saulabs::ReportsAsSparkline::Grouping.new(:hour)
grouping.stub!(:date_parts_from_db_string).and_return([2008, 1, 1, 12])
- Simplabs::ReportsAsSparkline::ReportingPeriod.from_db_string(grouping, '…
+ Saulabs::ReportsAsSparkline::ReportingPeriod.from_db_string(grouping, ''…
end
it 'should return a reporting period with the date part only for grouping …
- grouping = Simplabs::ReportsAsSparkline::Grouping.new(:day)
+ grouping = Saulabs::ReportsAsSparkline::Grouping.new(:day)
grouping.stub!(:date_parts_from_db_string).and_return([2008, 1, 1])
- Simplabs::ReportsAsSparkline::ReportingPeriod.from_db_string(grouping, '…
+ Saulabs::ReportsAsSparkline::ReportingPeriod.from_db_string(grouping, ''…
end
it 'should return a reporting period with the date part of the monday of t…
- grouping = Simplabs::ReportsAsSparkline::Grouping.new(:week)
+ grouping = Saulabs::ReportsAsSparkline::Grouping.new(:week)
grouping.stub!(:date_parts_from_db_string).and_return([2008, 1])
- Simplabs::ReportsAsSparkline::ReportingPeriod.from_db_string(grouping, '…
+ Saulabs::ReportsAsSparkline::ReportingPeriod.from_db_string(grouping, ''…
end
it 'should return a reporting period with the correct date and with day = …
- grouping = Simplabs::ReportsAsSparkline::Grouping.new(:month)
+ grouping = Saulabs::ReportsAsSparkline::Grouping.new(:month)
grouping.stub!(:date_parts_from_db_string).and_return([2008, 1])
- Simplabs::ReportsAsSparkline::ReportingPeriod.from_db_string(grouping, '…
+ Saulabs::ReportsAsSparkline::ReportingPeriod.from_db_string(grouping, ''…
end
end
@@ -145,7 +145,7 @@ describe Simplabs::ReportsAsSparkline::ReportingPeriod do
it 'should return a reporting period with date and time one hour after the…
now = Time.now
- reporting_period = Simplabs::ReportsAsSparkline::ReportingPeriod.new(Sim…
+ reporting_period = Saulabs::ReportsAsSparkline::ReportingPeriod.new(Saul…
expected = now + 1.hour
reporting_period.next.date_time.should == DateTime.new(expected.year, ex…
@@ -153,7 +153,7 @@ describe Simplabs::ReportsAsSparkline::ReportingPeriod do
it 'should return a reporting period with date one day after the current p…
now = Time.now
- reporting_period = Simplabs::ReportsAsSparkline::ReportingPeriod.new(Sim…
+ reporting_period = Saulabs::ReportsAsSparkline::ReportingPeriod.new(Saul…
expected = now + 1.day
reporting_period.next.date_time.should == Date.new(expected.year, expect…
@@ -161,7 +161,7 @@ describe Simplabs::ReportsAsSparkline::ReportingPeriod do
it 'should return a reporting period with date one week after the current …
now = DateTime.now
- reporting_period = Simplabs::ReportsAsSparkline::ReportingPeriod.new(Sim…
+ reporting_period = Saulabs::ReportsAsSparkline::ReportingPeriod.new(Saul…
expected = reporting_period.date_time + 1.week
reporting_period.next.date_time.should == Date.new(expected.year, expect…
@@ -169,7 +169,7 @@ describe Simplabs::ReportsAsSparkline::ReportingPeriod do
it 'should return a reporting period with date of the first day in the mon…
now = Time.now
- reporting_period = Simplabs::ReportsAsSparkline::ReportingPeriod.new(Sim…
+ reporting_period = Saulabs::ReportsAsSparkline::ReportingPeriod.new(Saul…
expected = reporting_period.date_time + 1.month
reporting_period.next.date_time.should == Date.new(expected.year, expect…
@@ -181,7 +181,7 @@ describe Simplabs::ReportsAsSparkline::ReportingPeriod do
it 'should return a reporting period with date and time one hour before th…
now = Time.now
- reporting_period = Simplabs::ReportsAsSparkline::ReportingPeriod.new(Sim…
+ reporting_period = Saulabs::ReportsAsSparkline::ReportingPeriod.new(Saul…
expected = now - 1.hour
reporting_period.previous.date_time.should == DateTime.new(expected.year…
@@ -189,7 +189,7 @@ describe Simplabs::ReportsAsSparkline::ReportingPeriod do
it 'should return a reporting period with date one day before the current …
now = Time.now
- reporting_period = Simplabs::ReportsAsSparkline::ReportingPeriod.new(Sim…
+ reporting_period = Saulabs::ReportsAsSparkline::ReportingPeriod.new(Saul…
expected = now - 1.day
reporting_period.previous.date_time.should == Date.new(expected.year, ex…
@@ -197,7 +197,7 @@ describe Simplabs::ReportsAsSparkline::ReportingPeriod do
it 'should return a reporting period with date one week before the current…
now = DateTime.now
- reporting_period = Simplabs::ReportsAsSparkline::ReportingPeriod.new(Sim…
+ reporting_period = Saulabs::ReportsAsSparkline::ReportingPeriod.new(Saul…
expected = reporting_period.date_time - 1.week
reporting_period.previous.date_time.should == Date.new(expected.year, ex…
@@ -205,7 +205,7 @@ describe Simplabs::ReportsAsSparkline::ReportingPeriod do
it 'should return a reporting period with date of the first day in the mon…
now = Time.now
- reporting_period = Simplabs::ReportsAsSparkline::ReportingPeriod.new(Sim…
+ reporting_period = Saulabs::ReportsAsSparkline::ReportingPeriod.new(Saul…
expected = reporting_period.date_time - 1.month
reporting_period.previous.date_time.should == Date.new(expected.year, ex…
@@ -217,30 +217,30 @@ describe Simplabs::ReportsAsSparkline::ReportingPeriod do
it 'should return true for 2 reporting periods with the same date_time and…
now = DateTime.now
- reporting_period1 = Simplabs::ReportsAsSparkline::ReportingPeriod.new(Si…
- reporting_period2 = Simplabs::ReportsAsSparkline::ReportingPeriod.new(Si…
+ reporting_period1 = Saulabs::ReportsAsSparkline::ReportingPeriod.new(Sau…
+ reporting_period2 = Saulabs::ReportsAsSparkline::ReportingPeriod.new(Sau…
(reporting_period1 == reporting_period2).should == true
end
it 'should return false for 2 reporting periods with the same date_time bu…
now = Time.now
- reporting_period1 = Simplabs::ReportsAsSparkline::ReportingPeriod.new(Si…
- reporting_period2 = Simplabs::ReportsAsSparkline::ReportingPeriod.new(Si…
+ reporting_period1 = Saulabs::ReportsAsSparkline::ReportingPeriod.new(Sau…
+ reporting_period2 = Saulabs::ReportsAsSparkline::ReportingPeriod.new(Sau…
(reporting_period1 == reporting_period2).should == false
end
it 'should return true for 2 reporting periods with the same grouping but …
- reporting_period1 = Simplabs::ReportsAsSparkline::ReportingPeriod.new(Si…
- reporting_period2 = Simplabs::ReportsAsSparkline::ReportingPeriod.new(Si…
+ reporting_period1 = Saulabs::ReportsAsSparkline::ReportingPeriod.new(Sau…
+ reporting_period2 = Saulabs::ReportsAsSparkline::ReportingPeriod.new(Sau…
(reporting_period1 == reporting_period2).should == true
end
it 'should return false for 2 reporting periods with the same grouping but…
- reporting_period1 = Simplabs::ReportsAsSparkline::ReportingPeriod.new(Si…
- reporting_period2 = Simplabs::ReportsAsSparkline::ReportingPeriod.new(Si…
+ reporting_period1 = Saulabs::ReportsAsSparkline::ReportingPeriod.new(Sau…
+ reporting_period2 = Saulabs::ReportsAsSparkline::ReportingPeriod.new(Sau…
(reporting_period1 == reporting_period2).should == false
end
@@ -251,7 +251,7 @@ describe Simplabs::ReportsAsSparkline::ReportingPeriod do
it 'should return true when the date and hour are equal' do
date_time = DateTime.new(2008, 10, 30, 12)
- reporting_period = Simplabs::ReportsAsSparkline::ReportingPeriod.new…
+ reporting_period = Saulabs::ReportsAsSparkline::ReportingPeriod.new(…
reporting_period.should == date_time
end
@@ -262,7 +262,7 @@ describe Simplabs::ReportsAsSparkline::ReportingPeriod do
it 'should return true when the date is equal' do
date_time = DateTime.new(2008, 10, 30)
- reporting_period = Simplabs::ReportsAsSparkline::ReportingPeriod.new…
+ reporting_period = Saulabs::ReportsAsSparkline::ReportingPeriod.new(…
reporting_period.should == date_time
end
@@ -273,7 +273,7 @@ describe Simplabs::ReportsAsSparkline::ReportingPeriod do
it 'should return true when the date of the first day in that week is …
date_time = DateTime.new(2009, 5, 4) #monday (first day of the week …
- reporting_period = Simplabs::ReportsAsSparkline::ReportingPeriod.new…
+ reporting_period = Saulabs::ReportsAsSparkline::ReportingPeriod.new(…
reporting_period.should == DateTime.new(2009, 5, 7) #thursday of sam…
end
@@ -284,7 +284,7 @@ describe Simplabs::ReportsAsSparkline::ReportingPeriod do
it 'should return true when the date of the first day in that month is…
date_time = DateTime.new(2009, 5, 1)
- reporting_period = Simplabs::ReportsAsSparkline::ReportingPeriod.new…
+ reporting_period = Saulabs::ReportsAsSparkline::ReportingPeriod.new(…
reporting_period.should == DateTime.new(2009, 5, 17)
end
@@ -303,14 +303,14 @@ describe Simplabs::ReportsAsSparkline::ReportingPeriod do
end
it 'should return a reporting period with the date part of (DateTime.now -…
- reporting_period = Simplabs::ReportsAsSparkline::ReportingPeriod.first(S…
+ reporting_period = Saulabs::ReportsAsSparkline::ReportingPeriod.first(Sa…
expected = @now - 3.hours
reporting_period.date_time.should == DateTime.new(expected.year, expecte…
end
it 'should return a reporting period with the date part of (DateTime.now -…
- reporting_period = Simplabs::ReportsAsSparkline::ReportingPeriod.first(S…
+ reporting_period = Saulabs::ReportsAsSparkline::ReportingPeriod.first(Sa…
expected = @now - 3.days
reporting_period.date_time.should == Date.new(expected.year, expected.mo…
@@ -318,14 +318,14 @@ describe Simplabs::ReportsAsSparkline::ReportingPeriod do
it 'should return a reporting period with the date of the first day of the…
DateTime.stub!(:now).and_return(DateTime.new(2008, 12, 31, 0, 0, 0))
- reporting_period = Simplabs::ReportsAsSparkline::ReportingPeriod.first(S…
+ reporting_period = Saulabs::ReportsAsSparkline::ReportingPeriod.first(Sa…
reporting_period.date_time.should == DateTime.new(2008, 9, 1)
end
it 'should return a reporting period with the date of the monday of the we…
DateTime.stub!(:now).and_return(DateTime.new(2008, 12, 31, 0, 0, 0)) #we…
- reporting_period = Simplabs::ReportsAsSparkline::ReportingPeriod.first(S…
+ reporting_period = Saulabs::ReportsAsSparkline::ReportingPeriod.first(Sa…
reporting_period.date_time.should == DateTime.new(2008, 12, 8) #the mond…
end
diff --git a/spec/other/report_method_spec.rb b/spec/other/report_method_spec.rb
@@ -1,6 +1,6 @@
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
-describe Simplabs::ReportsAsSparkline do
+describe Saulabs::ReportsAsSparkline do
describe 'for inherited models' do
@@ -32,7 +32,7 @@ describe Simplabs::ReportsAsSparkline do
end
after do
- Simplabs::ReportsAsSparkline::ReportCache.destroy_all
+ Saulabs::ReportsAsSparkline::ReportCache.destroy_all
end
end
diff --git a/spec/other/sparkline_tag_helper_spec.rb b/spec/other/sparkline_tag…
@@ -1,6 +1,6 @@
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
-describe Simplabs::ReportsAsSparkline::SparklineTagHelper do
+describe Saulabs::ReportsAsSparkline::SparklineTagHelper do
before do
@helper = TestHelper.new
@@ -41,6 +41,6 @@ end
class TestHelper
- include Simplabs::ReportsAsSparkline::SparklineTagHelper
+ include Saulabs::ReportsAsSparkline::SparklineTagHelper
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.