ruport 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. data/LICENSE +55 -9
  2. data/Rakefile +3 -5
  3. data/examples/line_plotter.rb +3 -0
  4. data/examples/pdf_complex_report.rb +0 -1
  5. data/examples/pdf_report_with_common_base.rb +72 -0
  6. data/examples/pdf_styles.rb +16 -0
  7. data/examples/simple_pdf_lines.rb +0 -1
  8. data/lib/ruport.rb +5 -66
  9. data/lib/ruport/acts_as_reportable.rb +122 -51
  10. data/lib/ruport/data/grouping.rb +30 -13
  11. data/lib/ruport/data/record.rb +26 -25
  12. data/lib/ruport/data/table.rb +91 -34
  13. data/lib/ruport/formatter.rb +86 -11
  14. data/lib/ruport/formatter/csv.rb +29 -2
  15. data/lib/ruport/formatter/html.rb +23 -1
  16. data/lib/ruport/formatter/pdf.rb +123 -32
  17. data/lib/ruport/formatter/text.rb +62 -6
  18. data/lib/ruport/query.rb +75 -39
  19. data/lib/ruport/renderer.rb +250 -35
  20. data/lib/ruport/renderer/grouping.rb +2 -2
  21. data/test/html_formatter_test.rb +4 -1
  22. data/test/pdf_formatter_test.rb +30 -7
  23. data/test/query_test.rb +12 -0
  24. data/test/renderer_test.rb +33 -2
  25. data/test/table_test.rb +8 -2
  26. data/test/text_formatter_test.rb +11 -1
  27. metadata +53 -107
  28. data/bin/rope +0 -12
  29. data/examples/rope_examples/itunes/README +0 -12
  30. data/examples/rope_examples/itunes/Rakefile +0 -39
  31. data/examples/rope_examples/itunes/config/environment.rb +0 -4
  32. data/examples/rope_examples/itunes/data/mix.txt +0 -1
  33. data/examples/rope_examples/itunes/lib/helpers.rb +0 -0
  34. data/examples/rope_examples/itunes/lib/init.rb +0 -39
  35. data/examples/rope_examples/itunes/lib/reports.rb +0 -1
  36. data/examples/rope_examples/itunes/lib/reports/playlist.rb +0 -17
  37. data/examples/rope_examples/itunes/log/ruport.log +0 -1
  38. data/examples/rope_examples/itunes/test/test_playlist.rb +0 -8
  39. data/examples/rope_examples/itunes/util/build +0 -96
  40. data/examples/rope_examples/itunes/util/sql_exec +0 -5
  41. data/examples/rope_examples/sales_report/README +0 -4
  42. data/examples/rope_examples/sales_report/Rakefile +0 -39
  43. data/examples/rope_examples/sales_report/config/environment.rb +0 -4
  44. data/examples/rope_examples/sales_report/lib/helpers.rb +0 -0
  45. data/examples/rope_examples/sales_report/lib/init.rb +0 -39
  46. data/examples/rope_examples/sales_report/lib/reports.rb +0 -1
  47. data/examples/rope_examples/sales_report/lib/reports/sales.rb +0 -132
  48. data/examples/rope_examples/sales_report/log/ruport.log +0 -1
  49. data/examples/rope_examples/sales_report/output/books.pdf +0 -170
  50. data/examples/rope_examples/sales_report/output/books.txt +0 -11
  51. data/examples/rope_examples/sales_report/test/test_sales.rb +0 -8
  52. data/examples/rope_examples/sales_report/util/build +0 -96
  53. data/examples/rope_examples/sales_report/util/sql_exec +0 -5
  54. data/examples/sample.rb +0 -16
  55. data/lib/ruport/generator.rb +0 -294
  56. data/lib/ruport/report.rb +0 -262
  57. data/setup.rb +0 -1585
  58. data/test/report_test.rb +0 -218
  59. data/test/samples/foo.rtxt +0 -3
@@ -40,8 +40,8 @@ module Ruport
40
40
  #
41
41
  # == Default layout options
42
42
  #
43
- # * <tt>show_group_headers</tt> #=> true
44
- # * <tt>style</tt> #=> :inline
43
+ # * <tt>show_group_headers</tt> #=> true
44
+ # * <tt>style</tt> #=> :inline
45
45
  #
46
46
  # == Formatter hooks called (in order)
47
47
  #
@@ -96,9 +96,12 @@ class TestFormatHTML < Test::Unit::TestCase
96
96
  "\t\t\t<td>9</td>\n\t\t</tr>\n\t</table>\n", actual
97
97
  end
98
98
 
