ruport 1.7.1 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +38 -0
  3. data/HACKING +1 -17
  4. data/{README.rdoc → README.md} +30 -38
  5. data/Rakefile +0 -10
  6. data/examples/row_renderer.rb +1 -1
  7. data/examples/simple_pdf_lines.rb +1 -1
  8. data/examples/trac_ticket_status.rb +1 -1
  9. data/lib/ruport/controller.rb +1 -1
  10. data/lib/ruport/data/grouping.rb +7 -7
  11. data/lib/ruport/data/record.rb +4 -4
  12. data/lib/ruport/data/table.rb +9 -9
  13. data/lib/ruport/formatter/csv.rb +1 -1
  14. data/lib/ruport/formatter/markdown.rb +105 -0
  15. data/lib/ruport/formatter/prawn_pdf.rb +96 -9
  16. data/lib/ruport/formatter/text.rb +1 -1
  17. data/lib/ruport/formatter.rb +1 -2
  18. data/lib/ruport/version.rb +1 -1
  19. data/lib/ruport.rb +7 -11
  20. data/test/controller_test.rb +107 -109
  21. data/test/csv_formatter_test.rb +21 -21
  22. data/test/data_feeder_test.rb +39 -39
  23. data/test/expected_outputs/prawn_pdf_formatter/pdf_basic.pdf.test +265 -0
  24. data/test/grouping_test.rb +74 -74
  25. data/test/helpers.rb +16 -5
  26. data/test/html_formatter_test.rb +22 -22
  27. data/test/markdown_formatter_test.rb +142 -0
  28. data/test/prawn_pdf_formatter_test.rb +108 -0
  29. data/test/record_test.rb +82 -82
  30. data/test/table_pivot_test.rb +9 -2
  31. data/test/table_test.rb +33 -40
  32. data/test/template_test.rb +12 -12
  33. data/test/text_formatter_test.rb +34 -34
  34. data/util/bench/data/table/bench_column_manip.rb +0 -1
  35. data/util/bench/data/table/bench_dup.rb +0 -1
  36. data/util/bench/data/table/bench_init.rb +0 -1
  37. data/util/bench/data/table/bench_manip.rb +0 -1
  38. data/util/bench/formatter/bench_csv.rb +0 -1
  39. data/util/bench/formatter/bench_html.rb +0 -1
  40. data/util/bench/formatter/bench_pdf.rb +0 -1
  41. data/util/bench/formatter/bench_text.rb +0 -1
  42. metadata +30 -29
  43. data/lib/ruport/formatter/pdf.rb +0 -589
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby -w
1
+ #!/usr/bin/env ruby -w
2
2
  require File.join(File.expand_path(File.dirname(__FILE__)), "helpers")
3
3
 
4
4
  class TestRenderCSVRow < Minitest::Test
@@ -9,7 +9,7 @@ class TestRenderCSVRow < Minitest::Test
9
9
  end
10
10
 
11
11
  class TestRenderCSVTable < Minitest::Test
12
-
12
+
13
13
  def setup
14
14
  Ruport::Formatter::Template.create(:simple) do |format|
