ruport 0.8.14 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. data/README +42 -107
  2. data/Rakefile +29 -32
  3. data/examples/centered_pdf_text_box.rb +13 -19
  4. data/examples/example.csv +3 -0
  5. data/examples/line_plotter.rb +15 -15
  6. data/examples/pdf_complex_report.rb +10 -23
  7. data/examples/pdf_table_with_title.rb +12 -12
  8. data/examples/rope_examples/itunes/Rakefile +22 -1
  9. data/examples/rope_examples/itunes/config/environment.rb +4 -0
  10. data/examples/rope_examples/itunes/lib/init.rb +32 -2
  11. data/examples/rope_examples/itunes/util/build +50 -16
  12. data/examples/rope_examples/sales_report/README +1 -1
  13. data/examples/rope_examples/sales_report/Rakefile +22 -1
  14. data/examples/rope_examples/sales_report/config/environment.rb +4 -0
  15. data/examples/rope_examples/sales_report/lib/init.rb +32 -2
  16. data/examples/rope_examples/sales_report/lib/reports/sales.rb +10 -16
  17. data/examples/rope_examples/sales_report/util/build +50 -16
  18. data/examples/row_renderer.rb +39 -0
  19. data/examples/ruport_list/png_embed.rb +61 -0
  20. data/examples/ruport_list/roadmap.png +0 -0
  21. data/examples/sample.rb +16 -0
  22. data/examples/simple_pdf_lines.rb +24 -0
  23. data/lib/ruport.rb +143 -57
  24. data/lib/ruport/acts_as_reportable.rb +246 -0
  25. data/lib/ruport/data.rb +1 -2
  26. data/lib/ruport/data/grouping.rb +311 -0
  27. data/lib/ruport/data/record.rb +113 -84
  28. data/lib/ruport/data/table.rb +275 -174
  29. data/lib/ruport/formatter.rb +149 -0
  30. data/lib/ruport/formatter/csv.rb +87 -0
  31. data/lib/ruport/formatter/html.rb +89 -0
  32. data/lib/ruport/formatter/pdf.rb +357 -0
  33. data/lib/ruport/formatter/text.rb +151 -0
  34. data/lib/ruport/generator.rb +127 -30
  35. data/lib/ruport/query.rb +46 -99
  36. data/lib/ruport/renderer.rb +238 -194
  37. data/lib/ruport/renderer/grouping.rb +67 -0
  38. data/lib/ruport/renderer/table.rb +25 -98
  39. data/lib/ruport/report.rb +45 -96
  40. data/test/acts_as_reportable_test.rb +229 -0
  41. data/test/csv_formatter_test.rb +97 -0
  42. data/test/{_test_database.rb → database_test_.rb} +0 -0
  43. data/test/grouping_test.rb +305 -0
  44. data/test/html_formatter_test.rb +104 -0
  45. data/test/pdf_formatter_test.rb +25 -0
  46. data/test/{test_query.rb → query_test.rb} +32 -121
  47. data/test/{test_record.rb → record_test.rb} +40 -23
  48. data/test/renderer_test.rb +344 -0
  49. data/test/{test_report.rb → report_test.rb} +74 -44
  50. data/test/samples/ticket_count.csv +124 -0
  51. data/test/{test_sql_split.rb → sql_split_test.rb} +0 -0
  52. data/test/{test_table.rb → table_test.rb} +255 -44
  53. data/test/text_formatter_test.rb +144 -0
  54. data/util/bench/data/record/bench_as_vs_to.rb +17 -0
  55. data/util/bench/data/record/bench_constructor.rb +46 -0
  56. data/util/bench/data/record/bench_indexing.rb +65 -0
  57. data/util/bench/data/record/bench_reorder.rb +35 -0
  58. data/util/bench/data/record/bench_to_a.rb +19 -0
  59. data/util/bench/data/table/bench_column_manip.rb +103 -0
  60. data/util/bench/data/table/bench_dup.rb +24 -0
  61. data/util/bench/data/table/bench_init.rb +67 -0
  62. data/util/bench/data/table/bench_manip.rb +125 -0
  63. data/util/bench/formatter/bench_csv.rb +14 -0
  64. data/util/bench/formatter/bench_html.rb +14 -0
  65. data/util/bench/formatter/bench_pdf.rb +14 -0
  66. data/util/bench/formatter/bench_text.rb +14 -0
  67. data/util/bench/samples/tattle.csv +1237 -0
  68. metadata +121 -143
  69. data/TODO +0 -21
  70. data/examples/invoice.rb +0 -142
  71. data/examples/invoice_report.rb +0 -29
  72. data/examples/line_graph.rb +0 -38
  73. data/examples/rope_examples/itunes/config/ruport_config.rb +0 -8
  74. data/examples/rope_examples/sales_report/config/ruport_config.rb +0 -8
  75. data/lib/ruport/attempt.rb +0 -63
  76. data/lib/ruport/config.rb +0 -204
  77. data/lib/ruport/data/groupable.rb +0 -93
  78. data/lib/ruport/data/taggable.rb +0 -80
  79. data/lib/ruport/format.rb +0 -1
  80. data/lib/ruport/format/csv.rb +0 -29
  81. data/lib/ruport/format/html.rb +0 -42
  82. data/lib/ruport/format/latex.rb +0 -47
  83. data/lib/ruport/format/pdf.rb +0 -233
  84. data/lib/ruport/format/plugin.rb +0 -31
  85. data/lib/ruport/format/svg.rb +0 -60
  86. data/lib/ruport/format/text.rb +0 -103
  87. data/lib/ruport/format/xml.rb +0 -32
  88. data/lib/ruport/layout.rb +0 -1
  89. data/lib/ruport/layout/component.rb +0 -7
  90. data/lib/ruport/mailer.rb +0 -99
  91. data/lib/ruport/renderer/graph.rb +0 -46
  92. data/lib/ruport/report/graph.rb +0 -14
  93. data/lib/ruport/system_extensions.rb +0 -71
  94. data/test/test_config.rb +0 -88
  95. data/test/test_format_text.rb +0 -63
  96. data/test/test_graph_renderer.rb +0 -97
  97. data/test/test_groupable.rb +0 -56
  98. data/test/test_mailer.rb +0 -170
  99. data/test/test_renderer.rb +0 -151
  100. data/test/test_ruport.rb +0 -58
  101. data/test/test_table_renderer.rb +0 -141
  102. data/test/test_taggable.rb +0 -52