99
- def test_textile
99
+ def test_textile
100
+ require "redcloth"
100
101
  a = Ruport::Formatter::HTML.new
101
102
  assert_equal "<p><strong>foo</strong></p>", a.textile("*foo*")
103
+ rescue LoadError
104
+ STDERR.puts "Skipping textile test... needs redcloth"
102
105
  end
103
106
 
104
107
  end
@@ -5,21 +5,44 @@ begin
5
5
  require "rubygems"
6
6
  rescue LoadError
7
7
  nil
8
- end
8
+ end
9
+
10
+ #require "pdf/writer"
9
11
 
10
12
  class TestFormatPDF < Test::Unit::TestCase
11
13
 
12
14
  def test_render_pdf_basic
13
- begin
14
- quiet { require "pdf/writer" }
15
- rescue LoadError
16
- warn "skipping pdf test"; return
17
- end
18
15
  data = [[1,2],[3,4]].to_table
19
- assert_raise(RuntimeError) { data.to_pdf }
16
+ assert_raise(Ruport::FormatterError) {
17
+ data.to_pdf
18
+ }
20
19
 
21
20
  data.column_names = %w[a b]
22
21
  assert_nothing_raised { data.to_pdf }
22
+ end
23
+
24
+ #--------BUG TRAPS--------#
25
+
26
+ # PDF::SimpleTable does not handle symbols as column names
27
+ # Ruport should smartly fix this surprising behaviour (#283)
28
+ def test_tables_should_render_with_symbol_column_name
29
+ data = [[1,2,3],[4,5,6]].to_table([:a,:b,:c])
30
+ assert_nothing_raised { data.to_pdf }
31
+ end
32
+
33
+ # As of Ruport 0.10.0, PDF's justified group output was throwing
34
+ # UnknownFormatError (#288)
35
+ def test_group_styles_should_not_throw_error
36
+ table = [[1,2,3],[4,5,6],[1,7,9]].to_table(%w[a b c])
37
+ grouping = Grouping(table,:by => "a")
38
+ assert_nothing_raised { grouping.to_pdf }
39
+ assert_nothing_raised { grouping.to_pdf(:style => :inline) }
40
+ assert_nothing_raised { grouping.to_pdf(:style => :offset) }
41
+ assert_nothing_raised { grouping.to_pdf(:style => :justified) }
42
+ assert_nothing_raised { grouping.to_pdf(:style => :separated) }
23
43
  end
44
+
45
+
46
+
24
47
 
25
48
  end
data/test/query_test.rb CHANGED
@@ -97,6 +97,18 @@
97
97
 
98
98
  query = Ruport::Query.new "query_test.sql"
99
99
  assert_equal "select * from foo", query.sql
100
+ end
101
+
102
+ def test_explicit
103
+ File.expects(:read).
104
+ with("query_test").
105
+ returns("select * from foo\n")
106
+
107
+ query = Ruport::Query.new(:file => "query_test")
108
+ assert_equal "select * from foo", query.sql
109
+
110
+ query = Ruport::Query.new(:string => "query_test")
111
+ assert_equal "query_test", query.sql
100
112
  end
101
113
 
102
114
  def test_load_file_not_found
@@ -74,8 +74,7 @@ class MultiPurposeFormatter < Ruport::Formatter
74
74
  end
75
75
 
76
76
  def build_footer; end
77
- end
78
-
77
+ end
79
78
 
80
79
  # FIXME: come up with a better name
81
80
  class RendererWithHelpers < Ruport::Renderer
@@ -124,6 +123,38 @@ class RendererWithHelperModule < TrivialRenderer2
124
123
  "Hello Dolly"
125
124
  end
126
125
  end
126
+ end
127
+
128
+ class ErbFormatter < Ruport::Formatter
129
+
130
+ renders :terb, :for => TrivialRenderer2
131
+
132
+ def build_header; end #gross, refactor
133
+ def build_footer; end #gross, refactor
134
+ def build_body
135
+ # demonstrate local binding
136
+ @foo = "bar"
137
+ if options.binding
138
+ output << erb("Binding Override: <%= reverse %>",
139
+ :binding => options.binding)
140
+ else
141
+ output << erb("Default Binding: <%= @foo %>")
142
+ end
143
+ end
144
+
145
+ end
146
+
147
+ class TestFormatterErbHelper < Test::Unit::TestCase
148
+ def test_self_bound
149
+ assert_equal "Default Binding: bar", TrivialRenderer2.render_terb
150
+ end
151
+
152
+ def test_custom_bound
153
+ a = [1,2,3]
154
+ arr_binding = a.instance_eval { binding }
155
+ assert_equal "Binding Override: 321",
156
+ TrivialRenderer2.render_terb(:binding => arr_binding)
157
+ end
127
158
  end
