ruport 0.6.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +6 -0
- data/Rakefile +4 -4
- data/TODO +3 -2
- data/bin/rope +2 -103
- data/examples/pdf_complex_report.rb +53 -0
- data/lib/ruport/config.rb +7 -7
- data/lib/ruport/data/collection.rb +8 -7
- data/lib/ruport/data/groupable.rb +3 -2
- data/lib/ruport/data/record.rb +13 -16
- data/lib/ruport/data/table.rb +89 -18
- data/lib/ruport/format/csv.rb +29 -0
- data/lib/ruport/format/html.rb +40 -0
- data/lib/ruport/format/latex.rb +50 -0
- data/lib/ruport/format/pdf.rb +78 -0
- data/lib/ruport/format/plugin.rb +20 -65
- data/lib/ruport/format/svg.rb +39 -0
- data/lib/ruport/format/text.rb +77 -0
- data/lib/ruport/format/xml.rb +32 -0
- data/lib/ruport/format.rb +1 -159
- data/lib/ruport/generator.rb +158 -0
- data/lib/ruport/layout/component.rb +7 -0
- data/lib/ruport/layout.rb +1 -0
- data/lib/ruport/query.rb +3 -3
- data/lib/ruport/renderer/graph.rb +48 -0
- data/lib/ruport/renderer/table.rb +132 -0
- data/lib/ruport/renderer.rb +193 -0
- data/lib/ruport/report/graph.rb +2 -2
- data/lib/ruport/report.rb +94 -96
- data/lib/ruport/system_extensions.rb +3 -6
- data/lib/ruport.rb +6 -4
- data/test/samples/dates.csv +1409 -0
- data/test/samples/foo.rtxt +3 -0
- data/test/test_collection.rb +0 -14
- data/test/test_config.rb +6 -6
- data/test/test_graph_renderer.rb +97 -0
- data/test/test_groupable.rb +1 -0
- data/test/test_query.rb +325 -324
- data/test/test_record.rb +3 -2
- data/test/test_renderer.rb +74 -0
- data/test/test_report.rb +29 -26
- data/test/test_table.rb +54 -29
- data/test/test_table_renderer.rb +93 -0
- data/test/test_text_table.rb +61 -0
- data/test/unit.log +24 -0
- metadata +41 -63
- data/CHANGELOG +0 -587
- data/examples/basic_grouping.rb +0 -19
- data/examples/fieldless_table.rb +0 -13
- data/examples/latex_table.rb +0 -17
- data/examples/line_graph.rb +0 -22
- data/examples/line_graph_report.rb +0 -23
- data/examples/line_plotter.rb +0 -46
- data/examples/long.txt +0 -24
- data/examples/new_plugin.rb +0 -24
- data/examples/report.rb +0 -35
- data/examples/sample_invoice_report.rb +0 -32
- data/examples/simple_mail.rb +0 -15
- data/examples/simple_table_interface.rb +0 -20
- data/examples/sql_erb.rb +0 -20
- data/examples/template.rb +0 -15
- data/examples/text_processors.rb +0 -13
- data/lib/ruport/format/engine/document.rb +0 -28
- data/lib/ruport/format/engine/graph.rb +0 -18
- data/lib/ruport/format/engine/invoice.rb +0 -23
- data/lib/ruport/format/engine/table.rb +0 -54
- data/lib/ruport/format/engine.rb +0 -108
- data/lib/ruport/format/plugin/csv_plugin.rb +0 -26
- data/lib/ruport/format/plugin/html_plugin.rb +0 -32
- data/lib/ruport/format/plugin/latex_plugin.rb +0 -50
- data/lib/ruport/format/plugin/pdf_plugin.rb +0 -126
- data/lib/ruport/format/plugin/svg_plugin.rb +0 -61
- data/lib/ruport/format/plugin/text_plugin.rb +0 -77
- data/lib/ruport/meta_tools.rb +0 -66
- data/lib/ruport/report/invoice.rb +0 -29
- data/test/_test_groupable.rb +0 -0
- data/test/test_format.rb +0 -39
- data/test/test_format_engine.rb +0 -264
- data/test/test_graph.rb +0 -93
- data/test/test_invoice.rb +0 -32
- data/test/test_latex.rb +0 -20
- data/test/test_meta_tools.rb +0 -14
- data/test/test_plugin.rb +0 -277
- data/test/ts_all.rb +0 -21
data/test/test_graph.rb
DELETED
@@ -1,93 +0,0 @@
|
|
1
|
-
require "ruport"
|
2
|
-
|
3
|
-
begin; require 'rubygems'; rescue LoadError; nil; end
|
4
|
-
require "test/unit"
|
5
|
-
|
6
|
-
begin
|
7
|
-
require 'scruffy'
|
8
|
-
|
9
|
-
class TestGraph < Test::Unit::TestCase
|
10
|
-
def setup
|
11
|
-
@data = [[1,2,3,2],[3,4,5,6]].to_table(%w[a b c d])
|
12
|
-
@data_mismatched_headings = [[3,2],[3,4]].to_table(%w[a b c])
|
13
|
-
@data_float = [[1.3,2],[3.28322,4]].to_table(%w[a b])
|
14
|
-
@data_not_numbers = [["d",:sdfs,"not a number","1"],[3,4,5,6]].to_table(%w[a b c d])
|
15
|
-
end
|
16
|
-
|
17
|
-
# basic test to ensure bar charts render
|
18
|
-
def test_bar
|
19
|
-
graph = Ruport::Format.graph_object :plugin => :svg, :data => @data
|
20
|
-
graph.title = "A Simple Bar Graph"
|
21
|
-
graph.width = 600
|
22
|
-
graph.height = 500
|
23
|
-
graph.style = :bar
|
24
|
-
output = graph.render
|
25
|
-
|
26
|
-
assert_not_equal nil, output
|
27
|
-
end
|
28
|
-
|
29
|
-
# basic test to ensure line charts render
|
30
|
-
def test_line
|
31
|
-
graph = Ruport::Format.graph_object :plugin => :svg, :data => @data
|
32
|
-
graph.title = "A Simple Line Graph"
|
33
|
-
graph.width = 600
|
34
|
-
graph.height = 500
|
35
|
-
graph.style = :line
|
36
|
-
|
37
|
-
output = graph.render
|
38
|
-
assert_not_equal nil, output
|
39
|
-
end
|
40
|
-
|
41
|
-
# ensure an exception is raised if the user doesn't name every column
|
42
|
-
def test_mismatched_headings
|
43
|
-
graph = Ruport::Format.graph_object :plugin => :svg, :data => @data_mismatched_headings
|
44
|
-
graph.title = "Mismatched Headings"
|
45
|
-
graph.width = 600
|
46
|
-
graph.height = 500
|
47
|
-
graph.style = :line
|
48
|
-
|
49
|
-
assert_raises(InvalidGraphDataError) {
|
50
|
-
output = graph.render
|
51
|
-
}
|
52
|
-
end
|
53
|
-
|
54
|
-
# test to ensure floats can be graphed
|
55
|
-
def test_floats
|
56
|
-
graph = Ruport::Format.graph_object :plugin => :svg, :data => @data_float
|
57
|
-
graph.title = "Graphing Floats"
|
58
|
-
graph.width = 600
|
59
|
-
graph.height = 500
|
60
|
-
graph.style = :line
|
61
|
-
output = graph.render
|
62
|
-
|
63
|
-
assert_not_equal nil, output
|
64
|
-
end
|
65
|
-
|
66
|
-
# ensure an exception is raised if non numeric data is graphed
|
67
|
-
def test_not_numbers
|
68
|
-
graph = Ruport::Format.graph_object :plugin => :svg, :data => @data_not_numbers
|
69
|
-
graph.title = "Graphing Things That Aren't Numbers"
|
70
|
-
graph.width = 600
|
71
|
-
graph.height = 500
|
72
|
-
graph.style = :line
|
73
|
-
|
74
|
-
assert_raises(InvalidGraphDataError) {
|
75
|
-
output = graph.render
|
76
|
-
}
|
77
|
-
end
|
78
|
-
|
79
|
-
# ensure an exception is raised if non numeric data is graphed
|
80
|
-
def test_missing_required_option
|
81
|
-
graph = Ruport::Format.graph_object :plugin => :svg, :data => @data
|
82
|
-
graph.title = "Rendering a graph with a missing option"
|
83
|
-
graph.height = 500
|
84
|
-
graph.style = :line
|
85
|
-
|
86
|
-
assert_raises(InvalidGraphOptionError) {
|
87
|
-
output = graph.render
|
88
|
-
}
|
89
|
-
end
|
90
|
-
end
|
91
|
-
rescue LoadError
|
92
|
-
puts "Skipping Graph Tests (needs scruffy)"
|
93
|
-
end
|
data/test/test_invoice.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'ruport'
|
2
|
-
begin; require 'rubygems'; rescue LoadError; nil; end
|
3
|
-
require "test/unit"
|
4
|
-
|
5
|
-
class SampleInvoiceReport < Ruport::Report
|
6
|
-
extend Invoice
|
7
|
-
end
|
8
|
-
|
9
|
-
class TestInvoice < Test::Unit::TestCase
|
10
|
-
|
11
|
-
def test_basic
|
12
|
-
begin
|
13
|
-
require "pdf/writer"
|
14
|
-
rescue LoadError
|
15
|
-
warn "skipping pdf test"; return
|
16
|
-
end
|
17
|
-
inv = SampleInvoiceReport.build_invoice do |i|
|
18
|
-
i.company_info = "Foo Inc.\n42 Bar Street\nBaz, CT\n"
|
19
|
-
i.customer_info = "Gregory Brown\ngregory.t.brown@gmail.com"
|
20
|
-
i.data = [[1,2],[3,4]].to_table(%w[a b])
|
21
|
-
end
|
22
|
-
assert_nothing_raised { inv.render }
|
23
|
-
assert_nothing_raised {
|
24
|
-
SampleInvoiceReport.render_invoice do |i|
|
25
|
-
i.company_info = "Foo Inc.\n42 Bar Street\nBaz, CT\n"
|
26
|
-
i.customer_info = "Gregory Brown\ngregory.t.brown@gmail.com"
|
27
|
-
i.data = [[1,2],[3,4]].to_table(%w[a b])
|
28
|
-
end
|
29
|
-
}
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
data/test/test_latex.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
require "ruport"
|
2
|
-
begin; require 'rubygems'; rescue LoadError; nil; end
|
3
|
-
require "test/unit"
|
4
|
-
|
5
|
-
class TestLatex < Test::Unit::TestCase
|
6
|
-
|
7
|
-
def setup
|
8
|
-
@data = [[1,2,3,2],[3,4,5,6]].to_table(%w[a b c d])
|
9
|
-
end
|
10
|
-
|
11
|
-
# basic test to ensure bar charts render
|
12
|
-
def test_table_to_latex
|
13
|
-
report = Ruport::Format.table_object :plugin => :latex, :data => @data
|
14
|
-
output = report.render
|
15
|
-
assert_equal "\\documentclass", output[/\\documentclass/]
|
16
|
-
assert_equal "\\begin{document}", output[/\\begin\{document\}/]
|
17
|
-
assert_equal "\\end{document}", output[/\\end\{document\}/]
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
data/test/test_meta_tools.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require "test/unit"
|
2
|
-
require "ruport"
|
3
|
-
|
4
|
-
class A; extend Ruport::MetaTools; end
|
5
|
-
|
6
|
-
class TestMetaTools < Test::Unit::TestCase
|
7
|
-
|
8
|
-
def test_action
|
9
|
-
assert_nothing_raised { A.action(:foo) { |x| x + 1 } }
|
10
|
-
assert_equal 4, A.foo(3)
|
11
|
-
assert_raise(ActionAlreadyDefinedError) { A.action(:foo) { } }
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|
data/test/test_plugin.rb
DELETED
@@ -1,277 +0,0 @@
|
|
1
|
-
require "test/unit"
|
2
|
-
require "ruport"
|
3
|
-
begin; require "rubygems"; rescue LoadError; nil; end
|
4
|
-
|
5
|
-
include Ruport
|
6
|
-
|
7
|
-
# a sample plugin to test the system
|
8
|
-
class TSVPlugin < Format::Plugin
|
9
|
-
|
10
|
-
require "fastercsv"
|
11
|
-
|
12
|
-
format_field_names do
|
13
|
-
FasterCSV.generate(:col_sep => "\t") { |csv| csv << data.column_names }
|
14
|
-
end
|
15
|
-
|
16
|
-
renderer :table do
|
17
|
-
rendered_field_names +
|
18
|
-
FasterCSV.generate(:col_sep => "\t") { |csv| data.each { |r| csv << r } }
|
19
|
-
end
|
20
|
-
|
21
|
-
helper(:foo, :engine => :table_engine) { }
|
22
|
-
helper(:bar, :engines => [:table_engine,:invoice_engine]) { }
|
23
|
-
helper(:baz) {}
|
24
|
-
|
25
|
-
plugin_name :tsv
|
26
|
-
register_on :table_engine
|
27
|
-
|
28
|
-
# wont work, just for helper tests
|
29
|
-
register_on :invoice_engine
|
30
|
-
register_on :document_engine
|
31
|
-
|
32
|
-
rendering_options :boring => :true
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
class NakedPlugin < Ruport::Format::Plugin
|
37
|
-
plugin_name :naked
|
38
|
-
end
|
39
|
-
|
40
|
-
|
41
|
-
class TestPlugin < Test::Unit::TestCase
|
42
|
-
def test_helper
|
43
|
-
t = Ruport::Format.table_object :data => [[1,2]], :plugin => :tsv
|
44
|
-
i = Ruport::Format.invoice_object :data => [[1,2]].to_table(%w[a b]), :plugin => :tsv
|
45
|
-
d = Ruport::Format.document_object :data => "foo", :plugin => :tsv
|
46
|
-
assert_nothing_raised { t.foo }
|
47
|
-
assert_nothing_raised { t.bar }
|
48
|
-
assert_nothing_raised { t.baz }
|
49
|
-
assert_nothing_raised { i.bar }
|
50
|
-
assert_nothing_raised { i.baz }
|
51
|
-
assert_nothing_raised { d.baz }
|
52
|
-
assert_raise(NoMethodError) { i.foo }
|
53
|
-
assert_raise(NoMethodError) { d.foo }
|
54
|
-
assert_raise(NoMethodError) { d.bar }
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_rendering_options
|
58
|
-
t = Ruport::Format.table_object(:data => [[1,2]], :plugin => :tsv)
|
59
|
-
assert t.active_plugin.respond_to?(:options)
|
60
|
-
assert t.active_plugin.respond_to?(:rendering_options)
|
61
|
-
assert t.active_plugin.rendering_options[:boring]
|
62
|
-
assert_nil t.active_plugin.options
|
63
|
-
assert_nil t.options
|
64
|
-
end
|
65
|
-
|
66
|
-
def test_register_on
|
67
|
-
a = NakedPlugin.dup
|
68
|
-
assert a.respond_to?(:register_on)
|
69
|
-
assert_raise(InvalidPluginError) {
|
70
|
-
Ruport::Format.table_object(:plugin => :naked)
|
71
|
-
}
|
72
|
-
assert_raise(InvalidPluginError) {
|
73
|
-
Ruport::Format.document_object(:plugin => :naked)
|
74
|
-
}
|
75
|
-
a.register_on :table_engine, :document_engine
|
76
|
-
assert_nothing_raised {
|
77
|
-
Ruport::Format.table_object(:plugin => :naked)
|
78
|
-
Ruport::Format.document_object(:plugin => :naked)
|
79
|
-
}
|
80
|
-
|
81
|
-
end
|
82
|
-
|
83
|
-
end
|
84
|
-
|
85
|
-
class TestCSVPlugin < Test::Unit::TestCase
|
86
|
-
|
87
|
-
def test_basic
|
88
|
-
a = Format.table_object :plugin => :csv, :data => [[1,2],[3,4]]
|
89
|
-
assert_equal("1,2\n3,4\n",a.render)
|
90
|
-
|
91
|
-
a.data = a.data.to_table(:column_names => %w[a b])
|
92
|
-
assert_equal("a,b\n1,2\n3,4\n",a.render)
|
93
|
-
|
94
|
-
a.data = Ruport::Data::Table.new :data => [[1,2],[3,4]]
|
95
|
-
assert_equal("1,2\n3,4\n",a.render)
|
96
|
-
|
97
|
-
a.data = Ruport::Data::Table.new :data => [[1,2],[3,4]],
|
98
|
-
:column_names => %w[a b]
|
99
|
-
|
100
|
-
assert_equal("a,b\n1,2\n3,4\n",a.render)
|
101
|
-
|
102
|
-
a.show_field_names = false
|
103
|
-
assert_equal("1,2\n3,4\n", a.render)
|
104
|
-
end
|
105
|
-
|
106
|
-
end
|
107
|
-
|
108
|
-
class TestPDFPlugin < Test::Unit::TestCase
|
109
|
-
|
110
|
-
def test_ensure_fails_on_array
|
111
|
-
begin
|
112
|
-
require "pdf/writer"
|
113
|
-
rescue LoadError
|
114
|
-
warn "skipping pdf test"; return
|
115
|
-
end
|
116
|
-
a = Format.table_object :plugin => :pdf, :data => [[1,2],[3,4]]
|
117
|
-
assert_raise(RuntimeError) { a.render }
|
118
|
-
|
119
|
-
a.data = a.data.to_table(:column_names => %w[a b])
|
120
|
-
assert_nothing_raised { a.render }
|
121
|
-
|
122
|
-
#FIXME: Engine should be further duck typed so this test will pass
|
123
|
-
#a.data = [{ "a" => "b", "c" => "d" },{"a" => "f", "c" => "g"}]
|
124
|
-
#assert_nothing_raised { a.render }
|
125
|
-
end
|
126
|
-
|
127
|
-
def test_hooks
|
128
|
-
begin
|
129
|
-
require "pdf/writer"
|
130
|
-
rescue LoadError
|
131
|
-
warn "skipping pdf test"; return
|
132
|
-
end
|
133
|
-
a = Format.table_object :plugin => :pdf, :data => [[1,2],[3,4]]
|
134
|
-
a = Format.table_object :plugin => :pdf,
|
135
|
-
:data => [[1,2],[3,4]].to_table(:column_names => %w[a b])
|
136
|
-
y = 0
|
137
|
-
a.active_plugin.pre = lambda { |pdf|
|
138
|
-
assert_instance_of(PDF::Writer,pdf);
|
139
|
-
y = pdf.y
|
140
|
-
}
|
141
|
-
a.active_plugin.post = lambda { |pdf|
|
142
|
-
assert_instance_of(PDF::Writer,pdf); assert(pdf.y < y)
|
143
|
-
}
|
144
|
-
assert_nothing_raised { a.render }
|
145
|
-
end
|
146
|
-
|
147
|
-
end
|
148
|
-
|
149
|
-
class TestHTMLPlugin < Test::Unit::TestCase
|
150
|
-
|
151
|
-
def test_basic
|
152
|
-
a = Format.table_object :plugin => :html, :data => [[1,2],[3,nil]]
|
153
|
-
assert_equal("\t<table>\n\t\t<tr>\n\t\t\t<td>1</td>\n\t\t\t<td>2</td>"+
|
154
|
-
"\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td>3</td>\n\t\t\t<td> "+
|
155
|
-
"</td>\n\t\t</tr>\n\t</table>",a.render)
|
156
|
-
a.data = a.data.to_table(:column_names => %w[a b])
|
157
|
-
assert_equal("\t<table>\n\t\t<tr>\n\t\t\t<th>a</th>\n\t\t\t<th>b</th>"+
|
158
|
-
"\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td>1</td>\n\t\t\t<td>"+
|
159
|
-
"2</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td>3</td>\n\t\t\t<td>"+
|
160
|
-
" </td>\n\t\t</tr>\n\t</table>",a.render)
|
161
|
-
a.show_field_names = false
|
162
|
-
assert_equal("\t<table>\n\t\t<tr>\n\t\t\t<td>1</td>\n\t\t\t<td>2</td>"+
|
163
|
-
"\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td>3</td>\n\t\t\t<td> "+
|
164
|
-
"</td>\n\t\t</tr>\n\t</table>",a.render)
|
165
|
-
a.data[0].tag(:odd)
|
166
|
-
a.data[1].tag(:even)
|
167
|
-
assert_equal("\t<table>\n\t\t<tr class='odd'>\n\t\t\t<td class='odd'>"+
|
168
|
-
"1</td>\n\t\t\t<td class='odd'>2</td>\n\t\t</tr>\n\t\t"+
|
169
|
-
"<tr class='even'>\n\t\t\t<td class='even'>3</td>\n\t\t\t"+
|
170
|
-
"<td class='even'> </td>\n\t\t</tr>\n\t</table>",
|
171
|
-
a.render)
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
|
176
|
-
#this test is intended to ensure proper functionality of the plugin system.
|
177
|
-
class TestNewPlugin < Test::Unit::TestCase
|
178
|
-
|
179
|
-
def test_basic
|
180
|
-
a = Format.table_object :plugin => :tsv, :data => [[1,2],[3,4]]
|
181
|
-
assert_equal("1\t2\n3\t4\n",a.render)
|
182
|
-
|
183
|
-
a.data = a.data.to_table(:column_names => %w[a b])
|
184
|
-
assert_equal("a\tb\n1\t2\n3\t4\n",a.render)
|
185
|
-
|
186
|
-
a.show_field_names = false
|
187
|
-
assert_equal("1\t2\n3\t4\n",a.render)
|
188
|
-
end
|
189
|
-
|
190
|
-
end
|
191
|
-
|
192
|
-
class TestTextPlugin < Test::Unit::TestCase
|
193
|
-
|
194
|
-
def test_basic
|
195
|
-
|
196
|
-
tf = "+-------+\n"
|
197
|
-
|
198
|
-
a = Format.table_object :plugin => :text, :data => [[1,2],[3,4]]
|
199
|
-
assert_equal("#{tf}| 1 | 2 |\n| 3 | 4 |\n#{tf}",a.render)
|
200
|
-
|
201
|
-
a.data = a.data.to_table(:column_names => %w[a b])
|
202
|
-
assert_equal("#{tf}| a | b |\n#{tf}| 1 | 2 |\n| 3 | 4 |\n#{tf}", a.render)
|
203
|
-
|
204
|
-
end
|
205
|
-
|
206
|
-
def test_max_col_width
|
207
|
-
a = Format.table_object :plugin => :text, :data => [[1,2],[300,4]]
|
208
|
-
a.active_plugin.calculate_max_col_widths
|
209
|
-
assert_equal(3,a.active_plugin.max_col_width[0])
|
210
|
-
assert_equal(1,a.active_plugin.max_col_width[1])
|
211
|
-
|
212
|
-
a.data = [[1,2],[300,4]].to_table(:column_names => %w[a ba])
|
213
|
-
a.active_plugin.calculate_max_col_widths
|
214
|
-
assert_equal(3,a.active_plugin.max_col_width[0])
|
215
|
-
assert_equal(2,a.active_plugin.max_col_width[1])
|
216
|
-
|
217
|
-
a.data = [[1,2],[3,40000]].to_table(:column_names => %w[foo bazz])
|
218
|
-
a.active_plugin.calculate_max_col_widths
|
219
|
-
assert_equal(3,a.active_plugin.max_col_width[0])
|
220
|
-
assert_equal(5,a.active_plugin.max_col_width[1])
|
221
|
-
end
|
222
|
-
|
223
|
-
def test_hr
|
224
|
-
a = Format.table_object :plugin => :text, :data => [[1,2],[300,4]]
|
225
|
-
a.active_plugin.calculate_max_col_widths
|
226
|
-
assert_equal("+---------+\n",a.active_plugin.hr)
|
227
|
-
|
228
|
-
|
229
|
-
a.data = [[1,2],[3,40000]].to_table(:column_names => %w[foo bazz])
|
230
|
-
a.active_plugin.calculate_max_col_widths
|
231
|
-
assert_equal "+-------------+\n", a.active_plugin.hr
|
232
|
-
|
233
|
-
end
|
234
|
-
|
235
|
-
def test_centering
|
236
|
-
tf = "+---------+\n"
|
237
|
-
|
238
|
-
a = Format.table_object :plugin => :text, :data => [[1,2],[300,4]]
|
239
|
-
assert_equal("#{tf}| 1 | 2 |\n| 300 | 4 |\n#{tf}",a.render)
|
240
|
-
|
241
|
-
tf = "+------------+\n"
|
242
|
-
a.data = a.data.to_table(:column_names => %w[a bark])
|
243
|
-
assert_equal("#{tf}| a | bark |\n#{tf}| 1 | 2 |\n"+
|
244
|
-
"| 300 | 4 |\n#{tf}",a.render)
|
245
|
-
|
246
|
-
end
|
247
|
-
|
248
|
-
def test_wrapping
|
249
|
-
|
250
|
-
a = Format.table_object :plugin => :text, :data => [[1,2],[300,4]]
|
251
|
-
|
252
|
-
#def SystemExtensions.terminal_width; 10; end
|
253
|
-
a.active_plugin.right_margin = 10
|
254
|
-
assert_equal("+------->>\n| 1 | >>\n| 300 | >>\n+------->>\n",a.render)
|
255
|
-
|
256
|
-
a = Format.table_object :plugin => :text, :data => [[1,2],[300,4]]
|
257
|
-
assert_equal(nil,a.active_plugin.right_margin)
|
258
|
-
end
|
259
|
-
|
260
|
-
|
261
|
-
def test_make_sure_this_damn_column_names_bug_dies_a_horrible_death!
|
262
|
-
a = Format.table :plugin => :text, :data => [[1,2,3]].to_table
|
263
|
-
expected = "+-----------+\n"+
|
264
|
-
"| 1 | 2 | 3 |\n"+
|
265
|
-
"+-----------+\n"
|
266
|
-
assert_equal(expected,a)
|
267
|
-
|
268
|
-
end
|
269
|
-
|
270
|
-
def test_graceful_failure_on_empty_table
|
271
|
-
assert_nothing_raised { [].to_table.to_text }
|
272
|
-
assert_nothing_raised { [].to_table(%w[a b c]).to_text }
|
273
|
-
end
|
274
|
-
|
275
|
-
|
276
|
-
end
|
277
|
-
|
data/test/ts_all.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
begin; require "tesly_reporter"; rescue LoadError; nil; end
|
2
|
-
%w[
|
3
|
-
test_collection.rb
|
4
|
-
test_config.rb
|
5
|
-
test_format.rb
|
6
|
-
test_format_engine.rb
|
7
|
-
test_graph.rb
|
8
|
-
test_invoice.rb
|
9
|
-
test_latex.rb
|
10
|
-
test_mailer.rb
|
11
|
-
test_meta_tools.rb
|
12
|
-
test_plugin.rb
|
13
|
-
test_query.rb
|
14
|
-
test_record.rb
|
15
|
-
test_report.rb
|
16
|
-
test_ruport.rb
|
17
|
-
test_set.rb
|
18
|
-
test_sql_split.rb
|
19
|
-
test_table.rb
|
20
|
-
test_taggable.rb
|
21
|
-
].each { |t| require "test/#{t}" }
|