Skip to content

Commit

Permalink
prepare docs and gemspec
Browse files Browse the repository at this point in the history
  • Loading branch information
seamusabshere committed Jul 4, 2012
1 parent 7a1c49f commit 0e2c945
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .yardopts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--no-private
--readme README.md
92 changes: 91 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,96 @@
# Report

DSL for creating CSV, XLSX, and PDF reports in Ruby.
DSL for creating clean CSV, XLSX, and PDF reports in Ruby.

Extracted from Brighter Planet's corporate reporting system.

## Usage

class FleetReport < Report
attr_reader :batchfile

def initialize(batchfile)
@batchfile = batchfile
end

def description
'Fleet sustainability report'
end

def vehicles(type)
@batchfile.vehicles.where(:type => type)
end
table 'Cars' do
head do
row 'Report type', :description
row 'Batchfile', :batchfile
end
body do
rows :vehicles, ['car']
column 'Vehicle ID', :id
column 'CO2 score', :carbon
column 'CO2 units', 'kg'
column 'Fuel grade'
column 'Fuel volume'
column 'Odometer'
column 'City'
column 'State'
column 'Postal code', :zip_code
column 'Country'
column 'Methodology'
end
end

table 'Trucks' do
head do
row 'Report type', :description
row 'Batchfile', :batchfile
end
body do
rows :vehicles, ['truck']
column 'Vehicle ID', :id
column 'CO2 score', :carbon
column 'CO2 units', 'kg'
column 'Fuel grade'
column 'Fuel volume'
column 'Odometer'
column 'City'
column 'State'
column 'Postal code', :zip_code
column 'Country'
column 'Methodology'
end
end

format_pdf(
:document => { :page_layout => :landscape },
:head => {:width => (10*72)},
:body => {:width => (10*72), :header => true}
)

format_xlsx do |xlsx|
xlsx.header.right.contents = 'Corporate Reporting Program'
xlsx.page_setup.top = 1.5
xlsx.page_setup.header = 0
xlsx.page_setup.footer = 0
end
end

b = Batchfile.first
fr = FleetReport.new(b)
fr.pdf.path
fr.csv.paths # note one file per table
fr.xlsx.path

## Real-world usage

<p><a href="http://brighterplanet.com"><img src="https://s3.amazonaws.com/static.brighterplanet.com/assets/logos/flush-left/inline/green/rasterized/brighter_planet-160-transparent.png" alt="Brighter Planet logo"/></a></p>

We use `report` for [corporate reporting products at Brighter Planet](http://brighterplanet.com/research) and in production at

* [Brighter Planet's impact estimate web service](http://impact.brighterplanet.com)
* [Brighter Planet's reference data web service](http://data.brighterplanet.com)

## Inspirations

Expand Down
3 changes: 3 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)

task :default => :spec

require 'yard'
YARD::Rake::YardocTask.new
10 changes: 6 additions & 4 deletions report.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ require File.expand_path('../lib/report/version', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["Seamus Abshere"]
gem.email = ["seamus@abshere.net"]
gem.description = %q{TODO: Write a gem description}
gem.summary = %q{TODO: Write a gem summary}
gem.homepage = ""
d = %q{DSL for creating clean CSV, XLSX, and PDF reports in Ruby. Extracted from Brighter Planet's corporate reporting system.}
gem.description = d
gem.summary = d
gem.homepage = "https://github.com/seamusabshere/report"

gem.files = `git ls-files`.split($\)
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
# gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
gem.name = "report"
gem.require_paths = ["lib"]
Expand All @@ -23,4 +24,5 @@ Gem::Specification.new do |gem|
gem.add_development_dependency 'rspec'
gem.add_development_dependency 'remote_table'
gem.add_development_dependency 'unix_utils'
gem.add_development_dependency 'yard'
end

0 comments on commit 0e2c945

Please sign in to comment.