128
159
 
129
160
  class TestRenderer < Test::Unit::TestCase
data/test/table_test.rb CHANGED
@@ -668,9 +668,15 @@ class TestTable < Test::Unit::TestCase
668
668
  def test_ensure_csv_loading_accepts_table_options
669
669
  a = Table("test/samples/addressbook.csv",:record_class => DuckRecord)
670
670
  a.each { |r| assert_kind_of(DuckRecord,r) }
671
+ end
672
+
673
+ def test_ensure_table_from_csv_accepts_record_class_in_block_usage
674
+ a = Table("test/samples/addressbook.csv",:record_class => DuckRecord,
675
+ :records => true) do |s,r|
676
+ assert_kind_of(DuckRecord,r)
677
+ end
671
678
  end
672
679
 
673
-
674
680
  class MySubClass < Ruport::Data::Table; end
675
681
 
676
682
  def test_ensure_table_subclasses_render_properly
@@ -736,6 +742,6 @@ class TestTableKernelHack < Test::Unit::TestCase
736
742
  def test_ensure_table_hack_accepts_normal_constructor_args
737
743
  assert_equal Ruport::Data::Table.new(:column_names => %w[a b c]),
738
744
  Table(:column_names => %w[a b c])
739
- end
745
+ end
740
746
 
741
747
  end
@@ -47,8 +47,18 @@ class TestFormatText < Test::Unit::TestCase
47
47
  }
48
48
 
49
49
  assert_equal("+------->>\n| 1 | >>\n| 300 | >>\n+------->>\n",a)
50
- end
50
+ end
51
+
52
+ def test_ignore_wrapping
53
+ a = [[1,2],[300,4]].to_table.as(:text) { |r|
54
+ r.options { |l|
55
+ l.table_width = 10
56
+ l.ignore_table_width = true
57
+ }
58
+ }
51
59
 
60
+ assert_equal("+---------+\n| 1 | 2 |\n| 300 | 4 |\n+---------+\n",a)
61
+ end
52
62
 
53
63
  def test_make_sure_this_damn_column_names_bug_dies_a_horrible_death!
54
64
  a = [[1,2,3]].to_table.to_text
metadata CHANGED
@@ -3,13 +3,13 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: ruport
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.10.0
7
- date: 2007-04-22 00:00:00 -04:00
6
+ version: 0.11.0
7
+ date: 2007-05-01 00:00:00 -04:00
8
8
  summary: A generalized Ruby report generation and templating engine.
9
9
  require_paths:
10
10
  - lib
11
11
  email: " gregory.t.brown@gmail.com"
12
- homepage: http://code.rubyreports.org
12
+ homepage: http://rubyreports.org
13
13
  rubyforge_project: ruport
14
14
  description: Ruby Reports is a software library that aims to make the task of reporting less tedious and painful. It provides tools for data acquisition, database interaction, formatting, and parsing/munging.
15
15
  autorequire:
@@ -29,156 +29,102 @@ post_install_message:
29
29
  authors:
30
30
  - Gregory Brown
31
31
  files:
32
- - examples/rope_examples
33
- - examples/ruport_list
34
- - examples/simple_pdf_lines.rb
35
- - examples/row_renderer.rb
36
- - examples/RWEmerson.jpg
37
- - examples/line_plotter.rb
38
32
  - examples/centered_pdf_text_box.rb
39
- - examples/sample.rb
40
33
  - examples/example.csv
34
+ - examples/line_plotter.rb
41
35
  - examples/pdf_complex_report.rb
36
+ - examples/pdf_report_with_common_base.rb
37
+ - examples/pdf_styles.rb
42
38
  - examples/pdf_table_with_title.rb