15
15
  format.table = {
@@ -24,7 +24,7 @@ class TestRenderCSVTable < Minitest::Test
24
24
  end
25
25
 
26
26
  def test_render_csv_table
27
- actual = Ruport::Controller::Table.render_csv do |r|
27
+ actual = Ruport::Controller::Table.render_csv do |r|
28
28
  r.data = Ruport.Table([], :data => [[1,2,3],[4,5,6]])
29
29
  end
30
30
  assert_equal("1,2,3\n4,5,6\n",actual)
@@ -33,32 +33,32 @@ class TestRenderCSVTable < Minitest::Test
33
33
  r.data = Ruport.Table(%w[a b c], :data => [[1,2,3],[4,5,6]])
34
34
  end
35
35
  assert_equal("a,b,c\n1,2,3\n4,5,6\n",actual)
36
- end
37
-
36
+ end
37
+
38
38
  def test_format_options
39
39
  a = Ruport.Table(%w[a b c], :data => [[1,2,3],[4,5,6]])
40
- assert_equal "a\tb\tc\n1\t2\t3\n4\t5\t6\n",
40
+ assert_equal "a\tb\tc\n1\t2\t3\n4\t5\t6\n",
41
41
  a.as(:csv,:format_options => { :col_sep => "\t" })
42
42
  end
43
43
 
44
44
  def test_table_headers
45
45
  actual = Ruport::Controller::Table.
46
- render_csv(:show_table_headers => false,
46
+ render_csv(:show_table_headers => false,
47
47
  :data => Ruport.Table(%w[a b c], :data => [[1,2,3],[4,5,6]]))
48
48
  assert_equal("1,2,3\n4,5,6\n",actual)
49
49
  end
50
-
50
+
51
51
  def test_render_with_template
52
52
  formatter = Ruport::Formatter::CSV.new
53
53
  formatter.options = Ruport::Controller::Options.new
54
54
  formatter.options.template = :simple
55
55
  formatter.apply_template
56
-
56
+
57
57
  assert_equal false, formatter.options.show_table_headers
58
58
 
59
59
  assert_equal :justified, formatter.options.style
60
60
  assert_equal false, formatter.options.show_group_headers
61
-
61
+
62
62
  assert_equal ":", formatter.options.format_options[:col_sep]
63
63
  end
64
64
 
@@ -77,7 +77,7 @@ class TestRenderCSVTable < Minitest::Test
77
77
  ) do |r|
78
78
  opts = r.options
79
79
  end
80
-
80
+
81
81
  assert_equal true, opts.show_table_headers
82
82
 
83
83
  assert_equal :raw, opts.style
@@ -96,15 +96,15 @@ class TestRenderCSVTable < Minitest::Test
96
96
  ) do |r|
97
97
  opts = r.options
98
98
  end
99
-
99
+
100
100
  assert_equal true, opts.show_table_headers
101
101
 
102
102
  assert_equal :raw, opts.style
103
103
  assert_equal true, opts.show_group_headers
104
-
104
+
105
105
  assert_equal ";", opts.format_options[:col_sep]
106
106
  end
107
- end
107
+ end
108
108
 
109
109
  class TestRenderCSVGroup < Minitest::Test
110
110
 
@@ -115,8 +115,8 @@ class TestRenderCSVGroup < Minitest::Test
115
115
  actual = Ruport::Controller::Group.
116
116
  render_csv(:data => group, :show_table_headers => false )
117
117
  assert_equal("test\n\n1,2,3\n4,5,6\n",actual)
118
- end
119
-
118
+ end
119
+
120
120
  end
121
121
 
122
122
  class RenderCSVGrouping < Minitest::Test
@@ -138,25 +138,25 @@ class RenderCSVGrouping < Minitest::Test
138
138
  actual = grouping.to_csv :show_table_headers => false
139
139
 
140
140
  assert_equal "is\n\nthis,annoying\nit,funny\n\n", actual
141
- end
141
+ end
142
142
 
143
143
  def test_alternative_styles
144
144
  g = Grouping((Ruport.Table(%w[a b c]) << [1,2,3] << [1,1,4] <<
145
145
  [2,1,2] << [1,9,1] ), :by => "a")
146
-
146
+
147
147
  assert_raises(NotImplementedError) { g.to_csv :style => :not_real }
148
148
 
149
- assert_equal "a,b,c\n1,2,3\n,1,4\n,9,1\n\n2,1,2\n\n",
149
+ assert_equal "a,b,c\n1,2,3\n,1,4\n,9,1\n\n2,1,2\n\n",
150
150
  g.to_csv(:style => :justified)
151
151
 
152
152
  assert_equal "a,b,c\n1,2,3\n1,1,4\n1,9,1\n\n2,1,2\n\n",
153
- g.to_csv(:style => :raw)
153
+ g.to_csv(:style => :raw)
154
154
  end
155
155
 
156
156
  # -----------------------------------------------------------------------
157
157
  # BUG TRAPS
158
158
  # ------------------------------------------------------------------------
159
-
159
+
160
160
  def test_ensure_group_names_are_converted_to_string
161
161
  g = Grouping((Ruport.Table(%w[a b c])<<[1,2,3]<<[1,1,4]), :by => "a")
162
162
  assert_equal "1\n\nb,c\n2,3\n1,4\n\n", g.to_csv
@@ -1,88 +1,88 @@
1
- #!/usr/bin/env ruby -w
2
- require File.join(File.expand_path(File.dirname(__FILE__)), "helpers")
1
+ #!/usr/bin/env ruby -w
2
+ require File.join(File.expand_path(File.dirname(__FILE__)), "helpers")
3
3
 
4
4
  class DataFeederTest < Minitest::Test
