require 'rubygems'
require 'ruport'
require 'ruport/util'
require 'date'
require 'optparse'


opts = OptionParser.new do |opts|
 opts.on("-h", "--help", "Displays this help.") do |a|
  puts opts
 end
 opts.on("-s", "--startdate", "Determines what start date to use.") do
|b|
  @startdate = Date.new(*ParseDate.parsedate(b)[0,3])
 end
 opts.on("-e", "--enddate", "Determines what end date to use.") do |c|
  @enddate = Date.new(*ParseDate.parsedate(c)[0,3])
 end
 opts.on("-o", "--output", "Specify Output format: svg|pdf|jpg") do |d|
  if ARGV = svg
    saveinput = GraphReport.generate{|r| r.save_as("Reportgraph.svg")}
  elsif ARGV = pdf
    #get pdf gem to output to pdf(ruport might have it included)
 end
end
end

opts.parse!(ARGV)

result = (@startdate..@enddate).to_a
range = result.size

class GraphReport < Ruport::Report
  renders_as_graph

 def generate

verizondat = []
qwestdat = []
level3dat = []
attdat = []
sprintdat = []
   data = File.readlines("data.csv")
   head = data[0]
   verizondat = data.grep(/Verizon/)
   qwestdat = data.grep(/Qwest/)
   level3dat = data.grep(/Level3/)
   attdat = data.grep(/AT\&T/)
   sprintdat = data.grep(/Sprint/)
   csv = ([head] + data).join

   table = Ruport::Data::Table.parse(csv)

 graph = Ruport::Graph(:column_names => #the 15 graph points by average

   graph.add_line verizondat.column('AVERAGE').map{|x|
x.grep(/@startdate..@enddate/).to_i}, :name=> "Verizon"
   graph.add_line qwestdat.column('AVERAGE').map{|x|
x.grep(/@startdate..@enddate/).to_i}, :name=> "Qwest"
   graph.add_line level3dat.column('AVERAGE').map{|x|
x.grep(/@startdate..@enddate/).to_i}, :name=> "Level3"
   graph.add_line attdat.column('AVERAGE').map{|x|
x.grep(/@startdate..@enddate/).to_i}, :name=> "AT&T"
   graph.add_line sprintdat.column('AVERAGE').map{|x|
x.grep(/@startdate..@enddate/).to_i}, :name=> "Sprint"
end
end

   return graph



GraphReport.generate{|r| r.save_as("graph.svg")}

##############
OUTPUT:

ruby reportgraph.rb
reportgraph.rb:55: syntax error, unexpected tIDENTIFIER, expecting ')'
   graph.add_line verizondat.column('AVERAGE').map{|x|
x.grep(/@startdate..@enddate/).to_i}, :name=> "Verizon"
                            ^
reportgraph.rb:55: syntax error, unexpected ',', expecting kEND
   graph.add_line verizondat.column('AVERAGE').map{|x|
x.grep(/@startdate..@enddate/).to_i}, :name=> "Verizon"

###############

all the commented objects also need fixing if anyone wants to throw
suggestions at me while i work on it over the night.

Much thanks!
-- 
Posted via http://www.ruby-forum.com/.