reportbuilder 1.2.0 → 1.2.1

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.
@@ -1,3 +1,7 @@
1
+ === 1.2.1 / 2010-03-29
2
+ * ReportBuilder#add returns self, to create chain of adds
3
+ * Changes on documentation, replacing Generator for Builder
4
+
1
5
  === 1.2.0 / 2010-03-28
2
6
  *ReporBuilder::Table
3
7
  * Colspans works as expected on Html and Text. On Rtf the cells doesn't merge, because ruby-rtf doesn't support it.
data/README.txt CHANGED
@@ -21,16 +21,16 @@ Report Abstract Interface. Creates text, html and rtf output, based on a common
21
21
  * report_building or
22
22
  * to_s
23
23
 
24
- require "reportbuilder"
25
- rb=ReportBuilder.new
26
- rb.add(2) # Int#to_s used
27
- table=ReportBuilder::Table.new(:name=>"Table", :header=>%w{id name})
28
- table.row([1,"John"])
29
- rb.add(table) # table have a #report_building method
30
- rb.add("Another text") # used directly
31
- rb.name="Text output"
32
- puts rb.to_text
33
- rb.save_rtf("test.rtf") # You could save files, too
24
+ require "reportbuilder"
25
+ rb=ReportBuilder.new
26
+ rb.add(2) # Int#to_s used
27
+ table=ReportBuilder::Table.new(:name=>"Table", :header=>%w{id name})
28
+ table.row([1,"John"])
29
+ rb.add(table) # table have a #report_building method
30
+ rb.add("Another text") # used directly
31
+ rb.name="Text output"
32
+ puts rb.to_text
33
+ rb.save_rtf("test.rtf") # You could save files, too
34
34
 
35
35
  * Using a block, you can control directly the generator
36
36
 
@@ -49,9 +49,9 @@ Report Abstract Interface. Creates text, html and rtf output, based on a common
49
49
 
50
50
  == DEVELOPERS
51
51
 
52
- If you want to give support to your class, create a method called #report_building(g), which accept a ReportBuilder::Generator as argument. If you need fine control of output according to format, append the name of format, like #report_building_html, #report_building_text.
52
+ If you want to give support to your class, create a method called #report_building(b), which accept a ReportBuilder::Builder as argument. If you need fine control of output according to format, append the name of format, like #report_building_html, #report_building_text.
53
53
 
54
- See ReportBuilder::Generator for API and ReportBuilder::Table, ReportBuilder::Image and ReportBuilder::Section for examples of implementation. Also, Statsample package object uses report_building on almost every class.
54
+ See ReportBuilder::Builder for API and ReportBuilder::Table, ReportBuilder::Image and ReportBuilder::Section for examples of implementation. Also, Statsample package object uses report_building on almost every class.
55
55
 
56
56
  == REQUIREMENTS:
57
57
 
data/Rakefile CHANGED
@@ -20,6 +20,7 @@ task :release => [:tag] do
20
20
  end
21
21
 
22
22
  task :tag do
23
+ sh %(svn commit -m "Version bump: #{ReportBuilder::VERSION}")
23
24
  sh %(svn cp https://ruby-statsample.googlecode.com/svn/reportbuilder/trunk https://ruby-statsample.googlecode.com/svn/reportbuilder/tags/v#{ReportBuilder::VERSION} -m "ReportBuilder #{ReportBuilder::VERSION} tagged")
24
25
  end
25
26
 
@@ -53,7 +53,7 @@ class ReportBuilder
53
53
  # Doesn't print a title if set to true
54
54
  attr_accessor :no_title
55
55
  # ReportBuilder version
56
- VERSION = '1.2.0'
56
+ VERSION = '1.2.1'
57
57
 
58
58
  FormatNotFound=Class.new(Exception)
59
59
  # Available formats
@@ -103,6 +103,7 @@ class ReportBuilder
103
103
  # Otherwise, the element itself will be added
104
104
  def add(element)
105
105
  @elements.push(element)
106
+ self
106
107
  end
107
108
  # Returns an Html output
108
109
  def to_html()
@@ -3,13 +3,21 @@ require 'pp'
3
3
  class ReportBuilder
4
4
  class Builder
5
5
  # Rtf Builder.
6
- # Based on ruby-rtf (http://ruby-rtf.rubyforge.org/)
6
+ # Based on ruby-rtf (http://ruby-rtf.rubyforge.org/).
7
7
  #
8
8
  class Rtf < Builder
9
9
  # RTF::Document object.
10
10
  # See http://ruby-rtf.rubyforge.org/ for documentation
11
11
  attr_accessor :rtf
12
12
  include RTF
13
+ # Creates a new Rtf object
14
+ # Params:
15
+ # * <tt>builder</tt>: A ReportBuilder::Builder object or other with same interface
16
+ # * <tt>options</tt>: Hash of options.
17
+ # * <tt>:font</tt>: Font family. Default to "Times New Roman"
18
+ # * <tt>:font_size</tt>: Font size. Default to 20
19
+ # * <tt>:table_border_width</tt>
20
+ # * <tt>:table_hr_width</tt>
13
21
  def initialize(builder, options)
14
22
  super
15
23
  @font=Font.new(Font::ROMAN, @options[:font])
@@ -47,6 +55,7 @@ class ReportBuilder
47
55
  :table_hr_width=>25
48
56
  }
49
57
  end
58
+ # Add a paragraph of text.
50
59
  def text(*args,&block)
51
60
  if args.size==1 and args[0].is_a? String and !block
52
61
  @rtf.paragraph << args[0]
@@ -54,6 +63,7 @@ class ReportBuilder
54
63
  @rtf.paragraph(*args,&block)
55
64
  end
56
65
  end
66
+ # Add a header of level <tt>level</tt> with text <tt>t</tt>
57
67
  def header(level,t)
58
68
  @rtf.paragraph(@header_styles[level][:ps]) do |n1|
59
69
  n1.apply(@header_styles[level][:cs]) do |n2|
@@ -63,6 +73,7 @@ class ReportBuilder
63
73
  end
64
74
  end
65
75
  end
76
+ # Add preformatted text. By default, uses Courier
66
77
  def preformatted(t)
67
78
  @rtf.paragraph(@pre_par) do |n1|
68
79
  n1.apply(@pre_char) do |n2|
@@ -74,14 +85,16 @@ class ReportBuilder
74
85
  end
75
86
 
76
87
  end
77
-
88
+ # Returns rtf code for report
78
89
  def out
79
90
  @rtf.to_rtf
80
91
  end
92
+ # Save rtf file
81
93
  def save(filename)
82
94
  File.open(filename,'wb') {|file| file.write(@rtf.to_rtf)
83
95
  }
84
96
  end
97
+ # Do nothing on this builder
85
98
  def html(t)
86
99
  # Nothing
87
100
  end
@@ -1,6 +1,10 @@
1
1
  require 'text-table'
2
2
  class ReportBuilder
3
3
  class Table
4
+ # Text Builder for ReportBuilder::Table objects.
5
+ #
6
+ # Uses Aaron Tinio's text-table gem[http://github.com/aptinio/text-table]
7
+
4
8
  class TextBuilder < ElementBuilder
5
9
  def generate()
6
10
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 2
8
- - 0
9
- version: 1.2.0
8
+ - 1
9
+ version: 1.2.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Claudio Bustos
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-28 00:00:00 -03:00
17
+ date: 2010-03-29 00:00:00 -03:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency