Changeset 1289
- Timestamp:
- 03/16/08 20:31:37 (8 months ago)
- Files:
-
- ruport/trunk/examples/btree/commaleon/commaleon.rb (modified) (7 diffs)
- ruport/trunk/examples/centered_pdf_text_box.rb (modified) (2 diffs)
- ruport/trunk/examples/line_plotter.rb (modified) (1 diff)
- ruport/trunk/examples/pdf_report_with_common_base.rb (modified) (4 diffs)
- ruport/trunk/examples/png_embed.rb (modified) (4 diffs)
- ruport/trunk/examples/row_renderer.rb (modified) (1 diff)
- ruport/trunk/examples/simple_pdf_lines.rb (modified) (1 diff)
- ruport/trunk/examples/trac_ticket_status.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
ruport/trunk/examples/btree/commaleon/commaleon.rb
r1083 r1289 11 11 # about new records ) 12 12 # 13 # It's a camping app, but the core of it is a renderer/formatter combo.13 # It's a camping app, but the core of it is a controller/formatter combo. 14 14 # (Marked by %%%%%%%%%%% below) 15 15 # … … 52 52 # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 53 53 # This is the bulk of the Ruport code in this app 54 # (CSVDiff Renderer and CSVDiffFormatter)54 # (CSVDiffController and CSVDiffFormatter) 55 55 # The rest is just camping. The interesting thing here is that 56 56 # you could easily define these in another file and just require … … 58 58 # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 59 59 60 class CSVDiff Renderer < Ruport::Renderer60 class CSVDiffController < Ruport::Controller 61 61 stage :diff_report 62 62 option :key, :mcsv, :ccsv … … 66 66 # rendering task to the formatters. 67 67 # 68 # We're using grouping mainly for the renderer support,68 # We're using grouping mainly for the controller support, 69 69 # and rather than reducing a table, we're building up the 70 70 # group objects via the helper methods missing_from_compare … … 134 134 # http://stonecode.svnrepository.com/ruport/trac.cgi/wiki/F 135 135 # 136 class CSVDiffFormatter < F([:html,:text,:csv,:pdf], :for => CSVDiff Renderer)136 class CSVDiffFormatter < F([:html,:text,:csv,:pdf], :for => CSVDiffController) 137 137 def build_diff_report 138 138 # this is using the selective blocks for formatters that implement … … 184 184 def post 185 185 @state.key = @input.csv_id 186 @table = CSVDiff Renderer.render_html(:key => @state.key,186 @table = CSVDiffController.render_html(:key => @state.key, 187 187 :mcsv => @state.mfile, 188 188 :ccsv => @state.cfile ) … … 208 208 case(format) 209 209 when "csv" 210 text CSVDiff Renderer.render_csv(options)210 text CSVDiffController.render_csv(options) 211 211 when "pdf" 212 text CSVDiff Renderer.render_pdf(options.merge(:style => :justified))212 text CSVDiffController.render_pdf(options.merge(:style => :justified)) 213 213 when "txt" 214 text CSVDiff Renderer.render_text(options)214 text CSVDiffController.render_text(options) 215 215 else 216 216 text "no format!" ruport/trunk/examples/centered_pdf_text_box.rb
r1210 r1289 1 1 require "ruport" 2 2 3 # Renderers can be though of as control classes or interface builders.3 # Controllers can be though of as control classes or interface builders. 4 4 # Essentially, they define the options that formatters should implement 5 5 # and the stages of rendering they should handle. Ruport's formatting 6 # system is very forgiving, and the renderers do not force their6 # system is very forgiving, and the controllers do not force their 7 7 # specs onto formatters that are attached to them. 8 8 # 9 class Document < Ruport:: Renderer9 class Document < Ruport::Controller 10 10 11 11 # Will throw an error if these options are not set at rendering time 12 12 required_option :text, :author 13 13 14 # The renderer will look for a build_document_body() method on the formatter,14 # The controller will look for a build_document_body() method on the formatter, 15 15 # but silently skip this stage if it is missing 16 16 stage :document_body 17 17 18 # The renderer will look for a finalize_document() method on the formatter,18 # The controller will look for a finalize_document() method on the formatter, 19 19 # but silently skip this stage if it is missing 20 20 finalize :document … … 60 60 end 61 61 62 # All options passed to a renderer will be written onto the options object.62 # All options passed to a controller will be written onto the options object. 63 63 # In the block form, you may use explicit accessors 64 64 # (i.e. r.text instead of r.options.text ) for only things that have 65 65 # either been defined with option / required_option methods, 66 # or have explicit accessors in the Renderer.66 # or have explicit accessors in the Controller. 67 67 # 68 68 a = Document.render_pdf( :heading => "a good quote", ruport/trunk/examples/line_plotter.rb
r930 r1289 1 1 require "ruport" 2 2 3 class LinePlotter < Ruport:: Renderer3 class LinePlotter < Ruport::Controller 4 4 5 5 options do |o| ruport/trunk/examples/pdf_report_with_common_base.rb
r1224 r1289 9 9 require "ruport" 10 10 11 # only used for the titleize call in Client Renderer#setup11 # only used for the titleize call in ClientController#setup 12 12 # tweak as needed if you don't want to install AS. 13 13 require "active_support" … … 16 16 # concern of wanting to have a standard template for reports. 17 17 # 18 class Client Renderer < Ruport::Renderer18 class ClientController < Ruport::Controller 19 19 prepare :standard_report 20 20 stage :company_header, :client_header, :client_body, :client_footer … … 52 52 # 53 53 class ClientPDF < CompanyPDFBase 54 renders :pdf, :for => Client Renderer54 renders :pdf, :for => ClientController 55 55 56 56 def build_client_header … … 69 69 70 70 File.open("example.pdf","w") do |f| 71 f << Client Renderer.render_pdf(:data => table,:example => "apple")71 f << ClientController.render_pdf(:data => table,:example => "apple") 72 72 end ruport/trunk/examples/png_embed.rb
r1224 r1289 2 2 require "ruport" 3 3 4 class Roadmap Renderer < Ruport::Renderer4 class RoadmapController < Ruport::Controller 5 5 stage :roadmap_image, :roadmap_text_body 6 6 finalize :roadmap … … 9 9 class HTMLRoadmap < Ruport::Formatter 10 10 11 renders :html, :for => Roadmap Renderer11 renders :html, :for => RoadmapController 12 12 13 13 def layout … … 29 29 class PDFRoadmap < Ruport::Formatter::PDF 30 30 31 renders :pdf, :for => Roadmap Renderer31 renders :pdf, :for => RoadmapController 32 32 33 33 def build_roadmap_image … … 50 50 formats = [:html, :pdf] 51 51 formats.each do |format| 52 Roadmap Renderer.render(format, :image_file => "roadmap.png",52 RoadmapController.render(format, :image_file => "roadmap.png", 53 53 :file => "roadmap.#{format}") 54 54 end ruport/trunk/examples/row_renderer.rb
r1250 r1289 1 1 require "ruport" 2 2 3 class CSV2Something < Ruport:: Renderer3 class CSV2Something < Ruport::Controller 4 4 required_option :csv_file 5 5 stage :table_body ruport/trunk/examples/simple_pdf_lines.rb
r933 r1289 3 3 # draws pretty little lines all over the place on a PDF 4 4 5 class SimpleLines < Ruport:: Renderer5 class SimpleLines < Ruport::Controller 6 6 stage :horizontal_lines 7 7 end ruport/trunk/examples/trac_ticket_status.rb
r1139 r1289 3 3 class TracSummaryReport 4 4 5 include Ruport:: Renderer::Hooks5 include Ruport::Controller::Hooks 6 6 7 7 renders_as_table