5
-
5
+
6
6
  context "when using a default data feeder" do
7
-
7
+
8
8
  setup do
9
9
  @feeder = Ruport::Data::Feeder.new(Ruport.Table(%w[a b c]))
10
- end
11
-
10
+ end
11
+
12
12
  should "data attribute should return wrapped data" do
13
13
  assert_equal Ruport.Table(%w[a b c]), @feeder.data
14
14
  end
15
-
15
+
16
16
  should "append should forward to wrapped data by default" do
17
17
  t = Ruport.Table(%w[a b c])
18
18
  t << [1,2,3] << {"a" => 2, "b" => 3, "c" => 4}
19
- @feeder << [1,2,3] << {"a" => 2, "b" => 3, "c" => 4}
20
- assert_equal t, @feeder.data
21
- end
22
-
23
- end
24
-
19
+ @feeder << [1,2,3] << {"a" => 2, "b" => 3, "c" => 4}
20
+ assert_equal t, @feeder.data
21
+ end
22
+
23
+ end
24
+
25
25
  context "when using a feeder with a filter" do
26
- setup do
26
+ setup do
27
27
  @feeder = Ruport::Data::Feeder.new(Ruport.Table(%w[a b c]))
28
28
  @feeder.filter { |r| r.a != 1 }
29
- end
30
-
29
+ end
30
+
31
31
  should "filter should only append rows for which block is true" do
32
32
  @feeder << [1,2,3] << [4,1,2] << [3,1,1] << [1,2,5]
33
33
  assert_equal Ruport.Table(%w[a b c], :data => [[4,1,2],[3,1,1]]), @feeder.data
34
34
  end
35
- end
36
-
35
+ end
36
+
37
37
  context "when using a feeder with a transform" do
38
38
  setup do
39
39
  @feeder = Ruport::Data::Feeder.new(Ruport.Table(%w[a b c]))
40
40
  @feeder.transform { |r| r.a += 1 }
41
41
  end
42
-
42
+
43
43
  should "filter should be applied to all rows" do
44
44
  @feeder << [1,2,3] << [4,1,2] << [3,1,1] << [1,2,5]
45
45
  assert_equal Ruport.Table(%w[a b c], :data => [[2,2,3],[5,1,2],[4,1,1],[2,2,5]]),
46
46
  @feeder.data
47
- end
48
- end
49
-
47
+ end
48
+ end
49
+
50
50
  context "when using a feeder and a filter together" do
51
51
  setup do
52
52
  @feeder = Ruport::Data::Feeder.new(Ruport.Table(%w[a b c]))
53
- end
54
-
53
+ end
54
+
55
55
  should "filter is called first when defined first" do
56
56
  @feeder.filter { |r| r.b != 2 }
57
57
  @feeder.transform { |r| r.b += 1 }
58
- @feeder << [1,2,3] << [4,1,2] << [3,1,1] << [1,2,5]
58
+ @feeder << [1,2,3] << [4,1,2] << [3,1,1] << [1,2,5]
59
59
  assert_equal Ruport.Table(%w[a b c], :data => [[4,2,2],[3,2,1]]),
60
60
  @feeder.data
61
61
  end
62
-
62
+
63
63
  should "transform is called first when defined first" do
64
- @feeder.transform { |r| r.b += 1 }
65
- @feeder.filter { |r| r.b != 2 }
66
- @feeder << [1,2,3] << [4,1,2] << [3,1,1] << [1,2,5]
64
+ @feeder.transform { |r| r.b += 1 }
65
+ @feeder.filter { |r| r.b != 2 }
66
+ @feeder << [1,2,3] << [4,1,2] << [3,1,1] << [1,2,5]
67
67
  assert_equal Ruport.Table(%w[a b c], :data => [[1,3,3],[1,3,5]]),
68
68
  @feeder.data
69
- end
70
- end
71
-
69
+ end
70
+ end
71
+
72
72
  context "when using many feeders and filters together" do
73
73
  setup do
74
74
  @feeder = Ruport::Data::Feeder.new(Ruport.Table(%w[a b c]))
75
- @feeder.transform { |r| r.a += 1 }
75
+ @feeder.transform { |r| r.a += 1 }
76
76
  @feeder.filter { |r| r.a > 5 }
77
- @feeder.transform { |r| r.b = r.b.to_s }
78
- @feeder.filter { |r| r.b == "3" }
77
+ @feeder.transform { |r| r.b = r.b.to_s }
78
+ @feeder.filter { |r| r.b == "3" }
79
79
  end