data/README CHANGED
@@ -1,106 +1,64 @@
1
1
  # ------------------------------------------------------------------------
2
- # -------------------------------------------------------------------------
3
- #
4
- # NOTE:
5
- #
6
- # The most up to date information can be found at:
7
- # http://reporting.stonecode.org
8
- #
9
2
  # Contents:
10
3
  #
11
- # - What Ruport Is.
4
+ # - What Ruport Is
12
5
  # - Installation
13
- # - Getting Started
14
- # - Caveats.
15
6
  # - Resources
16
- # - Background and Summary
17
- #
18
- # = What Ruport Is.
7
+ # - Hacking
19
8
  #
20
- # Ruby Reports is a software library that aims to make the task of reporting
21
- # less tedious and painful. It provides tools for data acquisition, database
22
- # interaction, formatting, and parsing/munging. Designed to be extensible,
23
- # it is possible to use Ruport for quick specific tasks as well as to build
24
- # robust reporting applications.
9
+ # = What Ruport Is
25
10
  #
26
- # = Installation
11
+ # Ruby Reports (Ruport) is an extensible reporting system.
12
+ #
13
+ # It aims to be as lightweight as possible while still providing core support
14
+ # for data aggregation and manipulation as well as multi-format rendering
15
+ # of reports.
27
16
  #
28
- # Dependencies:
29
- #
30
- # Ruport has a number of dependencies.
31
- #
32
- # Ruby/DBI and appropriate dbds: Makes Query useable
33
- # (must be installed manually)
17
+ # Ruport provides tools for using a number of data sources, including CSV files,
18
+ # ActiveRecord models, and raw SQL connections via RubyDBI.
34
19
  #
35
- # FasterCSV: Enables fast CSV parsing
36
- # (available via rubygems)
37
- #
38
- # RedCloth: Enables textile/markdown filtering
39
- # (available via rubygems)
40
- #
41
- # PDF::Writer: Enables printable documents
42
- # (available via rubygems)
20
+ # Data manipulation is easy as there are standard structures that support
21
+ # record, table, and grouping operations. These all can be extended to
22
+ # implement custom behavior as needed.
43
23
  #
44
- # MailFactory: For email support.
45
- # (available via rubygems)
24
+ # For common tasks, Ruport provides formatters for CSV, HTML, PDF, and text-
25
+ # based reports. However, the real power lies in building custom renderers and
26
+ # formatters. The base formatting libraries provide a number of helper
27
+ # functions that will let you build complex reports while maintaining a DRY and
28
+ # consistent interface.
46
29
  #
