ruport 0.8.10 → 0.8.11

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/Rakefile CHANGED
@@ -16,28 +16,28 @@ version = File.read(lib)[/^\s*VERSION\s*=\s*(['"])(\d+\.\d+\.d+)['"]/,1]
16
16
  task :default => [:test]
17
17
 
18
18
  Rake::TestTask.new do |test|
19
- test.libs << "test"
20
- test.test_files = Dir[ "test/test_*.rb" ]
21
- test.verbose = true
19
+ test.libs << "test"
20
+ test.test_files = Dir[ "test/test_*.rb" ]
21
+ test.verbose = true
22
22
  end
23
23
 
24
24
  spec = Gem::Specification.new do |spec|
25
- spec.name = LEAN ? "lean-ruport" : "ruport"
26
- spec.version = "0.8.10"
27
- spec.platform = Gem::Platform::RUBY
28
- spec.summary = "A generalized Ruby report generation and templating engine."
29
- spec.files = Dir.glob("{examples,lib,test,bin}/**/**/*") +
25
+ spec.name = LEAN ? "lean-ruport" : "ruport"
26
+ spec.version = "0.8.11"
27
+ spec.platform = Gem::Platform::RUBY
28
+ spec.summary = "A generalized Ruby report generation and templating engine."
29
+ spec.files = Dir.glob("{examples,lib,test,bin}/**/**/*") +
30
30
  ["Rakefile", "setup.rb"]
31
31
 
32
32
  spec.require_path = "lib"
33
-
33
+
34
34
  spec.test_files = Dir[ "test/test_*.rb" ]
35
35
  spec.bindir = "bin"
36
36
  spec.executables = FileList["rope"]
37
- spec.has_rdoc = true
38
- spec.extra_rdoc_files = %w{README LICENSE TODO AUTHORS}
39
- spec.rdoc_options << '--title' << 'Ruport Documentation' <<
40
- '--main' << 'README' << '-q'
37
+ spec.has_rdoc = true
38
+ spec.extra_rdoc_files = %w{README LICENSE TODO AUTHORS}
39
+ spec.rdoc_options << '--title' << 'Ruport Documentation' <<
40
+ '--main' << 'README' << '-q'
41
41
  unless LEAN
42
42
  spec.add_dependency('fastercsv', '>= 1.1.0')
43
43
  spec.add_dependency('RedCloth', '>= 3.0.3')
@@ -46,11 +46,12 @@ spec = Gem::Specification.new do |spec|
46
46
  spec.add_dependency('scruffy', '>= 0.2.2')
47
47
  spec.add_dependency('gem_plugin', '>=0.2.2')
48
48
  end
49
+
49
50
  spec.author = "Gregory Brown"
50
- spec.email = " gregory.t.brown@gmail.com"
51
- spec.rubyforge_project = "ruport"
52
- spec.homepage = "http://reporting.stonecode.org"
53
- spec.description = <<END_DESC
51
+ spec.email = " gregory.t.brown@gmail.com"
52
+ spec.rubyforge_project = "ruport"
53
+ spec.homepage = "http://reporting.stonecode.org"
54
+ spec.description = <<END_DESC
54
55
  Ruby Reports is a software library that aims to make the task of reporting
55
56
  less tedious and painful. It provides tools for data acquisition,
56
57
  database interaction, formatting, and parsing/munging.
@@ -68,8 +69,8 @@ Rake::RDocTask.new do |rdoc|
68
69
  end
69
70
 
70
71
  Rake::GemPackageTask.new(spec) do |pkg|
71
- pkg.need_zip = true
72
- pkg.need_tar = true
72
+ pkg.need_zip = true
73
+ pkg.need_tar = true
73
74
  end
74
75
 
75
76
  begin
data/lib/ruport.rb CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
  module Ruport
14
14
 
15
- VERSION = "0.8.10"
15
+ VERSION = "0.8.11"
16
16
 
17
17
  # This method is Ruport's logging and error interface. It can generate
18
18
  # warnings or raise fatal errors, logging +message+ to the file defined by
@@ -81,9 +81,4 @@ require "ruport/format"
81
81
  require "ruport/query"
82
82
  require "ruport/mailer"
83
83
  require "ruport/layout"
84
- require "ruport/renderer"
85
-
86
- if defined? Gem
87
- require "gem_plugin"
88
- GemPlugin::Manager.instance.load "ruport" => GemPlugin::INCLUDE
89
- end
84
+ require "ruport/renderer"
@@ -18,13 +18,13 @@ module Ruport::Data
18
18
  # ['pinky', 3],
19
19
  # ['clyde', 4]].to_table(['name','score'])
20
20
  #
21
- # table[0].tag(:winners)
22
- # table[1].tag(:losers)
23
- # table[2].tag(:winners)
24
- # table[3].tag(:losers)
21
+ # table[0].tag("grp_winners")
22
+ # table[1].tag("grp_losers")
23
+ # table[2].tag("grp_winners")
24
+ # table[3].tag("grp_losers")
25
25
  #
26
- # r = table.group_by_tag
27
- # puts r[:winners]
26
+ # r = table.groups
27
+ # puts r["winners"]
28
28
  # => +---------------+
29
29
  # | name | score |
30
30
  # +---------------+
@@ -32,7 +32,7 @@ module Ruport::Data
32
32
  # | pinky | 3 |
33
33
  # +---------------+
34
34
  #
35
- # puts r[:losers]
35
+ # puts r["losers"]
36
36
  # => +----------------+
37
37
  # | name | score |
38
38
  # +----------------+
@@ -41,21 +41,24 @@ module Ruport::Data
41
41
  # +----------------+
42
42
  #
43
43
  def groups
44
- #r_tags = map { |r| r.tags }.flatten.uniq
45
44
  r_tags = group_names_intern
46
45
  tables_hash = Hash.new { |h,k| h[k] = Table(column_names) }
47
46
  r_tags.each { |t|
48
47
  tables_hash[t.gsub(/^grp_/,"")] = sub_table { |r| r.tags.include? t }}
49
48
  r = Record.new tables_hash, :attributes => group_names
50
49
  end
51
-
50
+
51
+ # Gets the names of the groups
52
52
  def group_names
53
53
  group_names_intern.map { |r| r.gsub(/^grp_/,"") }
54
54
  end
55
55
 
56
+ # Gets a subtable of the rows matching the group name
57
+ #
56
58
  def group(tag)
57
59
  sub_table { |r| r.tags.include?("grp_#{tag}") }
58
60
  end
61
+
59
62
  #
60
63
  # Tags each row of the <tt>Table</tt> for which the <tt>block</tt> is not
61
64
  # false with <tt>label</tt>.
@@ -65,10 +68,10 @@ module Ruport::Data
65
68
  # ['blinky',2],
66
69
  # ['pinky', 3]].to_table(['name','score'])
67
70
  #
68
- # table.create_tag_group(:cool_kids) {|r| r.score > 1}
69
- # groups = table.group_by_tag(:cool_kids)
71
+ # table.create_group(:cool_kids) {|r| r.score > 1}
72
+ # groups = table.groups
70
73
  #
71
- # puts group[:cool_kids]
74
+ # puts groups["cool_kids"]
72
75
  # => +----------------+
73
76
  # | name | score |
74
77
  # +----------------+
@@ -202,6 +202,8 @@ module Ruport::Data
202
202
  # Makes a fresh copy of the Record.
203
203
  def dup
204
204
  r = Record.new(@data.dup,:attributes => @attributes.dup)
205
+ r.tags = tags.dup
206
+ return r
205
207
  end
206
208
 
207
209
  # Provides accessor style methods for attribute access.
@@ -240,7 +242,7 @@ module Ruport::Data
240
242
 
241
243
 
242
244
  def reindex(new_attributes)
243
- @attributes.replace(new_attributes)
245
+ @attributes = new_attributes
244
246
  end
245
247
  end
246
248
  end
@@ -49,11 +49,11 @@ module Ruport::Data
49
49
  end
50
50
 
51
51
  #
52
- # Returns an Array of the object's tags.
52
+ # Returns an Set of the object's tags.
53
53
  #
54
54
  # Example:
55
55
  #
56
- # taggable_obj.tags #=> [:spiffy, :kind_of_spiffy]
56
+ # taggable_obj.tags #=> #<Set: {:spiffy, :kind_of_spiffy}>
57
57
  #
58
58
  def tags
59
59
  @ruport_tags ||= Set.new
@@ -0,0 +1,4 @@
1
+ if defined? Gem
2
+ require "gem_plugin"
3
+ GemPlugin::Manager.instance.load "ruport" => GemPlugin::INCLUDE
4
+ end
data/test/test_record.rb CHANGED
@@ -218,13 +218,24 @@ class TestRecord < Test::Unit::TestCase
218
218
 
219
219
  def test_reindex
220
220
  assert_equal %w[a b c d], @record.attributes
221
- old_object_id = @record.instance_variable_get(:@attributes).object_id
221
+ #old_object_id = @record.instance_variable_get(:@attributes).object_id
222
222
 
223
- @record.send(:reindex, %w[apple banana courier django])
223
+ @record.send(:reindex, a=%w[apple banana courier django])
224
224
  assert_equal %w[apple banana courier django], @record.attributes
225
225
 
226
226
  new_object_id = @record.instance_variable_get(:@attributes).object_id
227
- assert_equal old_object_id, new_object_id
227
+ assert_equal a.object_id, new_object_id
228
228
  end
229
229
 
230
+ def test_ensure_tags_get_duped
231
+ a = Record.new([1,2,3])
232
+ a.tag :foo
233
+ assert a.tags.include?(:foo)
234
+ b = a.dup
235
+ assert b.tags.include?(:foo)
236
+ assert_not_same a.tags, b.tags
237
+ end
238
+
239
+
240
+
230
241
  end
data/test/test_table.rb CHANGED
@@ -481,6 +481,21 @@ class TestTable < Test::Unit::TestCase
481
481
  assert_equal [[1,2,3],[4,5,6],[7,8,9]].to_table,a
482
482
  end
483
483
 
484
+ def test_ensure_setting_column_names_later_does_not_break_replace_column
485
+ a = [[1,2,3],[4,5,6]].to_table(%w[a b c])
486
+ a.replace_column("b","q") { |r| r.a + r.c }
487
+ a.column_names = %w[d e f]
488
+ assert_equal [[1,4,3],[4,10,6]].to_table(%w[d e f]), a
489
+
490
+ a = [[1,2,3],[4,5,6]].to_table
491
+
492
+ a.column_names = %w[a b c]
493
+
494
+ a.replace_column("b","foo") { |r| r.b + 1 }
495
+
496
+ assert_equal [[1,3,3],[4,6,6]].to_table(%w[a foo c]), a
497
+ end
498
+
484
499
  end
485
500
 
486
501
  class TestTableKernelHack < Test::Unit::TestCase
metadata CHANGED
@@ -3,12 +3,12 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: ruport
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.8.10
7
- date: 2007-02-12 00:00:00 -05:00
6
+ version: 0.8.11
7
+ date: 2007-03-05 00:00:00 -05:00
8
8
  summary: A generalized Ruby report generation and templating engine.
9
9
  require_paths:
10
10
  - lib
11
- email: "\tgregory.t.brown@gmail.com"
11
+ email: " gregory.t.brown@gmail.com"
12
12
  homepage: http://reporting.stonecode.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.
@@ -29,128 +29,128 @@ post_install_message:
29
29
  authors:
30
30
  - Gregory Brown
31
31
  files:
32
- - examples/rope_examples
33
- - examples/invoice_report.rb
34
- - examples/RWEmerson.jpg
35
- - examples/line_plotter.rb
36
32
  - examples/centered_pdf_text_box.rb
37
- - examples/line_graph.rb
38
33
  - examples/invoice.rb
34
+ - examples/invoice_report.rb
35
+ - examples/line_graph.rb
36
+ - examples/line_plotter.rb
39
37
  - examples/pdf_complex_report.rb
40
38
  - examples/pdf_table_with_title.rb
41
- - examples/rope_examples/sales_report
39
+ - examples/rope_examples
40
+ - examples/RWEmerson.jpg
42
41
  - examples/rope_examples/itunes
43
- - examples/rope_examples/sales_report/sql
44
- - examples/rope_examples/sales_report/test
45
- - examples/rope_examples/sales_report/output
46
- - examples/rope_examples/sales_report/log
47
- - examples/rope_examples/sales_report/config
48
- - examples/rope_examples/sales_report/lib
49
- - examples/rope_examples/sales_report/data
50
- - examples/rope_examples/sales_report/util
51
- - examples/rope_examples/sales_report/templates
52
- - examples/rope_examples/sales_report/Rakefile
53
- - examples/rope_examples/sales_report/README
54
- - examples/rope_examples/sales_report/test/test_sales.rb
55
- - examples/rope_examples/sales_report/output/books.pdf
56
- - examples/rope_examples/sales_report/output/books.txt
57
- - examples/rope_examples/sales_report/log/ruport.log
58
- - examples/rope_examples/sales_report/config/ruport_config.rb
59
- - examples/rope_examples/sales_report/lib/reports
60
- - examples/rope_examples/sales_report/lib/reports.rb
61
- - examples/rope_examples/sales_report/lib/helpers.rb
62
- - examples/rope_examples/sales_report/lib/init.rb
63
- - examples/rope_examples/sales_report/lib/reports/sales.rb
64
- - examples/rope_examples/sales_report/util/build
65
- - examples/rope_examples/sales_report/util/sql_exec
66
- - examples/rope_examples/itunes/sql
67
- - examples/rope_examples/itunes/test
68
- - examples/rope_examples/itunes/output
69
- - examples/rope_examples/itunes/log
42
+ - examples/rope_examples/sales_report
70
43
  - examples/rope_examples/itunes/config
71
- - examples/rope_examples/itunes/lib
72
44
  - examples/rope_examples/itunes/data
73
- - examples/rope_examples/itunes/util
74
- - examples/rope_examples/itunes/templates
45
+ - examples/rope_examples/itunes/lib
46
+ - examples/rope_examples/itunes/log
47
+ - examples/rope_examples/itunes/output
75
48
  - examples/rope_examples/itunes/Rakefile
76
49
  - examples/rope_examples/itunes/README
77
- - examples/rope_examples/itunes/test/test_playlist.rb
78
- - examples/rope_examples/itunes/log/ruport.log
50
+ - examples/rope_examples/itunes/sql
51
+ - examples/rope_examples/itunes/templates
52
+ - examples/rope_examples/itunes/test
53
+ - examples/rope_examples/itunes/util
79
54
  - examples/rope_examples/itunes/config/ruport_config.rb
80
- - examples/rope_examples/itunes/lib/reports
81
- - examples/rope_examples/itunes/lib/reports.rb
55
+ - examples/rope_examples/itunes/data/mix.txt
82
56
  - examples/rope_examples/itunes/lib/helpers.rb
83
57
  - examples/rope_examples/itunes/lib/init.rb
58
+ - examples/rope_examples/itunes/lib/reports
59
+ - examples/rope_examples/itunes/lib/reports.rb
84
60
  - examples/rope_examples/itunes/lib/reports/playlist.rb
85
- - examples/rope_examples/itunes/data/mix.txt
61
+ - examples/rope_examples/itunes/log/ruport.log
62
+ - examples/rope_examples/itunes/test/test_playlist.rb
86
63
  - examples/rope_examples/itunes/util/build
87
64
  - examples/rope_examples/itunes/util/sql_exec
65
+ - examples/rope_examples/sales_report/config
66
+ - examples/rope_examples/sales_report/data
67
+ - examples/rope_examples/sales_report/lib
68
+ - examples/rope_examples/sales_report/log
69
+ - examples/rope_examples/sales_report/output
70
+ - examples/rope_examples/sales_report/Rakefile
71
+ - examples/rope_examples/sales_report/README
72
+ - examples/rope_examples/sales_report/sql
73
+ - examples/rope_examples/sales_report/templates
74
+ - examples/rope_examples/sales_report/test
75
+ - examples/rope_examples/sales_report/util
76
+ - examples/rope_examples/sales_report/config/ruport_config.rb
77
+ - examples/rope_examples/sales_report/lib/helpers.rb
78
+ - examples/rope_examples/sales_report/lib/init.rb
79
+ - examples/rope_examples/sales_report/lib/reports
80
+ - examples/rope_examples/sales_report/lib/reports.rb
81
+ - examples/rope_examples/sales_report/lib/reports/sales.rb
82
+ - examples/rope_examples/sales_report/log/ruport.log
83
+ - examples/rope_examples/sales_report/output/books.pdf
84
+ - examples/rope_examples/sales_report/output/books.txt
85
+ - examples/rope_examples/sales_report/test/test_sales.rb
86
+ - examples/rope_examples/sales_report/util/build
87
+ - examples/rope_examples/sales_report/util/sql_exec
88
88
  - lib/ruport
89
89
  - lib/ruport.rb
90
90
  - lib/uport.rb
91
- - lib/ruport/format
92
- - lib/ruport/query
93
- - lib/ruport/renderer
91
+ - lib/ruport/attempt.rb
92
+ - lib/ruport/config.rb
94
93
  - lib/ruport/data
95
- - lib/ruport/report
94
+ - lib/ruport/data.rb
95
+ - lib/ruport/extensions.rb
96
+ - lib/ruport/format
97
+ - lib/ruport/format.rb
98
+ - lib/ruport/generator.rb
96
99
  - lib/ruport/layout
97
100
  - lib/ruport/layout.rb
98
- - lib/ruport/attempt.rb
99
- - lib/ruport/generator.rb
100
- - lib/ruport/format.rb
101
+ - lib/ruport/mailer.rb
102
+ - lib/ruport/query
101
103
  - lib/ruport/query.rb
102
- - lib/ruport/data.rb
103
- - lib/ruport/system_extensions.rb
104
- - lib/ruport/config.rb
104
+ - lib/ruport/renderer
105
105
  - lib/ruport/renderer.rb
106
- - lib/ruport/mailer.rb
106
+ - lib/ruport/report
107
107
  - lib/ruport/report.rb
108
- - lib/ruport/format/plugin.rb
108
+ - lib/ruport/system_extensions.rb
109
+ - lib/ruport/data/groupable.rb
110
+ - lib/ruport/data/record.rb
111
+ - lib/ruport/data/table.rb
112
+ - lib/ruport/data/taggable.rb
113
+ - lib/ruport/format/csv.rb
114
+ - lib/ruport/format/html.rb
109
115
  - lib/ruport/format/latex.rb
116
+ - lib/ruport/format/pdf.rb
117
+ - lib/ruport/format/plugin.rb
110
118
  - lib/ruport/format/svg.rb
111
- - lib/ruport/format/xml.rb
112
- - lib/ruport/format/html.rb
113
119
  - lib/ruport/format/text.rb
114
- - lib/ruport/format/pdf.rb
115
- - lib/ruport/format/csv.rb
120
+ - lib/ruport/format/xml.rb
121
+ - lib/ruport/layout/component.rb
116
122
  - lib/ruport/query/sql_split.rb
117
123
  - lib/ruport/renderer/graph.rb
118
124
  - lib/ruport/renderer/table.rb
119
- - lib/ruport/data/record.rb
120
- - lib/ruport/data/groupable.rb
121
- - lib/ruport/data/taggable.rb
122
- - lib/ruport/data/table.rb
123
125
  - lib/ruport/report/graph.rb
124
- - lib/ruport/layout/component.rb
126
+ - test/_test_database.rb
125
127
  - test/samples
126
- - test/test_groupable.rb
127
- - test/test_record.rb
128
+ - test/test_config.rb
128
129
  - test/test_format_text.rb
129
- - test/test_table.rb
130
- - test/test_ruport.rb
131
130
  - test/test_graph_renderer.rb
132
- - test/test_table_renderer.rb
133
- - test/_test_database.rb
131
+ - test/test_groupable.rb
132
+ - test/test_mailer.rb
134
133
  - test/test_query.rb
135
- - test/test_config.rb
136
- - test/test_taggable.rb
134
+ - test/test_record.rb
137
135
  - test/test_renderer.rb
138
- - test/test_mailer.rb
139
- - test/test_sql_split.rb
140
136
  - test/test_report.rb
141
- - test/unit.log
142
- - test/samples/query_test.sql
143
- - test/samples/test.yaml
144
- - test/samples/erb_test.sql
137
+ - test/test_ruport.rb
138
+ - test/test_sql_split.rb
139
+ - test/test_table.rb
140
+ - test/test_table_renderer.rb
141
+ - test/test_taggable.rb
142
+ - test/samples/addressbook.csv
145
143
  - test/samples/data.csv
146
- - test/samples/foo.rtxt
147
144
  - test/samples/data.tsv
148
- - test/samples/stonecodeblog.sql
149
- - test/samples/ruport_test.sql
150
- - test/samples/addressbook.csv
151
145
  - test/samples/dates.csv
152
146
  - test/samples/document.xml
147
+ - test/samples/erb_test.sql
148
+ - test/samples/foo.rtxt
149
+ - test/samples/query_test.sql
150
+ - test/samples/ruport_test.sql
151
+ - test/samples/stonecodeblog.sql
153
152
  - test/samples/test.sql
153
+ - test/samples/test.yaml
154
154
  - bin/rope
155
155
  - Rakefile
156
156
  - setup.rb
@@ -159,20 +159,20 @@ files:
159
159
  - TODO
160
160
  - AUTHORS
161
161
  test_files:
162
- - test/test_groupable.rb
163
- - test/test_record.rb
162
+ - test/test_config.rb
164
163
  - test/test_format_text.rb
165
- - test/test_table.rb
166
- - test/test_ruport.rb
167
164
  - test/test_graph_renderer.rb
168
- - test/test_table_renderer.rb
165
+ - test/test_groupable.rb
166
+ - test/test_mailer.rb
169
167
  - test/test_query.rb
170
- - test/test_config.rb
171
- - test/test_taggable.rb
168
+ - test/test_record.rb
172
169
  - test/test_renderer.rb
173
- - test/test_mailer.rb
174
- - test/test_sql_split.rb
175
170
  - test/test_report.rb
171
+ - test/test_ruport.rb
172
+ - test/test_sql_split.rb
173
+ - test/test_table.rb
174
+ - test/test_table_renderer.rb
175
+ - test/test_taggable.rb
176
176
  rdoc_options:
177
177
  - --title
178
178
  - Ruport Documentation
data/test/unit.log DELETED
@@ -1,7 +0,0 @@
1
- # Logfile created on Mon Feb 12 21:22:00 -0500 2007 by logger.rb/1.5.2.9
2
- F, [2007-02-12T21:22:00.244983 #16500] FATAL -- : Missing host for mailer bar
3
- F, [2007-02-12T21:22:00.246039 #16500] FATAL -- : Missing DSN for source foo!
4
- F, [2007-02-12T21:22:00.668942 #16500] FATAL -- : no block given!
5
- W, [2007-02-12T21:22:00.863575 #16500] WARN -- : Error on attempt # 1: ; retrying
6
- W, [2007-02-12T21:22:01.865400 #16500] WARN -- : Error on attempt # 2: ; retrying
7
- W, [2007-02-12T21:22:03.874022 #16500] WARN -- : Error on attempt # 1: execution expired; retrying