43
- - examples/rope_examples/sales_report
44
- - examples/rope_examples/itunes
45
- - examples/rope_examples/sales_report/sql
46
- - examples/rope_examples/sales_report/test
47
- - examples/rope_examples/sales_report/output
48
- - examples/rope_examples/sales_report/log
49
- - examples/rope_examples/sales_report/config
50
- - examples/rope_examples/sales_report/lib
51
- - examples/rope_examples/sales_report/data
52
- - examples/rope_examples/sales_report/util
53
- - examples/rope_examples/sales_report/templates
54
- - examples/rope_examples/sales_report/Rakefile
55
- - examples/rope_examples/sales_report/README
56
- - examples/rope_examples/sales_report/test/test_sales.rb
57
- - examples/rope_examples/sales_report/output/books.pdf
58
- - examples/rope_examples/sales_report/output/books.txt
59
- - examples/rope_examples/sales_report/log/ruport.log
60
- - examples/rope_examples/sales_report/config/environment.rb
61
- - examples/rope_examples/sales_report/lib/reports
62
- - examples/rope_examples/sales_report/lib/reports.rb
63
- - examples/rope_examples/sales_report/lib/helpers.rb
64
- - examples/rope_examples/sales_report/lib/init.rb
65
- - examples/rope_examples/sales_report/lib/reports/sales.rb
66
- - examples/rope_examples/sales_report/util/build
67
- - examples/rope_examples/sales_report/util/sql_exec
68
- - examples/rope_examples/itunes/sql
69
- - examples/rope_examples/itunes/test
70
- - examples/rope_examples/itunes/output
71
- - examples/rope_examples/itunes/log
72
- - examples/rope_examples/itunes/config
73
- - examples/rope_examples/itunes/lib
74
- - examples/rope_examples/itunes/data
75
- - examples/rope_examples/itunes/util
76
- - examples/rope_examples/itunes/templates
77
- - examples/rope_examples/itunes/Rakefile
78
- - examples/rope_examples/itunes/README
79
- - examples/rope_examples/itunes/test/test_playlist.rb
80
- - examples/rope_examples/itunes/log/ruport.log
81
- - examples/rope_examples/itunes/config/environment.rb
82
- - examples/rope_examples/itunes/lib/reports
83
- - examples/rope_examples/itunes/lib/reports.rb
84
- - examples/rope_examples/itunes/lib/helpers.rb
85
- - examples/rope_examples/itunes/lib/init.rb
86
- - examples/rope_examples/itunes/lib/reports/playlist.rb
87
- - examples/rope_examples/itunes/data/mix.txt
88
- - examples/rope_examples/itunes/util/build
89
- - examples/rope_examples/itunes/util/sql_exec
39
+ - examples/row_renderer.rb
40
+ - examples/ruport_list
41
+ - examples/RWEmerson.jpg
42
+ - examples/simple_pdf_lines.rb
90
43
  - examples/ruport_list/png_embed.rb
91
44
  - examples/ruport_list/roadmap.png
92
45
  - lib/ruport
93
46
  - lib/ruport.rb
94
47
  - lib/uport.rb
95
- - lib/ruport/formatter
96
- - lib/ruport/query
97
- - lib/ruport/renderer
48
+ - lib/ruport/acts_as_reportable.rb
98
49
  - lib/ruport/data
50
+ - lib/ruport/data.rb
99
51
  - lib/ruport/extensions.rb
52
+ - lib/ruport/formatter
100
53
  - lib/ruport/formatter.rb
54
+ - lib/ruport/query
101
55
  - lib/ruport/query.rb
102
- - lib/ruport/generator.rb
56
+ - lib/ruport/renderer
103
57
  - lib/ruport/renderer.rb
104
- - lib/ruport/data.rb
105
- - lib/ruport/report.rb
106
- - lib/ruport/acts_as_reportable.rb
58
+ - lib/ruport/data/grouping.rb
59
+ - lib/ruport/data/record.rb
60
+ - lib/ruport/data/table.rb
61
+ - lib/ruport/formatter/csv.rb
107
62
  - lib/ruport/formatter/html.rb
108
- - lib/ruport/formatter/text.rb
109
63
  - lib/ruport/formatter/pdf.rb
110
- - lib/ruport/formatter/csv.rb
64
+ - lib/ruport/formatter/text.rb
111
65
  - lib/ruport/query/sql_split.rb
112
66
  - lib/ruport/renderer/grouping.rb
113
67
  - lib/ruport/renderer/table.rb
114
- - lib/ruport/data/record.rb
115
- - lib/ruport/data/table.rb
116
- - lib/ruport/data/grouping.rb
117
- - test/samples
118
68
  - test/acts_as_reportable_test.rb
119
69
  - test/csv_formatter_test.rb
120
- - test/record_test.rb
121
70
  - test/database_test_.rb
71
+ - test/grouping_test.rb
72
+ - test/html_formatter_test.rb
73
+ - test/pdf_formatter_test.rb
122
74
  - test/query_test.rb
75
+ - test/record_test.rb
123
76
  - test/renderer_test.rb
124
- - test/html_formatter_test.rb
77
+ - test/samples
78
+ - test/sql_split_test.rb
125
79
  - test/table_test.rb
126
80
  - test/text_formatter_test.rb