47
- # Scruffy: For Graph Support
48
- # (available via rubygems)
30
+ # Since Ruport's core support is intentionally minimalistic, you may be looking
31
+ # for some higher level support for specific needs such as graphing, invoices,
32
+ # report mailing support, etc. For this, you may wish to take a look at the
33
+ # ruport-util package, which contains some generally useful tools and libraries
34
+ # to extend Ruport's capabilities.
49
35
  #
50
- # Note that by installing any of the dependencies, either via gems or manually,
51
- # their functionality will automatically be enabled.
36
+ # = Installation
52
37
  #
53
38
  # To install ruport via rubygems with all it's dependencies (except DBI):
54
39
  #
55
40
  # sudo gem install ruport -y
56
41
  #
57
- # To install ruport manually via setup.rb:
58
- #
59
- # sudo ruby setup.rb
60
- #
61
- # To not install ruport at all:
62
- #
63
- # ruby -Ipath/to/ruport/lib my_script.rb
64
- #
65
42
  # Check to see if it installed properly:
66
43
  #
67
44
  # ruby -rubygems -e "require 'ruport'; puts Ruport::VERSION"
68
- # (omit the -rubygems flag if installed manually)
69
45
  #
70
46
  # If you get an error, please consult the mailing list.
71
47
  #
72
- # = Getting Started
73
- #
74
- # Building a report can be broadly broken up into two phases.
48
+ # Dependencies Details:
49
+ #
50
+ # -- formatting
75
51
  #
76
- # == Data Collection and Manipulation
77
- #
78
- # To begin, your data must be read from its source and stored in Ruport's
79
- # standard data structures. Ruport::Data::Table and Ruport::Data::Record
80
- # have further information on how to work with with
81
- # and store data in ruport.
52
+ # Ruport relies on PDF::Writer and FasterCSV for its formatting support.
53
+ # If you want to make use of textile helpers, you'll also need RedCloth
82
54
  #
83
- # If you wish to retrieve your data using Ruby on Rails and ActiveRecord,
84
- # please see the acts_as_reportable plugin.
85
- #
86
- # == Report Generation
87
- #
88
- # Once the data is ready, it can be rendered using a combination of
89
- # Ruport::Renderer and Ruport::Format::Plugin.
90
- # The renderer defines the report type (tablular, graph, etc), and
91
- # the plugin renders the engine into a final format (PDF, CSV, HTML, SVG).
92
- # Renderers will often interact with more than one plugin, to allow the same
93
- # report to be rendered in multiple ways ie. as HTML and a PDF.
94
- #
95
- # To tie these together, a basic DSL is provided by Ruport::Report
55
+ # -- database interaction
96
56
  #
97
- # For further reading and specific examples, please explore the examples/
98
- # directory in the source tree.
57
+ # If you wish to use Ruport to report against a rails project,
58
+ # a camping project, or do standalone AAR reports, you'll need ActiveRecord.
99
59
  #
100
- # = Bug Reports / Feature Requests
101
- #
102
- # Our Trac is at: http://code.stonecode.org
103
- # You may use the username ruport and password blinky to file tickets
60
+ # If you want to use Ruport::Query for raw SQL support, you'll need to
61
+ # install RubyDBI and whatever database drivers you might need.
104
62
  #
105
63
  # = Resources
106
64
  #
@@ -108,40 +66,17 @@
108
66
  # This software is on the move, so the list is the most reliable way of getting
109
67
  # up to date information.
110
68
  #
111
- # - You can sign up and/or view the archives here:
69
+ # - You can sign up and/or view the archives here:
112
70
  # http://groups.google.com/group/ruby-reports
113
71
  #
114
- # Please do not hesitate to use this list! I am happily accepting patches and
115
- # documentation, as well as encouraging design discussions and also am quite
116
- # curious about what people use or want to use ruport for.
117
- #
118
- # I will announce Ruport releases on RubyTalk, on the Ruport mailing list, on
119
- # Freshmeat, and RAA. If you would like to
120
- # keep an eye out for releases, please monitor one of those places.
121
- #
122
- # - You may download Ruport's source from the project page:
123
- # http://rubyforge.org/projects/ruport
124
- #
125
- # - The latest stable API documentation is available at:
72
+ # - The latest stable API documentation is available at:
126
73
  # http://api.rubyreports.org
