ruport 0.6.1 → 0.7.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.
- 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_record.rb
CHANGED
@@ -193,12 +193,13 @@ class TestRecord < Test::Unit::TestCase
|
|
193
193
|
|
194
194
|
assert_equal [1,2,3], [t[:a],t[:b],t[:c]]
|
195
195
|
|
196
|
+
t[:c] = 4
|
197
|
+
assert_equal [1,2,4], [t["a"],t["b"],t["c"]]
|
198
|
+
|
196
199
|
x = Record.new [1,2,3], :attributes => [:a,:b,:c]
|
197
200
|
assert_equal [1,2,3], [x[0],x[1],x[2]]
|
198
201
|
assert_equal [1,2,3], [x[:a],x[:b],x[:c]]
|
199
202
|
|
200
|
-
#FIXME: ...
|
201
|
-
|
202
203
|
assert_equal [1,2,3], [x["a"],x["b"],x["c"]]
|
203
204
|
assert_equal [1,2,3], [x.a,x.b,x.c]
|
204
205
|
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'ruport'
|
3
|
+
|
4
|
+
class DummyText < Ruport::Format::Plugin
|
5
|
+
def build_header
|
6
|
+
output << "header\n"
|
7
|
+
end
|
8
|
+
def build_body
|
9
|
+
output << "body\n"
|
10
|
+
end
|
11
|
+
def build_footer
|
12
|
+
output << "footer\n"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
class TrivialRenderer < Ruport::Renderer
|
18
|
+
add_format DummyText, :text
|
19
|
+
|
20
|
+
def run
|
21
|
+
plugin do
|
22
|
+
build_header
|
23
|
+
build_body
|
24
|
+
build_footer
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
class TestRenderer < Test::Unit::TestCase
|
32
|
+
|
33
|
+
def test_trivial
|
34
|
+
actual = TrivialRenderer.render(:text)
|
35
|
+
assert_equal "header\nbody\nfooter\n", actual
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_formats
|
39
|
+
assert_equal( {}, Ruport::Renderer.formats )
|
40
|
+
assert_equal( { :text => DummyText } , TrivialRenderer.formats )
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_try_require
|
44
|
+
assert_not_nil Ruport::Renderer.try_require(:csv)
|
45
|
+
assert_nil Ruport::Renderer.try_require(:not_a_plugin)
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_method_missing
|
49
|
+
actual = TrivialRenderer.render_text
|
50
|
+
assert_equal "header\nbody\nfooter\n", actual
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_plugin
|
54
|
+
# normal instance mode
|
55
|
+
|
56
|
+
rend = TrivialRenderer.new
|
57
|
+
rend.send(:use_plugin,:text)
|
58
|
+
|
59
|
+
assert_kind_of Ruport::Format::Plugin, rend.plugin
|
60
|
+
assert_kind_of DummyText, rend.plugin
|
61
|
+
|
62
|
+
# render mode
|
63
|
+
TrivialRenderer.render_text do |r|
|
64
|
+
assert_kind_of Ruport::Format::Plugin, r.plugin
|
65
|
+
assert_kind_of DummyText, r.plugin
|
66
|
+
end
|
67
|
+
|
68
|
+
assert_equal "body\n", rend.plugin { build_body }.output
|
69
|
+
|
70
|
+
rend.plugin.clear_output
|
71
|
+
assert_equal "", rend.plugin.output
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
data/test/test_report.rb
CHANGED
@@ -15,23 +15,19 @@ class TestReport < Test::Unit::TestCase
|
|
15
15
|
@query1 = Ruport::Query.new "select * from foo", :cache_enabled => true
|
16
16
|
@query1.cached_data = [[1,2,3],[4,5,6],[7,8,9]].to_table(%w[a b c])
|
17
17
|
end
|
18
|
-
|
19
|
-
def
|
20
|
-
|
21
|
-
|
22
|
-
assert_equal("
|
23
|
-
|
24
|
-
if defined? RedCloth
|
25
|
-
result = @report.process_text '"foo":http://foo.com',
|
26
|
-
:filters => [:red_cloth]
|
27
|
-
|
28
|
-
assert_equal('<p><a href="http://foo.com">foo</a></p>',result)
|
29
|
-
result = @report.process_text %{"<%= 2 + 3%>":http://foo.com },
|
30
|
-
:filters => [:erb, :red_cloth]
|
31
|
-
assert_equal('<p><a href="http://foo.com">5</a></p>',result)
|
32
|
-
end
|
18
|
+
|
19
|
+
def test_erb
|
20
|
+
@report = Report.new
|
21
|
+
@report.results = "foo"
|
22
|
+
assert_equal "foo", @report.erb("<%= @results %>")
|
23
|
+
assert_equal "foo\n4\n---\n", @report.erb("test/samples/foo.rtxt")
|
33
24
|
end
|
34
25
|
|
26
|
+
def test_textile
|
27
|
+
@report = Report.new
|
28
|
+
assert_equal "<p><strong>foo</strong></p>", @report.textile("*foo*")
|
29
|
+
end
|
30
|
+
|
35
31
|
def test_query
|
36
32
|
assert_kind_of Ruport::Data::Table,
|
37
33
|
@report.query("blah",:query_obj => @query1)
|
@@ -44,18 +40,13 @@ class TestReport < Test::Unit::TestCase
|
|
44
40
|
@report.query("blah",:query_obj => @query1, :as => :csv)
|
45
41
|
end
|
46
42
|
|
47
|
-
# ticket:86
|
48
|
-
def test_table_shortcut
|
49
|
-
# FIXME: Dinko, look at ticket and implement feature
|
50
|
-
end
|
51
|
-
|
52
43
|
class MyReport < Report; end
|
53
44
|
|
54
45
|
def test_klass_methods
|
55
46
|
rep_klass = MyReport.dup
|
56
|
-
rep_klass.prepare { self.file = "foo.csv" }
|
57
|
-
rep_klass.generate { "hello dolly" }
|
58
|
-
rep_klass.cleanup { @foo = "bar" }
|
47
|
+
rep_klass.send(:prepare) { self.file = "foo.csv" }
|
48
|
+
rep_klass.send(:generate) { "hello dolly" }
|
49
|
+
rep_klass.send(:cleanup) { @foo = "bar" }
|
59
50
|
report = rep_klass.new
|
60
51
|
report.run { |rep|
|
61
52
|
assert_equal("foo.csv",rep.file)
|
@@ -74,7 +65,7 @@ class TestReport < Test::Unit::TestCase
|
|
74
65
|
report1.file = "foo"
|
75
66
|
report2.file = "bar"
|
76
67
|
|
77
|
-
rep_klass.generate { file }
|
68
|
+
rep_klass.send(:generate) { file }
|
78
69
|
|
79
70
|
expected = %w[foo bar]
|
80
71
|
|
@@ -87,13 +78,13 @@ class TestReport < Test::Unit::TestCase
|
|
87
78
|
|
88
79
|
def test_timeout
|
89
80
|
rep_klass = MyReport.dup
|
90
|
-
rep_klass.generate { raise }
|
81
|
+
rep_klass.send(:generate) { raise }
|
91
82
|
|
92
83
|
assert_raises(RuntimeError){
|
93
84
|
rep_klass.run(:tries => 3, :interval => 1, :log_level => :log_only)
|
94
85
|
}
|
95
86
|
|
96
|
-
rep_klass.generate { sleep 1.1 }
|
87
|
+
rep_klass.send(:generate) { sleep 1.1 }
|
97
88
|
|
98
89
|
assert_raises(Timeout::Error) {
|
99
90
|
rep_klass.run( :tries => 2,
|
@@ -103,5 +94,17 @@ class TestReport < Test::Unit::TestCase
|
|
103
94
|
}
|
104
95
|
|
105
96
|
end
|
97
|
+
|
98
|
+
def test_return_value
|
99
|
+
rep_klass = MyReport.dup
|
100
|
+
rep_klass.send(:generate) { "hello dolly" }
|
101
|
+
|
102
|
+
# single report
|
103
|
+
assert_equal "hello dolly", rep_klass.run
|
104
|
+
|
105
|
+
# multiple reports
|
106
|
+
assert_equal ["hello dolly", "hello dolly"],
|
107
|
+
rep_klass.run(:reports => [rep_klass.new,rep_klass.new])
|
108
|
+
end
|
106
109
|
|
107
110
|
end
|
data/test/test_table.rb
CHANGED
@@ -284,24 +284,6 @@ class TestTable < Test::Unit::TestCase
|
|
284
284
|
assert_equal a,b
|
285
285
|
end
|
286
286
|
|
287
|
-
def test_array_hack
|
288
|
-
t = [[1,2],[3,4],[5,6]].to_table
|
289
|
-
assert_instance_of Ruport::Data::Table, t
|
290
|
-
assert_equal [], t.column_names
|
291
|
-
assert_equal Ruport::Data::Record.new([3,4]), t[1]
|
292
|
-
t = [[1,2],[3,4],[5,6]].to_table :column_names => %w[a b]
|
293
|
-
table = Ruport::Data::Table.new :column_names => %w[a b],
|
294
|
-
:data => [[1,2],[3,4],[5,6]]
|
295
|
-
|
296
|
-
assert_equal t, table
|
297
|
-
|
298
|
-
# test short form
|
299
|
-
table2 = [[1,2],[3,4],[5,6]].to_table %w[a b]
|
300
|
-
|
301
|
-
assert_equal table, table2
|
302
|
-
|
303
|
-
end
|
304
|
-
|
305
287
|
def test_ensure_coerce_sum
|
306
288
|
|
307
289
|
s = [["1"],["3"],["5"] ].to_table
|
@@ -312,17 +294,6 @@ class TestTable < Test::Unit::TestCase
|
|
312
294
|
|
313
295
|
end
|
314
296
|
|
315
|
-
def test_table_shortcut
|
316
|
-
self.class.send(:include,Ruport::Data::TableHelper)
|
317
|
-
|
318
|
-
a = table(%w[a b c]) do |t|
|
319
|
-
[[1,2,3],[4,5,6]].each { |r| t << r }
|
320
|
-
end
|
321
|
-
|
322
|
-
assert_equal([[1,2,3],[4,5,6]].to_table(%w[a b c]),a)
|
323
|
-
|
324
|
-
end
|
325
|
-
|
326
297
|
def test_setting_column_names_changes_record_attributes
|
327
298
|
table = Ruport::Data::Table.new :column_names => %w[a b c],
|
328
299
|
:data => [[1,2,3],[4,5,6]]
|
@@ -338,4 +309,58 @@ class TestTable < Test::Unit::TestCase
|
|
338
309
|
assert_equal %w[d e f], table.data[1].attributes
|
339
310
|
end
|
340
311
|
|
312
|
+
def test_sort_rows_by
|
313
|
+
table = Ruport::Data::Table.new :column_names => %w[a b c]
|
314
|
+
table << [1,2,3] << [6,1,8] << [9,1,4]
|
315
|
+
|
316
|
+
sorted_table_a = Ruport::Data::Table.new :column_names => %w[a b c]
|
317
|
+
sorted_table_a << [1,2,3] << [6,1,8] << [9,1,4]
|
318
|
+
|
319
|
+
sorted_table_b = Ruport::Data::Table.new :column_names => %w[a b c]
|
320
|
+
sorted_table_b << [6,1,8] << [9,1,4] << [1,2,3]
|
321
|
+
|
322
|
+
sorted_table_bc = Ruport::Data::Table.new :column_names => %w[a b c]
|
323
|
+
sorted_table_bc << [9,1,4] << [6,1,8] << [1,2,3]
|
324
|
+
|
325
|
+
assert_equal sorted_table_a, table.sort_rows_by {|r| r['a']}
|
326
|
+
assert_equal sorted_table_b, table.sort_rows_by(['b'])
|
327
|
+
assert_equal sorted_table_bc, table.sort_rows_by(['b', 'c'])
|
328
|
+
end
|
329
|
+
|
330
|
+
def test_array_hack
|
331
|
+
t = [[1,2],[3,4],[5,6]].to_table
|
332
|
+
assert_instance_of Ruport::Data::Table, t
|
333
|
+
assert_equal [], t.column_names
|
334
|
+
table = Ruport::Data::Table.new :column_names => %w[a b],
|
335
|
+
:data => [[1,2],[3,4],[5,6]]
|
336
|
+
|
337
|
+
table2 = [[1,2],[3,4],[5,6]].to_table %w[a b]
|
338
|
+
|
339
|
+
assert_equal table, table2
|
340
|
+
|
341
|
+
end
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
end
|
346
|
+
|
347
|
+
class TestTableKernelHack < Test::Unit::TestCase
|
348
|
+
|
349
|
+
def test_simple
|
350
|
+
assert_equal [].to_table(%w[a b c]), Table(%w[a b c])
|
351
|
+
assert_equal [].to_table(%w[a b c]), Table("a","b","c")
|
352
|
+
assert_equal Ruport::Data::Table.load("test/samples/addressbook.csv"),
|
353
|
+
Table("test/samples/addressbook.csv")
|
354
|
+
assert_equal Ruport::Data::Table.load(
|
355
|
+
"test/samples/addressbook.csv", :has_names => false),
|
356
|
+
Table('test/samples/addressbook.csv', :has_names => false)
|
357
|
+
Table("a","b","c") do |t|
|
358
|
+
t << [1,2,3]
|
359
|
+
assert_equal([[1,2,3]].to_table(%w[a b c]), t)
|
360
|
+
end
|
361
|
+
|
362
|
+
assert_equal Table("a"), Table(%w[a])
|
363
|
+
assert_equal Table(:a), Table([:a])
|
364
|
+
end
|
365
|
+
|
341
366
|
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require "test/unit"
|
2
|
+
require "ruport"
|
3
|
+
|
4
|
+
begin
|
5
|
+
require "rubygems"
|
6
|
+
rescue LoadError
|
7
|
+
nil
|
8
|
+
end
|
9
|
+
|
10
|
+
class TestTableRenderer < Test::Unit::TestCase
|
11
|
+
def test_render_csv_basic
|
12
|
+
actual = Ruport::Renderer::Table.render_csv { |r|
|
13
|
+
r.data = [[1,2,3],[4,5,6]].to_table
|
14
|
+
}
|
15
|
+
assert_equal("1,2,3\n4,5,6\n",actual)
|
16
|
+
|
17
|
+
actual = Ruport::Renderer::Table.render_csv { |r|
|
18
|
+
r.data = [[1,2,3],[4,5,6]].to_table(%w[a b c])
|
19
|
+
}
|
20
|
+
assert_equal("a,b,c\n1,2,3\n4,5,6\n",actual)
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_render_html_basic
|
24
|
+
actual = Ruport::Renderer::Table.render_html { |r|
|
25
|
+
r.data = [[1,2,3],[4,5,6]].to_table
|
26
|
+
}
|
27
|
+
assert_equal("\t<table>\n\t\t<tr>\n\t\t\t<td>1</td>\n\t\t\t<td>2"+
|
28
|
+
"</td>\n\t\t\t<td>3</td>\n\t\t</tr>\n\t\t<tr>\n\t\t"+
|
29
|
+
"\t<td>4</td>\n\t\t\t<td>5</td>\n\t\t\t<td>6</td>\n\t"+
|
30
|
+
"\t</tr>\n\t</table>",actual)
|
31
|
+
|
32
|
+
actual = Ruport::Renderer::Table.render_html { |r|
|
33
|
+
r.data = [[1,2,3],[4,5,6]].to_table(%w[a b c])
|
34
|
+
}
|
35
|
+
assert_equal("\t<table>\n\t\t<tr>\n\t\t\t<th>a</th>\n\t\t\t<th>b</th>"+
|
36
|
+
"\n\t\t\t<th>c</th>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td>1</td>"+
|
37
|
+
"\n\t\t\t<td>2</td>\n\t\t\t<td>3</td>\n\t\t</tr>\n\t\t<tr>"+
|
38
|
+
"\n\t\t\t<td>4</td>\n\t\t\t<td>5</td>\n\t\t\t<td>6</td>\n\t"+
|
39
|
+
"\t</tr>\n\t</table>",actual)
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_render_latex_basic
|
43
|
+
data = [[1,2,3,2],[3,4,5,6]].to_table(%w[a b c d])
|
44
|
+
output = data.to_latex
|
45
|
+
assert_equal "\\documentclass", output[/\\documentclass/]
|
46
|
+
assert_equal "\\begin{document}", output[/\\begin\{document\}/]
|
47
|
+
assert_equal "\\end{document}", output[/\\end\{document\}/]
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_render_pdf_basic
|
51
|
+
begin
|
52
|
+
require "pdf/writer"
|
53
|
+
rescue LoadError
|
54
|
+
warn "skipping pdf test"; return
|
55
|
+
end
|
56
|
+
data = [[1,2],[3,4]].to_table
|
57
|
+
assert_raise(RuntimeError) { data.to_pdf }
|
58
|
+
|
59
|
+
data.column_names = %w[a b]
|
60
|
+
assert_nothing_raised { data.to_pdf }
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_prune
|
64
|
+
actual = Ruport::Renderer::Table.render_csv { |r|
|
65
|
+
r.data = [[1,2,3],[1,5,6]].to_table(%w[a b c])
|
66
|
+
r.prune(1)
|
67
|
+
}
|
68
|
+
assert_equal("a,b,c\n1,2,3\n,5,6\n",actual)
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_num_cols
|
72
|
+
Ruport::Renderer::Table.render_csv { |r|
|
73
|
+
r.data = [[1,2,3],[4,5,6]].to_table
|
74
|
+
assert_equal 3, r.num_cols
|
75
|
+
}
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_rewrite_column
|
79
|
+
actual = Ruport::Renderer::Table.render_csv { |r|
|
80
|
+
r.data = [[1,2,3],[4,5,6]].to_table
|
81
|
+
r.rewrite_column(0) { |r| r[0]+r[1] }
|
82
|
+
}
|
83
|
+
assert_equal("3,2,3\n9,5,6\n",actual)
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_layout_header
|
87
|
+
actual = Ruport::Renderer::Table.render_csv { |r|
|
88
|
+
r.data = [[1,2,3],[4,5,6]].to_table(%w[a b c])
|
89
|
+
r.layout { |l| l.show_table_headers = false }
|
90
|
+
}
|
91
|
+
assert_equal("1,2,3\n4,5,6\n",actual)
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
class TextPluginTest < Test::Unit::TestCase
|
2
|
+
|
3
|
+
def test_basic
|
4
|
+
|
5
|
+
tf = "+-------+\n"
|
6
|
+
|
7
|
+
a = [[1,2],[3,4]].to_table.to_text
|
8
|
+
assert_equal("#{tf}| 1 | 2 |\n| 3 | 4 |\n#{tf}",a)
|
9
|
+
|
10
|
+
a = [[1,2],[3,4]].to_table(%w[a b]).to_text
|
11
|
+
assert_equal("#{tf}| a | b |\n#{tf}| 1 | 2 |\n| 3 | 4 |\n#{tf}", a)
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
def test_centering
|
17
|
+
tf = "+---------+\n"
|
18
|
+
|
19
|
+
a = [[1,2],[300,4]].to_table
|
20
|
+
assert_equal( "#{tf}| 1 | 2 |\n| 300 | 4 |\n#{tf}",
|
21
|
+
a.as(:text) { |e| e.layout.alignment = :center })
|
22
|
+
|
23
|
+
tf = "+------------+\n"
|
24
|
+
a.column_names = %w[a bark]
|
25
|
+
assert_equal("#{tf}| a | bark |\n#{tf}| 1 | 2 |\n"+
|
26
|
+
"| 300 | 4 |\n#{tf}",
|
27
|
+
a.as(:text) { |e| e.layout.alignment = :center })
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_justified
|
32
|
+
tf = "+----------+\n"
|
33
|
+
a = [[1,'Z'],[300,'BB']].to_table
|
34
|
+
assert_equal "#{tf}| 1 | Z |\n| 300 | BB |\n#{tf}", a.to_s
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_wrapping
|
38
|
+
a = [[1,2],[300,4]].to_table.as(:text) { |r|
|
39
|
+
r.layout { |l| l.table_width = 10 }
|
40
|
+
}
|
41
|
+
|
42
|
+
assert_equal("+------->>\n| 1 | >>\n| 300 | >>\n+------->>\n",a)
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
def test_make_sure_this_damn_column_names_bug_dies_a_horrible_death!
|
47
|
+
a = [[1,2,3]].to_table.to_text
|
48
|
+
expected = "+-----------+\n"+
|
49
|
+
"| 1 | 2 | 3 |\n"+
|
50
|
+
"+-----------+\n"
|
51
|
+
assert_equal(expected,a)
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_raise_error_on_empty_table
|
56
|
+
assert_raise(RuntimeError) { [].to_table.to_text }
|
57
|
+
assert_raise(RuntimeError) { [].to_table(%w[a b c]).to_text }
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
end
|
data/test/unit.log
CHANGED
@@ -233,3 +233,27 @@ F, [2006-11-23T13:50:02.728977 #3497] FATAL -- : no block given!
|
|
233
233
|
W, [2006-11-23T13:50:03.082515 #3497] WARN -- : Error on attempt # 1: ; retrying
|
234
234
|
W, [2006-11-23T13:50:04.079439 #3497] WARN -- : Error on attempt # 2: ; retrying
|
235
235
|
W, [2006-11-23T13:50:06.084182 #3497] WARN -- : Error on attempt # 1: execution expired; retrying
|
236
|
+
F, [2006-12-01T23:34:53.802091 #2653] FATAL -- : Missing host for mailer bar
|
237
|
+
F, [2006-12-01T23:34:53.826491 #2653] FATAL -- : Missing DSN for source foo!
|
238
|
+
F, [2006-12-01T23:34:57.241816 #2653] FATAL -- : no block given!
|
239
|
+
W, [2006-12-01T23:34:57.503488 #2653] WARN -- : Error on attempt # 1: ; retrying
|
240
|
+
W, [2006-12-01T23:34:58.500008 #2653] WARN -- : Error on attempt # 2: ; retrying
|
241
|
+
W, [2006-12-01T23:35:00.504711 #2653] WARN -- : Error on attempt # 1: execution expired; retrying
|
242
|
+
F, [2006-12-01T23:35:06.262963 #2664] FATAL -- : Missing host for mailer bar
|
243
|
+
F, [2006-12-01T23:35:06.264336 #2664] FATAL -- : Missing DSN for source foo!
|
244
|
+
F, [2006-12-01T23:35:09.310532 #2664] FATAL -- : no block given!
|
245
|
+
W, [2006-12-01T23:35:09.568074 #2664] WARN -- : Error on attempt # 1: ; retrying
|
246
|
+
W, [2006-12-01T23:35:10.564755 #2664] WARN -- : Error on attempt # 2: ; retrying
|
247
|
+
W, [2006-12-01T23:35:12.569504 #2664] WARN -- : Error on attempt # 1: execution expired; retrying
|
248
|
+
F, [2006-12-25T12:11:41.112026 #2855] FATAL -- : Missing host for mailer bar
|
249
|
+
F, [2006-12-25T12:11:41.150055 #2855] FATAL -- : Missing DSN for source foo!
|
250
|
+
F, [2006-12-25T12:11:41.738875 #2855] FATAL -- : no block given!
|
251
|
+
W, [2006-12-25T12:11:42.001759 #2855] WARN -- : Error on attempt # 1: ; retrying
|
252
|
+
W, [2006-12-25T12:11:43.000526 #2855] WARN -- : Error on attempt # 2: ; retrying
|
253
|
+
W, [2006-12-25T12:11:45.005285 #2855] WARN -- : Error on attempt # 1: execution expired; retrying
|
254
|
+
F, [2006-12-25T12:16:59.547807 #2969] FATAL -- : Missing host for mailer bar
|
255
|
+
F, [2006-12-25T12:16:59.549255 #2969] FATAL -- : Missing DSN for source foo!
|
256
|
+
F, [2006-12-25T12:16:59.960464 #2969] FATAL -- : no block given!
|
257
|
+
W, [2006-12-25T12:17:00.167594 #2969] WARN -- : Error on attempt # 1: ; retrying
|
258
|
+
W, [2006-12-25T12:17:01.164421 #2969] WARN -- : Error on attempt # 2: ; retrying
|
259
|
+
W, [2006-12-25T12:17:02.572305 #2969] WARN -- : Error on attempt # 1: ; retrying
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: ruport
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2006-
|
6
|
+
version: 0.7.0
|
7
|
+
date: 2006-12-25 00:00:00 -05:00
|
8
8
|
summary: A generalized Ruby report generation and templating engine.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -29,26 +29,12 @@ post_install_message:
|
|
29
29
|
authors:
|
30
30
|
- Gregory Brown
|
31
31
|
files:
|
32
|
-
- examples/
|
33
|
-
- examples/line_plotter.rb
|
34
|
-
- examples/sample_invoice_report.rb
|
35
|
-
- examples/line_graph_report.rb
|
36
|
-
- examples/latex_table.rb
|
37
|
-
- examples/text_processors.rb
|
38
|
-
- examples/new_plugin.rb
|
39
|
-
- examples/sql_erb.rb
|
40
|
-
- examples/line_graph.rb
|
32
|
+
- examples/pdf_complex_report.rb
|
41
33
|
- examples/line_graph_report.rb~
|
42
|
-
- examples/basic_grouping.rb
|
43
|
-
- examples/long.txt
|
44
|
-
- examples/report.rb
|
45
|
-
- examples/simple_mail.rb
|
46
|
-
- examples/template.rb
|
47
|
-
- examples/simple_table_interface.rb
|
48
34
|
- examples/line_graph_report.rb.rej
|
49
35
|
- lib/ruport
|
50
|
-
- lib/ruport.rb
|
51
36
|
- lib/uport.rb
|
37
|
+
- lib/ruport.rb
|
52
38
|
- lib/ruport.rb~
|
53
39
|
- lib/ruport/query
|
54
40
|
- lib/ruport/format
|
@@ -57,78 +43,75 @@ files:
|
|
57
43
|
- lib/ruport/system_extensions.rb
|
58
44
|
- lib/ruport/config.rb
|
59
45
|
- lib/ruport/query.rb
|
60
|
-
- lib/ruport/
|
61
|
-
- lib/ruport/
|
46
|
+
- lib/ruport/layout.rb
|
47
|
+
- lib/ruport/renderer
|
62
48
|
- lib/ruport/data.rb
|
63
49
|
- lib/ruport/mailer.rb
|
64
50
|
- lib/ruport/report.rb
|
65
51
|
- lib/ruport/attempt.rb
|
66
52
|
- lib/ruport/data.rb~
|
67
53
|
- lib/ruport/data.rb.rej
|
54
|
+
- lib/ruport/generator.rb
|
55
|
+
- lib/ruport/layout
|
56
|
+
- lib/ruport/format.rb
|
57
|
+
- lib/ruport/renderer.rb
|
68
58
|
- lib/ruport/query/sql_split.rb
|
69
|
-
- lib/ruport/format/
|
70
|
-
- lib/ruport/format/plugin
|
59
|
+
- lib/ruport/format/latex.rb
|
71
60
|
- lib/ruport/format/plugin.rb
|
72
|
-
- lib/ruport/format/
|
73
|
-
- lib/ruport/format/
|
74
|
-
- lib/ruport/format/
|
75
|
-
- lib/ruport/format/
|
76
|
-
- lib/ruport/format/
|
77
|
-
- lib/ruport/format/
|
78
|
-
- lib/ruport/format/plugin/html_plugin.rb
|
79
|
-
- lib/ruport/format/plugin/text_plugin.rb
|
80
|
-
- lib/ruport/format/plugin/pdf_plugin.rb
|
81
|
-
- lib/ruport/format/plugin/csv_plugin.rb
|
82
|
-
- lib/ruport/format/plugin/latex_plugin.rb
|
83
|
-
- lib/ruport/data/collection.rb
|
61
|
+
- lib/ruport/format/svg.rb
|
62
|
+
- lib/ruport/format/xml.rb
|
63
|
+
- lib/ruport/format/html.rb
|
64
|
+
- lib/ruport/format/text.rb
|
65
|
+
- lib/ruport/format/pdf.rb
|
66
|
+
- lib/ruport/format/csv.rb
|
84
67
|
- lib/ruport/data/record.rb
|
85
68
|
- lib/ruport/data/taggable.rb
|
86
69
|
- lib/ruport/data/table.rb
|
87
|
-
- lib/ruport/data/
|
70
|
+
- lib/ruport/data/collection.rb
|
88
71
|
- lib/ruport/data/set.rb
|
72
|
+
- lib/ruport/data/groupable.rb
|
89
73
|
- lib/ruport/data/table.rb~
|
90
74
|
- lib/ruport/data/table.rb.rej
|
91
75
|
- lib/ruport/data/record.rb~
|
92
|
-
- lib/ruport/report/invoice.rb
|
93
76
|
- lib/ruport/report/graph.rb
|
77
|
+
- lib/ruport/renderer/graph.rb
|
78
|
+
- lib/ruport/renderer/table.rb
|
79
|
+
- lib/ruport/layout/component.rb
|
94
80
|
- test/samples
|
95
|
-
- test/test_collection.rb
|
96
81
|
- test/test_record.rb
|
97
|
-
- test/ts_all.rb
|
98
82
|
- test/test_table.rb
|
99
|
-
- test/
|
83
|
+
- test/test_renderer.rb
|
100
84
|
- test/test_ruport.rb
|
101
|
-
- test/
|
85
|
+
- test/test_collection.rb
|
102
86
|
- test/test_set.rb
|
87
|
+
- test/test_groupable.rb
|
88
|
+
- test/test_graph_renderer.rb
|
103
89
|
- test/_test_database.rb
|
104
|
-
- test/test_plugin.rb
|
105
|
-
- test/test_graph.rb
|
106
|
-
- test/test_meta_tools.rb
|
107
90
|
- test/test_query.rb
|
108
91
|
- test/test_config.rb
|
109
|
-
- test/
|
92
|
+
- test/test_text_table.rb
|
110
93
|
- test/test_taggable.rb
|
111
94
|
- test/test_mailer.rb
|
112
|
-
- test/
|
95
|
+
- test/test_sql_split.rb
|
113
96
|
- test/test_report.rb
|
114
|
-
- test/
|
97
|
+
- test/test_table_renderer.rb
|
115
98
|
- test/unit.log
|
116
|
-
- test/
|
117
|
-
- test/_test_groupable.rb
|
118
|
-
- test/test_groupable.rb
|
99
|
+
- test/test_record.rb.rej
|
119
100
|
- test/test_table.rb~
|
120
101
|
- test/test_query.rb~
|
121
102
|
- test/test_query.rb.rej
|
122
|
-
- test/samples/query_test.sql
|
123
103
|
- test/samples/test.yaml
|
124
|
-
- test/samples/
|
104
|
+
- test/samples/query_test.sql
|
125
105
|
- test/samples/data.csv
|
106
|
+
- test/samples/erb_test.sql
|
126
107
|
- test/samples/stonecodeblog.sql
|
127
108
|
- test/samples/ruport_test.sql
|
128
109
|
- test/samples/addressbook.csv
|
129
110
|
- test/samples/document.xml
|
130
111
|
- test/samples/test.sql
|
131
112
|
- test/samples/data.tsv
|
113
|
+
- test/samples/foo.rtxt
|
114
|
+
- test/samples/dates.csv
|
132
115
|
- bin/rope
|
133
116
|
- Rakefile
|
134
117
|
- setup.rb
|
@@ -136,27 +119,23 @@ files:
|
|
136
119
|
- LICENSE
|
137
120
|
- TODO
|
138
121
|
- AUTHORS
|
139
|
-
- CHANGELOG
|
140
122
|
test_files:
|
141
|
-
- test/test_collection.rb
|
142
123
|
- test/test_record.rb
|
143
124
|
- test/test_table.rb
|
144
|
-
- test/
|
125
|
+
- test/test_renderer.rb
|
145
126
|
- test/test_ruport.rb
|
146
|
-
- test/
|
127
|
+
- test/test_collection.rb
|
147
128
|
- test/test_set.rb
|
148
|
-
- test/
|
149
|
-
- test/
|
150
|
-
- test/test_meta_tools.rb
|
129
|
+
- test/test_groupable.rb
|
130
|
+
- test/test_graph_renderer.rb
|
151
131
|
- test/test_query.rb
|
152
132
|
- test/test_config.rb
|
153
|
-
- test/
|
133
|
+
- test/test_text_table.rb
|
154
134
|
- test/test_taggable.rb
|
155
135
|
- test/test_mailer.rb
|
136
|
+
- test/test_sql_split.rb
|
156
137
|
- test/test_report.rb
|
157
|
-
- test/
|
158
|
-
- test/test_format_engine.rb
|
159
|
-
- test/test_groupable.rb
|
138
|
+
- test/test_table_renderer.rb
|
160
139
|
rdoc_options:
|
161
140
|
- --title
|
162
141
|
- Ruport Documentation
|
@@ -168,7 +147,6 @@ extra_rdoc_files:
|
|
168
147
|
- LICENSE
|
169
148
|
- TODO
|
170
149
|
- AUTHORS
|
171
|
-
- CHANGELOG
|
172
150
|
executables:
|
173
151
|
- rope
|
174
152
|
extensions: []
|