coryodaniel / skeleton
- Source
- Commits
- Network (1)
- Issues (0)
- Downloads (0)
- Wiki (1)
- Graphs
-
Branch:
master
Cory ODaniel (author)
Mon Sep 21 16:31:10 -0700 2009
skeleton /
| name | age | message | |
|---|---|---|---|
| |
CHANGELOG | ||
| |
README.markdown | ||
| |
Rakefile | ||
| |
lib/ | ||
| |
skeleton.gemspec | ||
| |
spec/ | ||
| |
tasks/ |
README.markdown
Skeleton is a super simply report generation and linking gem.
Usage
# gem sources -a http://gems.github.com
# gem install coryodaniel-skeleton
require 'rubygems'
require 'skeleton'
# Create a report
class FavoriteColorDetailedReport
include Skeleton::Report
report_name "Demographics for people that like %s"
column :age
column :gender
column :location
def initialize(color,people)
report_name_addl << color
people.each do |person|
rows << Skeleton::Row.new({
:age => person.age,
:gender => person.gender,
:location => person.location
})
end
end
end
class FavoriteColorAggregateReport
include Skeleton::Report
report_name
# Define the columns in your report
column :color
column :frequency
column :details
# create an constructor to set up your data
def initialize
color_data = %w(red orange yellow green blue purple black white brown grey)
# for this example we'll pretend we have a DataMapper/ActiveRecord table containing the data
color_data.each do |color|
people = People.all(:favorite_color => color)
# rows is an accessor for attaching rows to this report
rows << Skeleton::Row.new({
:color => color,
:frequency => people.length,
# Attach a detailed report to the 'details' field.
:details => FavoriteColorDetailedReport.new(color, people)
})
end #end color_data loop
end #end initialize
end
FavoriteColorAggregateReport.new.generate(:index => true) #:index makes it the index file.