127
74
  #
128
- # There are also some tutorial available:
129
- # http://stonecode.svnrepository.com/ruport/trac.cgi/wiki/TutorialsAndArticles
130
- #
131
- # If you are interested in developing Ruport, please *never* study code in
132
- # official releases. As this software is in it's early stages, it's essential
133
- # to keep an eye on the subversion repository. If you let me know you are
134
- # interested in working on something, I will let you know if I'm actively
135
- # working on that section.
136
- #
137
- # - Grabbing the code from the svn trunk is simple:
138
- #
139
- # svn co svn://rubyforge.org//var/svn/ruport/trunk/ ruport
140
- #
141
- # - Or if you are interested in the latest updates to the stable branch
142
- #
143
- # svn co svn://rubyforge.org//var/svn/ruport/branches/stable ruport
75
+ # - Our Trac is at: http://code.stonecode.org
76
+ # You may use the username ruport and password blinky to file tickets
144
77
  #
145
- # Thanks for checking out Ruport!
78
+ # = Hacking
146
79
  #
147
- # If you have any questions or concerns, hop on the mailing list and fire away!
80
+ # If you'd like to work on Ruport, please post on the list and let us know what
81
+ # you're interested in doing, or contact Gregory Brown or Michael Milner if you
82
+ # have questions.
data/Rakefile CHANGED
@@ -2,53 +2,42 @@ require "rake/rdoctask"
2
2
  require "rake/testtask"
3
3
  require "rake/gempackagetask"
4
4
 
5
+
6
+ RUPORT_VERSION = "0.10.0"
7
+
5
8
  begin
6
9
  require "rubygems"
7
10
  rescue LoadError
8
11
  nil
9
12
  end
10
13
 
