updated documentation - reportable - Fork of reportable required by WarVox, from hdm/reportable.
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
---
(DIR) commit 1553007ee04f6544b5a9771bcb687630666474af
(DIR) parent 3766a5046d1c774ed50b4471c88f261839536c27
(HTM) Author: Marco Otte-Witte <marco.otte-witte@simplabs.com>
Date: Thu, 15 Jan 2009 11:37:07 +0100
updated documentation
Diffstat:
M README.rdoc | 32 +++++++++++++++++++++++++++----
M lib/kvlr/reports_as_sparkline/repo… | 2 +-
M rdoc/created.rid | 2 +-
M rdoc/files/README_rdoc.html | 72 ++++++++++++++++++++++++++++---
M rdoc/files/lib/kvlr/reports_as_spa… | 2 +-
M rdoc/files/lib/kvlr/reports_as_spa… | 2 +-
M rdoc/files/lib/kvlr/reports_as_spa… | 2 +-
M rdoc/files/lib/kvlr/reports_as_spa… | 2 +-
M rdoc/files/lib/kvlr/reports_as_spa… | 2 +-
M rdoc/files/lib/kvlr/reports_as_spa… | 2 +-
M rdoc/files/lib/kvlr/reports_as_spa… | 2 +-
11 files changed, 102 insertions(+), 20 deletions(-)
---
(DIR) diff --git a/README.rdoc b/README.rdoc
@@ -2,22 +2,46 @@
ReportsAsSparkline enables you to generate reports and sparklines from your model's data with very little effort.
-== Example
+== Usage
-This shows the basic usage. Consider the following user model, including +created_at+ and +activated_at+ timestamp fields.
+If you hace a +User+ model with +created_at+ and +activated_at+ columns, you can just add +reports_as_sparkline+
+to it with the following options:
+
+* :date_column - The name of the date column on that the records are aggregated
+* :value_column - The name of the column that holds the value to sum for aggregation :sum
+* :aggregation - The aggregation to use (either :count or :sum); when using :sum, :value_column must also be specified
+* :grouping - The period records are grouped on (:hour, :day, :week, :month)
+* :limit - The number of periods to get (see :grouping)
+* :conditions - Conditions like in ActiveRecord::Base#find; only records that match there conditions are reported on
+* :cumulate - Sets whether to cumulate the numbers (instead of [1, 2, 3] returns [1, 3, 6])
+
+<b>Example:</b>
class User < ActiveRecord::Base
reports_as_sparkline :registrations
reports_as_sparkline :activations, :date_column => :activated_at
reports_as_sparkline :total_users, :cumulate => true
- end
+ end
-Using +reports_as_sparkline+ like this will add the following class methods to your User model:
+This will add the following class methods to your User model:
User.registrations_report
User.activations_report
User.total_users_report
+When invoking the report, you can override some of the options you specified for +reports_as_sparkline+:
+
+* :grouping - The period records are grouped on (:hour, :day, :week, :month)
+* :limit - The number of periods to get (see :grouping)
+* :conditions - Conditions like in ActiveRecord::Base#find; only records that match there conditions are reported on
+
+<b>Example:</b>
+
+ User.registrations_report(:conditions => ['last_name LIKE 'A%'])
+ User.activations_report(:grouping => :week, :limit => 5)
+
+<b>Beware that when specifying conditions on invocation of the report, the cache will not be used!</b>
+
You can than render sparklines for these reports with sparkline_tag in your view:
<%= sparkline_tag(User.registrations_report) %>
(DIR) diff --git a/lib/kvlr/reports_as_sparkline/reporting_period.rb b/lib/kvlr/reports_as_sparkline/reporting_period.rb
@@ -2,7 +2,7 @@ module Kvlr #:nodoc:
module ReportsAsSparkline #:nodoc:
- # A ReportingPeriod is - depending on the Grouping - either a specific hour, a day, a month or a year. All records falling into this period will be grouped.
+ # A ReportingPeriod is - depending on the Grouping - either a specific hour, a day, a month or a year. All records falling into this period will be grouped together.
class ReportingPeriod
attr_reader :date_time, :grouping
(DIR) diff --git a/rdoc/created.rid b/rdoc/created.rid
@@ -1 +1 @@
-Wed, 14 Jan 2009 11:20:49 +0100
+Thu, 15 Jan 2009 11:34:04 +0100
(DIR) diff --git a/rdoc/files/README_rdoc.html b/rdoc/files/README_rdoc.html
@@ -56,7 +56,7 @@
</tr>
<tr class="top-aligned-row">
<td><strong>Last Update:</strong></td>
- <td>Tue Jan 13 16:47:15 +0100 2009</td>
+ <td>Thu Jan 15 11:33:40 +0100 2009</td>
</tr>
</table>
</div>
@@ -74,21 +74,52 @@
ReportsAsSparkline enables you to generate reports and sparklines from your
model‘s data with very little effort.
</p>
-<h2>Example</h2>
+<h2>Usage</h2>
<p>
-This shows the basic usage. Consider the following user model, including
-<tt>created_at</tt> and <tt>activated_at</tt> timestamp fields.
+If you hace a <tt>User</tt> model with <tt>created_at</tt> and
+<tt>activated_at</tt> columns, you can just add
+<tt>reports_as_sparkline</tt> to it with the following options:
+</p>
+<ul>
+<li>:date_column - The name of the date column on that the records are
+aggregated
+
+</li>
+<li>:value_column - The name of the column that holds the value to sum for
+aggregation :sum
+
+</li>
+<li>:aggregation - The aggregation to use (either :count or :sum); when using
+:sum, :value_column must also be specified
+
+</li>
+<li>:grouping - The period records are grouped on (:hour, :day, :week, :month)
+
+</li>
+<li>:limit - The number of periods to get (see :grouping)
+
+</li>
+<li>:conditions - Conditions like in ActiveRecord::Base#find; only records that
+match there conditions are reported on
+
+</li>
+<li>:cumulate - Sets whether to cumulate the numbers (instead of [1, 2, 3]
+returns [1, 3, 6])
+
+</li>
+</ul>
+<p>
+<b>Example:</b>
</p>
<pre>
class User < ActiveRecord::Base
reports_as_sparkline :registrations
reports_as_sparkline :activations, :date_column => :activated_at
reports_as_sparkline :total_users, :cumulate => true
- end
+ end
</pre>
<p>
-Using <tt>reports_as_sparkline</tt> like this will add the following class
-methods to your User model:
+This will add the following class methods to your User model:
</p>
<pre>
User.registrations_report
@@ -96,6 +127,33 @@ methods to your User model:
User.total_users_report
</pre>
<p>
+When invoking the report, you can override some of the options you
+specified for <tt>reports_as_sparkline</tt>:
+</p>
+<ul>
+<li>:grouping - The period records are grouped on (:hour, :day, :week, :month)
+
+</li>
+<li>:limit - The number of periods to get (see :grouping)
+
+</li>
+<li>:conditions - Conditions like in ActiveRecord::Base#find; only records that
+match there conditions are reported on
+
+</li>
+</ul>
+<p>
+<b>Example:</b>
+</p>
+<pre>
+ User.registrations_report(:conditions => ['last_name LIKE 'A%'])
+ User.activations_report(:grouping => :week, :limit => 5)
+</pre>
+<p>
+<b>Beware that when specifying conditions on invocation of the report, the
+cache will not be used!</b>
+</p>
+<p>
You can than render sparklines for these reports with sparkline_tag in your
view:
</p>
(DIR) diff --git a/rdoc/files/lib/kvlr/reports_as_sparkline/asset_tag_helper_rb.html b/rdoc/files/lib/kvlr/reports_as_sparkline/asset_tag_helper_rb.html
@@ -56,7 +56,7 @@
</tr>
<tr class="top-aligned-row">
<td><strong>Last Update:</strong></td>
- <td>Tue Jan 13 18:48:41 +0100 2009</td>
+ <td>Thu Jan 15 11:13:51 +0100 2009</td>
</tr>
</table>
</div>
(DIR) diff --git a/rdoc/files/lib/kvlr/reports_as_sparkline/cumulated_report_rb.html b/rdoc/files/lib/kvlr/reports_as_sparkline/cumulated_report_rb.html
@@ -56,7 +56,7 @@
</tr>
<tr class="top-aligned-row">
<td><strong>Last Update:</strong></td>
- <td>Tue Jan 13 18:48:41 +0100 2009</td>
+ <td>Thu Jan 15 11:13:51 +0100 2009</td>
</tr>
</table>
</div>
(DIR) diff --git a/rdoc/files/lib/kvlr/reports_as_sparkline/grouping_rb.html b/rdoc/files/lib/kvlr/reports_as_sparkline/grouping_rb.html
@@ -56,7 +56,7 @@
</tr>
<tr class="top-aligned-row">
<td><strong>Last Update:</strong></td>
- <td>Tue Jan 13 18:48:41 +0100 2009</td>
+ <td>Thu Jan 15 11:13:51 +0100 2009</td>
</tr>
</table>
</div>
(DIR) diff --git a/rdoc/files/lib/kvlr/reports_as_sparkline/report_cache_rb.html b/rdoc/files/lib/kvlr/reports_as_sparkline/report_cache_rb.html
@@ -56,7 +56,7 @@
</tr>
<tr class="top-aligned-row">
<td><strong>Last Update:</strong></td>
- <td>Wed Jan 14 11:14:28 +0100 2009</td>
+ <td>Thu Jan 15 11:13:51 +0100 2009</td>
</tr>
</table>
</div>
(DIR) diff --git a/rdoc/files/lib/kvlr/reports_as_sparkline/report_rb.html b/rdoc/files/lib/kvlr/reports_as_sparkline/report_rb.html
@@ -56,7 +56,7 @@
</tr>
<tr class="top-aligned-row">
<td><strong>Last Update:</strong></td>
- <td>Tue Jan 13 18:48:41 +0100 2009</td>
+ <td>Thu Jan 15 11:13:51 +0100 2009</td>
</tr>
</table>
</div>
(DIR) diff --git a/rdoc/files/lib/kvlr/reports_as_sparkline/reporting_period_rb.html b/rdoc/files/lib/kvlr/reports_as_sparkline/reporting_period_rb.html
@@ -56,7 +56,7 @@
</tr>
<tr class="top-aligned-row">
<td><strong>Last Update:</strong></td>
- <td>Tue Jan 13 18:48:41 +0100 2009</td>
+ <td>Thu Jan 15 11:13:51 +0100 2009</td>
</tr>
</table>
</div>
(DIR) diff --git a/rdoc/files/lib/kvlr/reports_as_sparkline_rb.html b/rdoc/files/lib/kvlr/reports_as_sparkline_rb.html
@@ -56,7 +56,7 @@
</tr>
<tr class="top-aligned-row">
<td><strong>Last Update:</strong></td>
- <td>Tue Jan 13 12:14:34 +0100 2009</td>
+ <td>Thu Jan 15 11:13:51 +0100 2009</td>
</tr>
</table>
</div>