For as long as I can remember the end of the summer meant slaving over
some Free Software project before I went back to school.  This year
will be no exception.  I am currently trying to develop and mature a
pure ruby reporting tool based on a very clever hack that James Edward
Gray II shared with me (along with some great ideas).  Basically, I am
trying to make a tool that will allow you to run queries against a
database and then get them to painless output to basically whatever
format you'd like weilding the power of Erb and other great tools such
as PDF::Writer.  So far, the system I have built is functional but far
from robust.  It allows you to execute SQL statements passed as
strings, passed in from files, or even passed in from the database
itself and then gives you a row by row iterator which can be called
from within a template OR a pure ruby file.  I am also currently
working on implementing a simple DSL wrapper around SQL to allow easy
generation of queries.  I have a few ideas for functions I'd like to
add, but I figured the best bet would be to ask the community what
kinds of features they'd like to see in a pure ruby report generation
tool.  If you let me know what you'd like to see in such a tool soon,
there is a good chance it will end up in Ruport 0.1.0 ([Ru]by
Re[port]s) which will be released on August 28th on RubyForge.  So...
if you had your ideal reporting tool in Ruby, what would it be like?

My job is paying me to work on this project despite the fact that it is
under the GPL, therefore the more requests you make, the longer I can
justify working on this instead of the (gulp) .Net system they've been
developing.

 Below I've posted a little snippet of Ruport calling a query out of
the database itself (config and query not shown) and then generating a
PDF.  This is actual functional code which prints out customer labels.

Also... scouts honor on a first release of Gambit (The game design
software James and I built) before the end of the summer.

With no further ado, a (rudimentary) Ruport example.


require 'pdf/writer'
 pdf = PDF::Writer.new
 pdf.select_font "Times-Roman"
 pdf.margins_mm(12,0,20,0)
 pdf.start_columns(3,27)
 sql_stored( "RUPORT_QUERIES", "RECALL") do |row|
 	row["DUEDATE"] = row["DUEDATE"].to_s.slice( 0 .. 9)
 	row["ZIP"] = row["ZIP"].to_s.slice(0..4)
   pdf.start_new_page if pdf.lines_remaining < 5
   pdf.text "Due: #{row["DUEDATE"]}\n" +
           "#{row["FIRSTNAME"]} #{row["LASTNAME"]}\n" +
           "#{row["STREET1"]}\n" +
			( row["STREET2"].eql?("") ? "" : row["STREET2"] + "\n" ) +
			"#{row["CITY"]}, #{row["STATE"]} #{row["ZIP"]}\n\n" +
			( row["STREET2"].eql?("") ? "\n" : "" ),
			:font_size => 11, :justification => :full
 end
<%= pdf.render %>