11
- RUPORT_VERSION = "0.8.14"
12
-
13
- #Set to true to disable dependency resolution
14
- LEAN=false
15
- dir = File.dirname(__FILE__)
16
- lib = File.join(dir, "lib", "ruport.rb")
17
- version = File.read(lib)[/^\s*VERSION\s*=\s*(['"])(\d+\.\d+\.d+)['"]/,1]
18
14
  task :default => [:test]
19
15
 
20
16
  Rake::TestTask.new do |test|
21
17
  test.libs << "test"
22
- test.test_files = Dir[ "test/test_*.rb" ]
18
+ test.test_files = Dir[ "test/*_test.rb" ]
23
19
  test.verbose = true
24
20
  end
25
21
 
26
22
  spec = Gem::Specification.new do |spec|
27
- spec.name = LEAN ? "lean-ruport" : "ruport"
23
+ spec.name = "ruport"
28
24
  spec.version = RUPORT_VERSION
29
25
  spec.platform = Gem::Platform::RUBY
30
26
  spec.summary = "A generalized Ruby report generation and templating engine."
31
- spec.files = Dir.glob("{examples,lib,test,bin}/**/**/*") +
27
+ spec.files = Dir.glob("{examples,lib,test,bin,util/bench}/**/**/*") +
32
28
  ["Rakefile", "setup.rb"]
33
-
34
29
  spec.require_path = "lib"
35
30
 
36
- spec.test_files = Dir[ "test/test_*.rb" ]
31
+ spec.test_files = Dir[ "test/*_test.rb" ]
37
32
  spec.bindir = "bin"
38
33
  spec.executables = FileList["rope"]
39
34
  spec.has_rdoc = true
40
- spec.extra_rdoc_files = %w{README LICENSE TODO AUTHORS}
35
+ spec.extra_rdoc_files = %w{README LICENSE AUTHORS}
41
36
  spec.rdoc_options << '--title' << 'Ruport Documentation' <<
42
37
  '--main' << 'README' << '-q'
43
- unless LEAN
44
- spec.add_dependency('fastercsv', '>= 1.1.0')
45
- spec.add_dependency('RedCloth', '>= 3.0.3')
46
- spec.add_dependency('pdf-writer', '>= 1.1.3')
47
- spec.add_dependency("mailfactory", ">= 1.2.3")
48
- spec.add_dependency('scruffy', '>= 0.2.2')
49
- spec.add_dependency('gem_plugin', '>=0.2.2')
50
- end
51
-
38
+ spec.add_dependency('transaction-simple', "=1.4.0")
39
+ spec.add_dependency('fastercsv', '>= 1.1.0')
40
+ spec.add_dependency('pdf-writer', '>= 1.1.3')
52
41
  spec.author = "Gregory Brown"
53
42
  spec.email = " gregory.t.brown@gmail.com"
54
43
  spec.rubyforge_project = "ruport"
@@ -62,7 +51,7 @@ end
62
51
 
63
52
  Rake::RDocTask.new do |rdoc|
64
53
  rdoc.rdoc_files.include( "README",
65
- "TODO", #"CHANGELOG",
54
+ #"CHANGELOG",
66
55
  "AUTHORS", "COPYING",
67
56
  "LICENSE", "lib/" )
68
57
  rdoc.main = "README"
@@ -83,19 +72,27 @@ task :build_archives => [:package,:rcov,:rdoc] do
83
72
  sh "tar cjvf ruport-#{RUPORT_VERSION}.tar.bz2 ruport-#{RUPORT_VERSION}"
84
73
  end
85
74
 
75
+ task :run_benchmarks do
76
+ files = FileList["util/bench/**/**/*.rb"]
77
+ files.sort!
78
+ files.uniq!
79
+ names = files.map { |r| r.sub("util/bench","").split("/").map { |e| e.capitalize } }
80
+ names.map! { |e| e[1..-2].join("::") + " <BENCH: #{e[-1].sub('Bench_','').sub('.rb','')}>" }
81
+ start_time = Time.now
82
+ files.zip(names).each { |f,n|
83
+ puts "\n#{n}\n\n"
84
+ sh "ruby -Ilib #{f}"
85
+ puts "\n"
86
+ }
87
+ end_time = Time.now
88
+ puts "\n** Total Run Time: #{end_time-start_time}s **"
89
+ end
90
+
86
91
  begin
87
92
  require 'rcov/rcovtask'
88
93
  Rcov::RcovTask.new do |t|
89
- t.test_files = Dir[ "test/test_*.rb" ]
94
+ t.test_files = Dir[ "test/*_test.rb" ]
90
95
  end
91
96
  rescue LoadError
92
97
  nil
93
98
  end
94
-
95
- desc "Generate Ruport Recipes. Assumes you have erb, redcloth, and htmldoc."
96
- task :cookbook do
97
- sh "erb doc/ruport_recipes.textile | redcloth >doc/temp.html"
98
- sh "htmldoc --batch doc/ruport.book" rescue nil
99
- rm "doc/temp.html"
100
- mv "out.pdf", "doc/out.pdf"
101
- end
@@ -2,8 +2,6 @@ require "ruport"
2
2
 
3
3
  class Document < Ruport::Renderer
4
4
 
5
- include Ruport::Renderer::Helpers
6
-
7
5
  required_option :text
8
6
  required_option :author
9
7
  option :heading
@@ -13,43 +11,39 @@ class Document < Ruport::Renderer
13
11
  end
14
12
 
15
13
 
16
- class CenteredPDFTextBox < Ruport::Format::PDF
14
+ class CenteredPDFTextBox < Ruport::Formatter::PDF
17
15
 
18
- Document.add_format self, :pdf
16
+ renders :pdf, :for => Document
19
17
 
20
18
  def build_document_body
21
-
22
19
  add_text "-- " << options.author << " --",
23
- :justification => :center, :font_size => 20
24
-
20
+ :justification => :center, :font_size => 20
25
21
 
26
22
  c = pdf_writer.absolute_x_middle - 239/2
27
23
 
28
- #img,x,y,width,height
29
- center_image_in_box("RWEmerson.jpg",c,325,239,359)
24
+ center_image_in_box("RWEmerson.jpg", :x => c, :y => 325,
25
+ :width => 239, :height => 359)
30
26
 
31
27
  rounded_text_box(options.text) do |o|
32
28
  o.radius = 5
33
- o.width = layout.width || 400
34
- o.height = layout.height || 130
35
- o.font_size = layout.font_size || 12
29
+ o.width = options.width || 400
30
+ o.height = options.height || 130
31
+ o.font_size = options.font_size || 12
36
32
  o.heading = options.heading
37
33
 
38
34
  o.x = pdf_writer.absolute_x_middle - o.width/2
39
35
  o.y = 300
40
- end
41
-
36
+ end
42
37
  end
43
38
 
44
39
  def finalize_document
45
- output << pdf_writer.render
40
+ render_pdf
46
41
  end
47
42
  end
48
43
 
49
- a = Document.render_pdf { |r|
50
- r.heading = "a good quote"
51
- r.author = "Ralph Waldo Emerson"
52
- r.text = <<EOS
44
+ a = Document.render_pdf( :heading => "a good quote",
45
+ :author => "Ralph Waldo Emerson") { |r|
46
+ r.text = <<EOS
53
47
  A foolish consistency is the hobgoblin of little minds, adored by little
54
48
  statesmen and philosophers and divines. With consistency a great soul has simply
55
49
  nothing to do. He may as well concern himself with his shadow on the wall. Speak
@@ -0,0 +1,3 @@
1
+ 1,2,3
2
+ 4,5,6
3
+ 7,8,9
@@ -2,17 +2,17 @@ require "ruport"
2
2
 
3
3
  class LinePlotter < Ruport::Renderer
4
4
 
5
- layout do |l|
6
- l.line_color = "green"
7
- l.line_width = 2
8
- l.width = "100%"
9
- l.height = "100%"
5
+ options do |o|
6
+ o.line_color = "green"
7
+ o.line_width = 2
8
+ o.width = "100%"
9
+ o.height = "100%"
10
10
  end
11
11
 
12
12
  def run
13
- plugin do |p|
14
- p.data = get_lines
15
- p.render_plot
13
+ formatter do |f|
14
+ f.data = get_lines
15
+ f.render_plot
16
16
  end
17
17
  end
18
18
 
@@ -24,7 +24,9 @@ class LinePlotter < Ruport::Renderer
24
24
 
25
25
  end
26
26
 
27
- class SVG < Ruport::Format::Plugin
27
+ class SVG < Ruport::Formatter
28
+
29
+ renders :svg, :for => LinePlotter
28
30
 
29
31
  def initialize
30
32
  require "builder"
@@ -33,12 +35,12 @@ class SVG < Ruport::Format::Plugin
33
35
 
34
36
  def render_plot
35
37
 
36
- opts = { :width => layout.width, :height => layout.height,
38
+ opts = { :width => options.width, :height => options.height,
37
39
  :xmlns => "http://www.w3.org/2000/svg" }
38
40
 
39
41
  output << @builder.svg(opts) do |builder|
40
- builder.g( :stroke => layout.line_color,
41
- "stroke-width" => layout.line_width ) do |g|
42
+ builder.g( :stroke => options.line_color,
43
+ "stroke-width" => options.line_width ) do |g|
42
44
  data.each { |r| render_line(r,g) }
43
45
  end
44
46
  end
@@ -49,9 +51,7 @@ class SVG < Ruport::Format::Plugin
49
51
  opts = { :x1 => line.x1, :x2 => line.x2,
50
52
  :y1 => line.y1, :y2 => line.y2 }
51
53
  xml_obj.line(opts)
52
- end
53
-
54
- LinePlotter.add_format self, :svg
54
+ end
55
55
 
56
56
  end
57
57
 
@@ -1,38 +1,25 @@
1
+ require 'rubygems'
1
2
  require "ruport"
2
3
 
3
4
  module MyStuff
4
5
 
5
6
  class DocumentRenderer < Ruport::Renderer
6
- include Ruport::Renderer::Helpers
7
-
8
- def run
9
- build [:header,:body,:footer],:document
10
- finalize :document
11
- end
12
-
13
- def table=(t)
14
- options.table = t
15
- end
16
-
17
- def header_text=(t)
18
- options.header_text=(t)
19
- end
20
-
21
- def footer_text=(t)
22
- options.footer_text=(t)
23
- end
7
+ required_option :header_text, :footer_text
24
8
 
9
+ stage :document_header, :document_body, :document_footer
10
+
11
+ finalize :document
25
12
  end
26
13
 
27
- class PDF < Ruport::Format::PDF
28
- DocumentRenderer.add_format self, :pdf
14
+ class PDF < Ruport::Formatter::PDF
15
+ renders :pdf, :for => DocumentRenderer
29
16
 
30
17
  def build_document_header
31
18
  add_text options.header_text, :justification => :center
32
19
  end
33
20
 
34
21
  def build_document_body
35
- pad(10) { draw_table }
22
+ pad(10) { draw_table(data) }
36
23
  end
37
24
 
38
25
  def build_document_footer
@@ -40,10 +27,10 @@ module MyStuff
40
27
  end
41
28
 
42
29
  def finalize_document
43
- output << pdf_writer.render
30
+ render_pdf
44
31
  end
45
-
46
32
  end
33
+
47
34
  end
48
35
 
49
36
  puts MyStuff::DocumentRenderer.render_pdf { |e|