80
-
80
+
81
81
  should "all blocks are executed in order" do
82
- @feeder << [1,2,3] << [4,1,9] << [5,3,1] << [2,3,0] << [7,3,5]
82
+ @feeder << [1,2,3] << [4,1,9] << [5,3,1] << [2,3,0] << [7,3,5]
83
83
  assert_equal Ruport.Table(%w[a b c], :data => [[6,"3",1],[8,"3",5]]),
84
84
  @feeder.data
85
- end
85
+ end
86
86
  end
87
-
87
+
88
88
  end
@@ -0,0 +1,265 @@
1
+ %PDF-1.3
2
+ %����
3
+ 1 0 obj
4
+ << /Creator <feff0050007200610077006e>
5
+ /Producer <feff0050007200610077006e>
6
+ >>
7
+ endobj
8
+ 2 0 obj
9
+ << /Type /Catalog
10
+ /Pages 3 0 R
11
+ >>
12
+ endobj
13
+ 3 0 obj
14
+ << /Type /Pages
15
+ /Count 1
16
+ /Kids [5 0 R]
17
+ >>
18
+ endobj
19
+ 4 0 obj
20
+ << /Length 1894
21
+ >>
22
+ stream
23
+ q
24
+ 1 w
25
+ /DeviceRGB CS
26
+ 0.0 0.0 0.0 SCN
27
+ 36.0 756.0 m
28
+ 52.672 756.0 l
29
+ S
30
+ [] 0 d
31
+ 1 w
32
+ 0.0 0.0 0.0 SCN
33
+ 36.0 732.128 m
34
+ 52.672 732.128 l
35
+ S
36
+ [] 0 d
37
+ 1 w
38
+ 0.0 0.0 0.0 SCN
39
+ 36.0 756.5 m
40
+ 36.0 731.628 l
41
+ S
42
+ [] 0 d
43
+ 1 w
44
+ 0.0 0.0 0.0 SCN
45
+ 52.672 756.5 m
46
+ 52.672 731.628 l
47
+ S
48
+ [] 0 d
49
+ 1 w
50
+ 0.0 0.0 0.0 SCN
51
+
52
+ BT
53
+ 41.0 739.756 Td
54
+ /F1.0 12 Tf
55
+ [<61>] TJ
56
+ ET
57
+
58
+ 1 w
59
+ 0.0 0.0 0.0 SCN
60
+ 52.672 756.0 m
61
+ 69.344 756.0 l
62
+ S
63
+ [] 0 d
64
+ 1 w
65
+ 0.0 0.0 0.0 SCN
66
+ 52.672 732.128 m
67
+ 69.344 732.128 l
68
+ S
69
+ [] 0 d
70
+ 1 w
71
+ 0.0 0.0 0.0 SCN
72
+ 52.672 756.5 m
73
+ 52.672 731.628 l
74
+ S
75
+ [] 0 d
76
+ 1 w
77
+ 0.0 0.0 0.0 SCN
78
+ 69.344 756.5 m
79
+ 69.344 731.628 l
80
+ S
81
+ [] 0 d
82
+ 1 w
83
+ 0.0 0.0 0.0 SCN
84
+
85
+ BT
86
+ 57.672 739.756 Td
87
+ /F1.0 12 Tf
88
+ [<62>] TJ
89
+ ET
90
+
91
+ 1 w
92
+ 0.0 0.0 0.0 SCN
93
+ 69.344 756.0 m
94
+ 86.016 756.0 l
95
+ S
96
+ [] 0 d
97
+ 1 w
98
+ 0.0 0.0 0.0 SCN
99
+ 69.344 732.128 m
100
+ 86.016 732.128 l
101
+ S
102
+ [] 0 d
103
+ 1 w
104
+ 0.0 0.0 0.0 SCN
105
+ 69.344 756.5 m
106
+ 69.344 731.628 l
107
+ S
108
+ [] 0 d
109
+ 1 w
110
+ 0.0 0.0 0.0 SCN
111
+ 86.016 756.5 m
112
+ 86.016 731.628 l
113
+ S
114
+ [] 0 d
115
+ 1 w
116
+ 0.0 0.0 0.0 SCN
117
+
118
+ BT
119
+ 74.344 739.756 Td
120
+ /F1.0 12 Tf
121
+ [<63>] TJ
122
+ ET
123
+
124
+ 1 w
125
+ 0.0 0.0 0.0 SCN
126
+ 36.0 732.128 m
127
+ 52.672 732.128 l
128
+ S
129
+ [] 0 d
130
+ 1 w
131
+ 0.0 0.0 0.0 SCN
132
+ 36.0 708.256 m
133
+ 52.672 708.256 l
134
+ S
135
+ [] 0 d
136
+ 1 w
137
+ 0.0 0.0 0.0 SCN
138
+ 36.0 732.628 m
139
+ 36.0 707.756 l
140
+ S
141
+ [] 0 d
142
+ 1 w
143
+ 0.0 0.0 0.0 SCN
144
+ 52.672 732.628 m
145
+ 52.672 707.756 l
146
+ S
147
+ [] 0 d
148
+ 1 w
149
+ 0.0 0.0 0.0 SCN
150
+
151
+ BT
152
+ 41.0 715.884 Td
153
+ /F1.0 12 Tf
154
+ [<31>] TJ
155
+ ET
156
+
157
+ 1 w
158
+ 0.0 0.0 0.0 SCN
159
+ 52.672 732.128 m
160
+ 69.344 732.128 l
161
+ S
162
+ [] 0 d
163
+ 1 w
164
+ 0.0 0.0 0.0 SCN
165
+ 52.672 708.256 m
166
+ 69.344 708.256 l
167
+ S
168
+ [] 0 d
169
+ 1 w
170
+ 0.0 0.0 0.0 SCN
171
+ 52.672 732.628 m
172
+ 52.672 707.756 l
173
+ S
174
+ [] 0 d
175
+ 1 w
176
+ 0.0 0.0 0.0 SCN
177
+ 69.344 732.628 m
178
+ 69.344 707.756 l
179
+ S
180
+ [] 0 d
181
+ 1 w
182
+ 0.0 0.0 0.0 SCN
183
+
184
+ BT
185
+ 57.672 715.884 Td
186
+ /F1.0 12 Tf
187
+ [<32>] TJ
188
+ ET
189
+
190
+ 1 w
191
+ 0.0 0.0 0.0 SCN
192
+ 69.344 732.128 m
193
+ 86.016 732.128 l
194
+ S
195
+ [] 0 d
196
+ 1 w
197
+ 0.0 0.0 0.0 SCN
198
+ 69.344 708.256 m
199
+ 86.016 708.256 l
200
+ S
201
+ [] 0 d
202
+ 1 w
203
+ 0.0 0.0 0.0 SCN
204
+ 69.344 732.628 m
205
+ 69.344 707.756 l
206
+ S
207
+ [] 0 d
208
+ 1 w
209
+ 0.0 0.0 0.0 SCN
210
+ 86.016 732.628 m
211
+ 86.016 707.756 l
212
+ S
213
+ [] 0 d
214
+ 1 w
215
+ 0.0 0.0 0.0 SCN
216
+
217
+ BT
218
+ 74.344 715.884 Td
219
+ /F1.0 12 Tf
220
+ [<33>] TJ
221
+ ET
222
+
223
+ Q
224
+
225
+ endstream
226
+ endobj
227
+ 5 0 obj
228
+ << /Type /Page
229
+ /Parent 3 0 R
230
+ /MediaBox [0 0 612 792]
231
+ /CropBox [0 0 612 792]
232
+ /BleedBox [0 0 612 792]
233
+ /TrimBox [0 0 612 792]
234
+ /ArtBox [0 0 612 792]
235
+ /Contents 4 0 R
236
+ /Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
237
+ /Font << /F1.0 6 0 R
238
+ >>
239
+ >>
240
+ >>
241
+ endobj
242
+ 6 0 obj
243
+ << /Type /Font
244
+ /Subtype /Type1
245
+ /BaseFont /Helvetica
246
+ /Encoding /WinAnsiEncoding
247
+ >>
248
+ endobj
249
+ xref
250
+ 0 7
251
+ 0000000000 65535 f
252
+ 0000000015 00000 n
253
+ 0000000109 00000 n
254
+ 0000000158 00000 n
255
+ 0000000215 00000 n
256
+ 0000002161 00000 n
257
+ 0000002427 00000 n
258
+ trailer
259
+ << /Size 7
260
+ /Root 2 0 R
261
+ /Info 1 0 R
262
+ >>
263
+ startxref
264
+ 2524
265
+ %%EOF