reportbuilder 1.2.3 → 1.2.4
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.
- data.tar.gz.sig +0 -0
- data/History.txt +3 -0
- data/Rakefile +1 -8
- data/lib/reportbuilder.rb +2 -2
- data/lib/reportbuilder/table.rb +4 -1
- data/lib/reportbuilder/table/rtfbuilder.rb +20 -11
- metadata +2 -2
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/History.txt
CHANGED
data/Rakefile
CHANGED
@@ -5,7 +5,7 @@ $:.unshift(File.dirname(__FILE__)+"/lib")
|
|
5
5
|
require 'rubygems'
|
6
6
|
require 'hoe'
|
7
7
|
require 'reportbuilder'
|
8
|
-
|
8
|
+
Hoe.plugin :git
|
9
9
|
Hoe.spec 'reportbuilder' do
|
10
10
|
self.testlib=:minitest
|
11
11
|
self.version=ReportBuilder::VERSION
|
@@ -16,11 +16,4 @@ Hoe.spec 'reportbuilder' do
|
|
16
16
|
self.extra_dev_deps << ["nokogiri", "~>1.4"]
|
17
17
|
end
|
18
18
|
|
19
|
-
task :release do
|
20
|
-
version="v#{ReportBuilder::VERSION}"
|
21
|
-
sh %(git commit -a -m "Release #{version}")
|
22
|
-
sh %(git tag "#{version}")
|
23
|
-
sh %(git push origin --tags)
|
24
|
-
end
|
25
|
-
|
26
19
|
# vim: syntax=ruby
|
data/lib/reportbuilder.rb
CHANGED
@@ -51,7 +51,7 @@ class ReportBuilder
|
|
51
51
|
# Doesn't print a title if set to true
|
52
52
|
attr_accessor :no_title
|
53
53
|
# ReportBuilder version
|
54
|
-
VERSION = '1.2.
|
54
|
+
VERSION = '1.2.4'
|
55
55
|
|
56
56
|
FormatNotFound=Class.new(Exception)
|
57
57
|
# Available formats
|
@@ -87,7 +87,7 @@ class ReportBuilder
|
|
87
87
|
end
|
88
88
|
end
|
89
89
|
# Create a new Report
|
90
|
-
def initialize(options=Hash.new
|
90
|
+
def initialize(options=Hash.new, &block)
|
91
91
|
options[:name]||="Report "+Time.new.to_s
|
92
92
|
@no_title=options.delete :no_title
|
93
93
|
@name=options.delete :name
|
data/lib/reportbuilder/table.rb
CHANGED
@@ -75,6 +75,9 @@ class ReportBuilder
|
|
75
75
|
def n_rows_no_hr
|
76
76
|
@rows.inject(0) {|ac,v| ac+(v==:hr ? 0 : 1)}
|
77
77
|
end
|
78
|
+
def n_rows
|
79
|
+
@rows.size
|
80
|
+
end
|
78
81
|
# Adds a colspan on a cell
|
79
82
|
# table.add_row(["a",table.colspan("b",2)])
|
80
83
|
def colspan(data,n)
|
@@ -128,7 +131,7 @@ class ReportBuilder
|
|
128
131
|
0
|
129
132
|
end
|
130
133
|
end
|
131
|
-
|
134
|
+
|
132
135
|
|
133
136
|
|
134
137
|
######################
|
@@ -5,57 +5,66 @@ class ReportBuilder
|
|
5
5
|
def generate()
|
6
6
|
@t=@element
|
7
7
|
@rtf=@builder.rtf
|
8
|
-
|
8
|
+
|
9
9
|
# Title
|
10
|
-
|
10
|
+
|
11
11
|
@builder.header(6,@t.name)
|
12
|
-
|
12
|
+
|
13
13
|
max_cols=@t.calculate_widths
|
14
14
|
n_rows=@t.n_rows_no_hr+(@t.header.size>0 ? 1: 0)
|
15
15
|
args=[n_rows, @t.n_columns]+max_cols.map{|m| m*@builder.options[:font_size]*10}
|
16
16
|
@table=@rtf.table(*args)
|
17
17
|
@table.border_width=@builder.options[:table_border_width]
|
18
18
|
@rowspans=[]
|
19
|
+
row_i=0
|
19
20
|
if @t.header.size>0
|
21
|
+
row_i=1
|
20
22
|
@t.header.each_with_index do |th,i|
|
21
23
|
@table[0][i] << th
|
22
24
|
end
|
25
|
+
add_hr_on_bottom(0)
|
23
26
|
end
|
24
27
|
next_with_hr=false
|
25
|
-
|
28
|
+
|
29
|
+
@t.rows.each_with_index{|row|
|
26
30
|
if row==:hr
|
27
31
|
next_with_hr=true
|
28
32
|
# Nothing
|
29
33
|
else
|
30
34
|
parse_row(row,row_i)
|
31
35
|
if next_with_hr
|
32
|
-
|
36
|
+
add_hr_on_top(row_i)
|
33
37
|
next_with_hr=false
|
34
38
|
end
|
35
|
-
|
39
|
+
row_i+=1
|
36
40
|
end
|
37
41
|
}
|
38
|
-
|
42
|
+
|
39
43
|
end
|
40
|
-
def
|
44
|
+
def add_hr_on_top(row_i)
|
41
45
|
(0...@t.n_columns).each {|i|
|
42
46
|
@table[row_i][i].top_border_width=@builder.options[:table_hr_width]
|
43
47
|
}
|
44
48
|
end
|
45
|
-
|
49
|
+
def add_hr_on_bottom(row_i)
|
50
|
+
(0...@t.n_columns).each {|i|
|
51
|
+
@table[row_i][i].bottom_border_width=@builder.options[:table_hr_width]
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
46
55
|
def parse_row(row,row_i)
|
47
56
|
t=@element
|
48
57
|
row_ary=[]
|
49
58
|
real_i=0
|
50
59
|
colspan_i=0
|
51
60
|
row.each_index do |i|
|
52
|
-
extra=1
|
61
|
+
extra=1
|
53
62
|
while !@rowspans[real_i].nil? and @rowspans[real_i]>0
|
54
63
|
@rowspans[real_i]-=1
|
55
64
|
real_i+=1
|
56
65
|
end
|
57
66
|
if row[i].is_a? Table::Colspan
|
58
|
-
@table[row_i][real_i] << row[i].data
|
67
|
+
@table[row_i][real_i] << row[i].data
|
59
68
|
colspan_i=row[i].cols-1
|
60
69
|
extra=row[i].cols
|
61
70
|
elsif row[i].nil?
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reportbuilder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Claudio Bustos
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
rpP0jjs0
|
31
31
|
-----END CERTIFICATE-----
|
32
32
|
|
33
|
-
date: 2010-04-
|
33
|
+
date: 2010-04-30 00:00:00 -04:00
|
34
34
|
default_executable:
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
metadata.gz.sig
CHANGED
Binary file
|