127
- - test/grouping_test.rb
128
- - test/sql_split_test.rb
129
- - test/report_test.rb
130
- - test/pdf_formatter_test.rb
131
- - test/samples/query_test.sql
132
- - test/samples/test.yaml
133
- - test/samples/erb_test.sql
81
+ - test/samples/addressbook.csv
134
82
  - test/samples/data.csv
135
- - test/samples/foo.rtxt
136
83
  - test/samples/data.tsv
137
- - test/samples/stonecodeblog.sql
138
- - test/samples/ticket_count.csv
139
- - test/samples/ruport_test.sql
140
- - test/samples/addressbook.csv
141
84
  - test/samples/dates.csv
142
85
  - test/samples/document.xml
86
+ - test/samples/erb_test.sql
87
+ - test/samples/query_test.sql
88
+ - test/samples/ruport_test.sql
89
+ - test/samples/stonecodeblog.sql
143
90
  - test/samples/test.sql
144
- - bin/rope
91
+ - test/samples/test.yaml
92
+ - test/samples/ticket_count.csv
93
+ - util/bench/data
145
94
  - util/bench/formatter
146
95
  - util/bench/samples
147
- - util/bench/data
148
- - util/bench/formatter/bench_html.rb
149
- - util/bench/formatter/bench_text.rb
150
- - util/bench/formatter/bench_pdf.rb
151
- - util/bench/formatter/bench_csv.rb
152
- - util/bench/samples/tattle.csv
153
- - util/bench/data/table
154
96
  - util/bench/data/record
155
- - util/bench/data/table/bench_column_manip.rb
156
- - util/bench/data/table/bench_init.rb
157
- - util/bench/data/table/bench_manip.rb
158
- - util/bench/data/table/bench_dup.rb
97
+ - util/bench/data/table
98
+ - util/bench/data/record/bench_as_vs_to.rb
159
99
  - util/bench/data/record/bench_constructor.rb
100
+ - util/bench/data/record/bench_indexing.rb
160
101
  - util/bench/data/record/bench_reorder.rb
161
102
  - util/bench/data/record/bench_to_a.rb
162
- - util/bench/data/record/bench_indexing.rb
163
- - util/bench/data/record/bench_as_vs_to.rb
103
+ - util/bench/data/table/bench_column_manip.rb
104
+ - util/bench/data/table/bench_dup.rb
105
+ - util/bench/data/table/bench_init.rb
106
+ - util/bench/data/table/bench_manip.rb
107
+ - util/bench/formatter/bench_csv.rb
108
+ - util/bench/formatter/bench_html.rb
109
+ - util/bench/formatter/bench_pdf.rb
110
+ - util/bench/formatter/bench_text.rb
111
+ - util/bench/samples/tattle.csv
164
112
  - Rakefile
165
- - setup.rb
166
113
  - README
167
114
  - LICENSE
168
115
  - AUTHORS
169
116
  test_files:
170
117
  - test/acts_as_reportable_test.rb
171
118
  - test/csv_formatter_test.rb
172
- - test/record_test.rb
119
+ - test/grouping_test.rb
120
+ - test/html_formatter_test.rb
121
+ - test/pdf_formatter_test.rb
173
122
  - test/query_test.rb
123
+ - test/record_test.rb
174
124
  - test/renderer_test.rb
175
- - test/html_formatter_test.rb
125
+ - test/sql_split_test.rb
176
126
  - test/table_test.rb
177
127
  - test/text_formatter_test.rb
178
- - test/grouping_test.rb
179
- - test/sql_split_test.rb
180
- - test/report_test.rb
181
- - test/pdf_formatter_test.rb
182
128
  rdoc_options:
183
129
  - --title
184
130
  - Ruport Documentation
@@ -189,8 +135,8 @@ extra_rdoc_files:
189
135
  - README
190
136
  - LICENSE
191
137
  - AUTHORS
192
- executables:
193
- - rope
138
+ executables: []
139
+
194
140
  extensions: []
195
141
 
196
142
  requirements: []
data/bin/rope DELETED
@@ -1,12 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require "fileutils"
3
- require "ruport/generator"
4
- include FileUtils
5
-
6
- if ARGV.empty?
7
- puts "Usage: rope project_name"
8
- exit
9
- end
10
- project = ARGV[0]
11
-
12
- Ruport::Generator.build(ARGV[0])
@@ -1,12 +0,0 @@
1
- - this is an up to date version of the code in Chris Carter's tutorial at:
2
- http://concentrationstudios.com/2007/1/21/ruports
3
-
4
- To run the report do:
5
-
6
- ruby app/reports/playlist.rb
7
-
8
- or
9
-
10
- rake run report=playlist
11
-
12
- It will generate a pdf in output/