ruport-util 0.4.0 → 0.5.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/INSTALL +42 -0
- data/Rakefile +7 -8
- data/example/graph_report.rb +1 -1
- data/lib/ruport/util/bench.rb +35 -0
- data/lib/ruport/util/generator.rb +307 -46
- data/lib/ruport/util/graph.rb +9 -9
- data/lib/ruport/util/invoice.rb +2 -2
- data/lib/ruport/util/mailer.rb +3 -1
- data/lib/ruport/util/report.rb +0 -2
- data/lib/ruport/util/report_manager.rb +1 -45
- data/lib/ruport/util.rb +1 -1
- data/test/test_invoice.rb +1 -1
- metadata +10 -6
data/INSTALL
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
== What is it?
|
2
|
+
|
3
|
+
ruport-util provides a home for marooned former parts of Ruby Reports,
|
4
|
+
and newer fringe ideas.
|
5
|
+
|
6
|
+
Support as of 2007.05.01:
|
7
|
+
|
8
|
+
* Basic Graphing (util/graph)
|
9
|
+
* Report runner (util/report)
|
10
|
+
* Report Mailing (util/mailer)
|
11
|
+
* Report Manager (util/report_manager)
|
12
|
+
* Invoices (util/invoice)
|
13
|
+
* Ruport centric code generation via the rope command.
|
14
|
+
|
15
|
+
See example/ for more information
|
16
|
+
|
17
|
+
== Getting Ruport
|
18
|
+
|
19
|
+
To use ruport-util, you'll need Ruport >= 0.12.0
|
20
|
+
|
21
|
+
sudo gem install ruport -y
|
22
|
+
|
23
|
+
== Installing ruport-util
|
24
|
+
|
25
|
+
It's on RubyForge:
|
26
|
+
|
27
|
+
gem install ruport-util -y
|
28
|
+
|
29
|
+
== Using
|
30
|
+
|
31
|
+
To load all of the tools at once:
|
32
|
+
|
33
|
+
require "ruport/util"
|
34
|
+
|
35
|
+
To load just one tool:
|
36
|
+
|
37
|
+
require "ruport/util/graph"
|
38
|
+
|
39
|
+
== Help?
|
40
|
+
|
41
|
+
Please report any problems on the Ruport mailing list:
|
42
|
+
http://list.rubyreports.org
|
data/Rakefile
CHANGED
@@ -18,7 +18,7 @@ end
|
|
18
18
|
|
19
19
|
spec = Gem::Specification.new do |spec|
|
20
20
|
spec.name = "ruport-util"
|
21
|
-
spec.version = "0.
|
21
|
+
spec.version = "0.5.0"
|
22
22
|
spec.platform = Gem::Platform::RUBY
|
23
23
|
spec.summary = "A set of tools and helper libs for Ruby Reports"
|
24
24
|
spec.files = Dir.glob("{example,lib,test,bin}/**/**/*") +
|
@@ -30,10 +30,10 @@ spec = Gem::Specification.new do |spec|
|
|
30
30
|
spec.bindir = "bin"
|
31
31
|
spec.executables = FileList["rope"]
|
32
32
|
spec.has_rdoc = true
|
33
|
-
spec.extra_rdoc_files = %w{}
|
34
|
-
spec.rdoc_options << '--title' << '
|
35
|
-
|
36
|
-
spec.add_dependency('ruport', ">=0.
|
33
|
+
spec.extra_rdoc_files = %w{INSTALL}
|
34
|
+
spec.rdoc_options << '--title' << 'ruport-util Documentation' <<
|
35
|
+
'--main' << 'INSTALL' << '-q'
|
36
|
+
spec.add_dependency('ruport', ">=0.11.0")
|
37
37
|
spec.add_dependency('scruffy', ">=0.2.2")
|
38
38
|
spec.add_dependency('mailfactory',">=1.2.3")
|
39
39
|
spec.author = "Gregory Brown"
|
@@ -47,10 +47,9 @@ END_DESC
|
|
47
47
|
end
|
48
48
|
|
49
49
|
Rake::RDocTask.new do |rdoc|
|
50
|
-
rdoc.rdoc_files.include( "
|
51
|
-
"AUTHORS", "COPYING",
|
50
|
+
rdoc.rdoc_files.include( "COPYING", "INSTALL",
|
52
51
|
"LICENSE", "lib/" )
|
53
|
-
rdoc.main = "
|
52
|
+
rdoc.main = "INSTALL"
|
54
53
|
rdoc.rdoc_dir = "doc/html"
|
55
54
|
rdoc.title = "Ruport Documentation"
|
56
55
|
end
|
data/example/graph_report.rb
CHANGED
data/lib/ruport/util/bench.rb
CHANGED
@@ -1,3 +1,38 @@
|
|
1
|
+
# A strange little benchmarking utility that uses Ruport
|
2
|
+
# to output the results of benchmark suites. This is primarily an internal
|
3
|
+
# developers tool for Ruport, but you might find it interesting or useful.
|
4
|
+
#
|
5
|
+
# Example:
|
6
|
+
#
|
7
|
+
# require "ruport"
|
8
|
+
# require "ruport/util/bench"
|
9
|
+
# include Ruport::Bench
|
10
|
+
#
|
11
|
+
# class MyFormat < Ruport::Formatter;
|
12
|
+
# renders :nothing, :for => Ruport::Renderer::Row
|
13
|
+
# end
|
14
|
+
#
|
15
|
+
# record = Ruport::Data::Record.new [1,2,3]
|
16
|
+
#
|
17
|
+
# bench_suite do
|
18
|
+
# N = 10000
|
19
|
+
# bench_case("as(:nothing)",N) { record.as(:nothing) }
|
20
|
+
# bench_case("to_nothing",N) { record.to_nothing }
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# # output
|
24
|
+
#
|
25
|
+
# Running Bench Suite...
|
26
|
+
# > as(:nothing)... ok[2.12905]
|
27
|
+
# > to_nothing... ok[2.00278]
|
28
|
+
# +--------------------------------------+
|
29
|
+
# | name | iterations | realtime |
|
30
|
+
# +--------------------------------------+
|
31
|
+
# | as(:nothing) | 10000 | 2.12905 |
|
32
|
+
# | to_nothing | 10000 | 2.00278 |
|
33
|
+
# +--------------------------------------+
|
34
|
+
# Suite run time: 4.13183
|
35
|
+
#
|
1
36
|
module Ruport::Bench
|
2
37
|
|
3
38
|
require "benchmark"
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module Ruport
|
2
|
-
class Generator
|
2
|
+
class Generator #:nodoc:
|
3
3
|
extend FileUtils
|
4
4
|
|
5
|
-
module Helpers
|
5
|
+
module Helpers #:nodoc:
|
6
6
|
def format_class_name(string)
|
7
7
|
string.downcase.split("_").map { |s| s.capitalize }.join
|
8
8
|
end
|
@@ -32,27 +32,38 @@ module Ruport
|
|
32
32
|
build_init
|
33
33
|
build_config
|
34
34
|
build_utils
|
35
|
-
build_rakefile
|
35
|
+
build_rakefile
|
36
|
+
build_readme
|
37
|
+
|
36
38
|
puts "\nSuccessfully generated project: #{proj}"
|
37
|
-
end
|
38
|
-
|
39
|
-
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.write_file(path,options={})
|
42
|
+
options = {:io => STDOUT}.merge(options)
|
43
|
+
m = "#{project}/#{path}"
|
44
|
+
options[:io].puts " #{m}"
|
45
|
+
if options[:file]
|
46
|
+
options[:file] << yield
|
47
|
+
else
|
48
|
+
File.open(m,"w") { |f| f << yield }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
40
52
|
def self.build_init
|
41
|
-
|
42
|
-
puts " #{m}"
|
43
|
-
File.open(m,"w") { |f| f << INIT }
|
53
|
+
write_file("lib/init.rb") { INIT }
|
44
54
|
end
|
45
55
|
|
46
56
|
# Generates a trivial rakefile for use with Ruport.
|
47
57
|
def self.build_rakefile
|
48
|
-
|
49
|
-
|
50
|
-
|
58
|
+
write_file("Rakefile") { RAKEFILE }
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.build_readme
|
62
|
+
write_file("README") { README }
|
51
63
|
end
|
52
64
|
|
53
65
|
# Generates the build.rb and sql_exec.rb utilities
|
54
66
|
def self.build_utils
|
55
|
-
|
56
67
|
m = "#{project}/util/build"
|
57
68
|
puts " #{m}"
|
58
69
|
File.open(m,"w") { |f| f << BUILD }
|
@@ -68,8 +79,8 @@ module Ruport
|
|
68
79
|
def self.build_directory_structure
|
69
80
|
mkdir project
|
70
81
|
puts "creating directories.."
|
71
|
-
%w[ test config output data lib lib/reports
|
72
|
-
lib/renderers templates sql log util].each do |d|
|
82
|
+
%w[ test config output data data/models lib lib/reports
|
83
|
+
lib/renderers templates sql log util ].each do |d|
|
73
84
|
m="#{project}/#{d}"
|
74
85
|
puts " #{m}"
|
75
86
|
mkdir(m)
|
@@ -84,9 +95,7 @@ module Ruport
|
|
84
95
|
end
|
85
96
|
|
86
97
|
def self.build_config
|
87
|
-
|
88
|
-
puts " #{m}"
|
89
|
-
File.open(m,"w") { |f| f << CONFIG }
|
98
|
+
write_file("config/environment.rb") { CONFIG }
|
90
99
|
end
|
91
100
|
|
92
101
|
# returns the project's name
|
@@ -109,6 +118,8 @@ task :build do
|
|
109
118
|
sh "ruby util/build report #{ENV['report']}"
|
110
119
|
elsif ENV['renderer']
|
111
120
|
sh "ruby util/build renderer #{ENV['renderer']}"
|
121
|
+
elsif ENV['model']
|
122
|
+
sh "ruby util/build model #{ENV['model']}"
|
112
123
|
end
|
113
124
|
end
|
114
125
|
|
@@ -120,8 +131,23 @@ END_RAKEFILE
|
|
120
131
|
CONFIG = <<END_CONFIG
|
121
132
|
require "ruport"
|
122
133
|
|
123
|
-
|
124
|
-
|
134
|
+
# Uncomment and modify the lines below if you want to use query.rb
|
135
|
+
#
|
136
|
+
# Ruport::Query.add_source :default, :user => "root",
|
137
|
+
# :dsn => "dbi:mysql:mydb"
|
138
|
+
|
139
|
+
# Uncomment and modify the lines below if you want to use AAR
|
140
|
+
#
|
141
|
+
# require "active_record"
|
142
|
+
# require "ruport/acts_as_reportable"
|
143
|
+
# ActiveRecord::Base.establish_connection(
|
144
|
+
# :adapter => 'mysql',
|
145
|
+
# :host => 'localhost',
|
146
|
+
# :username => 'name',
|
147
|
+
# :password => 'password',
|
148
|
+
# :database => 'mydb'
|
149
|
+
# )
|
150
|
+
|
125
151
|
END_CONFIG
|
126
152
|
|
127
153
|
BUILD = <<'END_BUILD'
|
@@ -217,7 +243,24 @@ EOR
|
|
217
243
|
puts "test file: test/test_#{ARGV[1]}.rb"
|
218
244
|
|
219
245
|
puts "class name: #{class_name}"
|
220
|
-
File.open("test/test_#{ARGV[1]}.rb","w") { |f| f << TEST }
|
246
|
+
File.open("test/test_#{ARGV[1]}.rb","w") { |f| f << TEST }
|
247
|
+
elsif ARGV[0].eql? "model"
|
248
|
+
if File.exist?("data/models/#{ARGV[1]}.rb")
|
249
|
+
raise "Model #{class_name} exists!"
|
250
|
+
end
|
251
|
+
File.open("data/models.rb","a") { |f|
|
252
|
+
f.puts("require \"data/models/#{ARGV[1]}\"")
|
253
|
+
}
|
254
|
+
REP = <<EOR
|
255
|
+
class #{class_name} < ActiveRecord::Base
|
256
|
+
|
257
|
+
acts_as_reportable
|
258
|
+
|
259
|
+
end
|
260
|
+
EOR
|
261
|
+
puts "model file: data/models/#{ARGV[1]}.rb"
|
262
|
+
File.open("data/models/#{ARGV[1]}.rb", "w") { |f| f << REP }
|
263
|
+
puts "class name: #{class_name}"
|
221
264
|
else
|
222
265
|
puts "Incorrect usage."
|
223
266
|
end
|
@@ -242,39 +285,257 @@ end
|
|
242
285
|
require "ruport"
|
243
286
|
require "ruport/util"
|
244
287
|
require "lib/helpers"
|
245
|
-
require "config/environment"
|
288
|
+
require "config/environment"
|
289
|
+
END_INIT
|
246
290
|
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
291
|
+
README = <<END_README
|
292
|
+
|
293
|
+
== rope : A Code Generation Tool for Ruby Reports ==
|
294
|
+
|
295
|
+
# Overview
|
296
|
+
|
297
|
+
Rope provides you with a number of simple utilities that script away
|
298
|
+
much of your boilerplate code, and also provide useful tools for
|
299
|
+
development, such as automatic test running and a way to check your
|
300
|
+
SQL queries for validity. Additionally, you'll get logging for free
|
301
|
+
and you can share a common configuration file between applications
|
302
|
+
in the same project.
|
303
|
+
|
304
|
+
Though each tool on it's own isn't complicated, having them all
|
305
|
+
working together can be a major win.
|
306
|
+
|
307
|
+
# The Basics
|
308
|
+
|
309
|
+
-- Starting a new rope project
|
310
|
+
|
311
|
+
$ rope labyrith
|
312
|
+
creating directories..
|
313
|
+
labyrith/test
|
314
|
+
labyrith/config
|
315
|
+
labyrith/output
|
316
|
+
labyrith/data
|
317
|
+
labyrith/data/models
|
318
|
+
labyrith/lib
|
319
|
+
labyrith/lib/reports
|
320
|
+
labyrith/lib/renderers
|
321
|
+
labyrith/templates
|
322
|
+
labyrith/sql
|
323
|
+
labyrith/log
|
324
|
+
labyrith/util
|
325
|
+
creating files..
|
326
|
+
labyrith/lib/reports.rb
|
327
|
+
labyrith/lib/helpers.rb
|
328
|
+
labyrith/lib/renderers.rb
|
329
|
+
labyrith/lib/init.rb
|
330
|
+
labyrith/config/environment.rb
|
331
|
+
labyrith/util/build
|
332
|
+
labyrith/util/sql_exec
|
333
|
+
labyrith/Rakefile
|
334
|
+
labyrith/README
|
335
|
+
|
336
|
+
Successfully generated project: labyrith
|
337
|
+
|
338
|
+
Once this is complete, you'll have a large number of mostly empty
|
339
|
+
folders laying around, along with some helpful tools at your disposal.
|
340
|
+
|
341
|
+
-- utilities
|
342
|
+
|
343
|
+
* build : A tool for generating reports and formatting system extensions
|
344
|
+
* sql_exec: A simple tool for getting a result set from a SQL file
|
345
|
+
(possibly with ERb)
|
346
|
+
* Rakefile: Script for project automation tasks.
|
347
|
+
|
348
|
+
-- directories
|
349
|
+
|
350
|
+
* test : unit tests stored here can be auto-run
|
351
|
+
* config : holds a configuration file which is shared across your applications
|
352
|
+
* reports : when reports are autogenerated, they are stored here
|
353
|
+
* renderers : autogenerated formatting system extensions are stored here
|
354
|
+
* models : stores autogenerated activerecord models
|
355
|
+
* templates : erb templates may be stored here
|
356
|
+
* sql : SQL files can be stored here, which are pre-processed by erb
|
357
|
+
* log : The logger will automatically store your logfiles here by default
|
358
|
+
* util : contains rope related tools
|
359
|
+
|
360
|
+
# Generating a Report definition with rope
|
361
|
+
|
362
|
+
$ ./util/build report ghosts
|
363
|
+
report file: lib/reports/ghosts.rb
|
364
|
+
test file: test/test_ghosts.rb
|
365
|
+
class name: Ghosts
|
366
|
+
|
367
|
+
$ rake
|
368
|
+
(in /home/sandal/labyrinth)
|
369
|
+
/usr/bin/ruby -Ilib:test
|
370
|
+
"/usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake/rake_test_loader.rb"
|
371
|
+
"test/test_ghosts.rb"
|
372
|
+
Loaded suite /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake/rake_test_loader
|
373
|
+
Started
|
374
|
+
F
|
375
|
+
Finished in 0.001119 seconds.
|
376
|
+
|
377
|
+
1) Failure:
|
378
|
+
test_flunk(TestGhosts) [./test/test_ghosts.rb:6]:
|
379
|
+
Write your real tests here or in any test/test_* file.
|
380
|
+
|
381
|
+
1 tests, 1 assertions, 1 failures, 0 errors
|
382
|
+
rake aborted!
|
383
|
+
Command failed with status (1): [/usr/bin/ruby -Ilib:test
|
384
|
+
"/usr/lib/ruby/ge...]
|
385
|
+
|
386
|
+
(See full trace by running task with --trace)
|
387
|
+
|
388
|
+
You can now edit lib/reports/ghosts.rb as needed and write tests for
|
389
|
+
it in test/test_ghosts.rb without having to hook up any underplumbing.
|
390
|
+
|
391
|
+
# Rope's Auto-generated Configuration File
|
392
|
+
|
393
|
+
-- Basic Details
|
394
|
+
|
395
|
+
roped projects will automatically make use of the configuration details in
|
396
|
+
config/environment.rb , which can be used to set up database
|
397
|
+
connections, Ruport's mailer, and other project information.
|
398
|
+
|
399
|
+
The default file is shown below.
|
252
400
|
|
253
|
-
|
254
|
-
|
255
|
-
def output_dir
|
256
|
-
config.output_dir or dir('output')
|
257
|
-
end
|
401
|
+
require "ruport"
|
258
402
|
|
259
|
-
|
260
|
-
|
261
|
-
|
403
|
+
# Uncomment and modify the lines below if you want to use query.rb
|
404
|
+
#
|
405
|
+
# Ruport::Query.add_source :default, :user => "root",
|
406
|
+
# :dsn => "dbi:mysql:mydb"
|
262
407
|
|
263
|
-
|
264
|
-
|
265
|
-
|
408
|
+
# Uncomment and modify the lines below if you want to use AAR
|
409
|
+
#
|
410
|
+
# require "active_record"
|
411
|
+
# require "ruport/acts_as_reportable"
|
412
|
+
# ActiveRecord::Base.establish_connection(
|
413
|
+
# :adapter => 'mysql',
|
414
|
+
# :host => 'localhost',
|
415
|
+
# :username => 'name',
|
416
|
+
# :password => 'password',
|
417
|
+
# :database => 'mydb'
|
418
|
+
# )
|
266
419
|
|
267
|
-
|
268
|
-
|
269
|
-
|
420
|
+
You'll need to tweak this as needed to fit your database configuration needs.
|
421
|
+
If you need to require any third party libraries which are shared across your
|
422
|
+
project, you should do it in this file.
|
423
|
+
|
424
|
+
# Custom rendering with rope generators.
|
425
|
+
|
426
|
+
-- By Example
|
427
|
+
|
428
|
+
$ rope my_reverser
|
429
|
+
$ cd my_reverser
|
430
|
+
$ rake build renderer=reverser
|
431
|
+
|
432
|
+
Edit test/test_reverser.rb to look like the code below:
|
433
|
+
|
434
|
+
require "test/unit"
|
435
|
+
require "lib/renderers/reverser"
|
436
|
+
|
437
|
+
class TestReverser < Test::Unit::TestCase
|
438
|
+
def test_reverser
|
439
|
+
assert_equal "baz", Reverser.render_text("zab")
|
440
|
+
end
|
441
|
+
end
|
442
|
+
|
443
|
+
Now edit lib/renderers/reverser.rb to look like this:
|
444
|
+
|
445
|
+
require "lib/init"
|
446
|
+
|
447
|
+
class Reverser < Ruport::Renderer
|
448
|
+
stage :reverser
|
449
|
+
end
|
450
|
+
|
451
|
+
class ReverserFormatter < Ruport::Formatter
|
452
|
+
|
453
|
+
renders :text, :for => Reverser
|
454
|
+
|
455
|
+
def build_reverser
|
456
|
+
output << data.reverse
|
457
|
+
end
|
458
|
+
|
459
|
+
end
|
460
|
+
|
461
|
+
The tests should pass. You can now generate a quick report using this renderer
|
462
|
+
|
463
|
+
$ rake build report=reversed_report
|
464
|
+
|
465
|
+
Edit test/test_reversed_report.rb as such:
|
466
|
+
|
467
|
+
require "test/unit"
|
468
|
+
require "lib/reports/reversed_report"
|
469
|
+
|
470
|
+
class TestReversedReport < Test::Unit::TestCase
|
471
|
+
def test_reversed_report
|
472
|
+
report = ReversedReport.new
|
473
|
+
report.message = "hello"
|
474
|
+
assert_equal "olleh", report.to_text
|
475
|
+
end
|
476
|
+
end
|
477
|
+
|
478
|
+
edit lib/reports/reversed_report.rb as below and run the tests.
|
479
|
+
|
480
|
+
require "lib/init"
|
481
|
+
require "lib/renderers/reverser"
|
482
|
+
class ReversedReport < Ruport::Report
|
483
|
+
|
484
|
+
renders_with Reverser
|
485
|
+
attr_accessor :message
|
486
|
+
|
487
|
+
def generate
|
488
|
+
message
|
489
|
+
end
|
490
|
+
|
491
|
+
end
|
492
|
+
|
493
|
+
# ActiveRecord integration the lazy way.
|
494
|
+
|
495
|
+
Ruport now has built in support for acts_as_reportable, which provides
|
496
|
+
ActiveRecord integration with ruport.
|
497
|
+
|
498
|
+
-- Setup details
|
499
|
+
|
500
|
+
Edit the following code in config/environment.rb
|
501
|
+
(change as needed to match your config information)
|
502
|
+
|
503
|
+
ActiveRecord::Base.establish_connection(
|
504
|
+
:adapter => 'mysql',
|
505
|
+
:host => 'localhost',
|
506
|
+
:username => 'name',
|
507
|
+
:password => 'password',
|
508
|
+
:database => 'mydb'
|
509
|
+
)
|
510
|
+
|
511
|
+
-- Generating a model
|
512
|
+
|
513
|
+
Here is an example of generating the model file:
|
514
|
+
|
515
|
+
$ util/build model my_model
|
516
|
+
model file: data/models/my_model.rb
|
517
|
+
class name: MyModel
|
518
|
+
|
519
|
+
This will create a barebones model that looks like this:
|
520
|
+
|
521
|
+
class MyModel < ActiveRecord::Base
|
522
|
+
|
523
|
+
acts_as_reportable
|
270
524
|
|
271
|
-
private
|
272
|
-
def dir(name)
|
273
|
-
"#{FileUtils.pwd}/#{ARGV[0]}/\#{name}"
|
274
|
-
end
|
275
525
|
end
|
276
|
-
END_INIT
|
277
526
|
|
527
|
+
The data/models.rb file will require all generated models,
|
528
|
+
but you can of course require specific models in your reports.
|
529
|
+
|
530
|
+
This should be enought to get you started, but for more complex needs,
|
531
|
+
check the appropriate acts_as_reportable / ActiveRecord documentation.
|
532
|
+
|
533
|
+
# Getting Help / Reporting Problems
|
534
|
+
|
535
|
+
rope is an officially supported utility for the Ruby Reports project, in
|
536
|
+
the ruport-util package. If you run into problems or have feature requests,
|
537
|
+
please contact us at http://list.rubyreports.org
|
538
|
+
END_README
|
278
539
|
|
279
540
|
end
|
280
541
|
end
|
data/lib/ruport/util/graph.rb
CHANGED
@@ -60,8 +60,8 @@ module Ruport
|
|
60
60
|
#
|
61
61
|
# == Supported Format Plugins
|
62
62
|
#
|
63
|
-
# *
|
64
|
-
# *
|
63
|
+
# * Formatter::XML
|
64
|
+
# * Formatter::SVG
|
65
65
|
#
|
66
66
|
# == Default layout options
|
67
67
|
#
|
@@ -85,8 +85,8 @@ module Ruport
|
|
85
85
|
finalize :graph
|
86
86
|
|
87
87
|
end
|
88
|
-
|
89
|
-
class SVG < Formatter
|
88
|
+
|
89
|
+
class Formatter::SVG < Formatter
|
90
90
|
|
91
91
|
renders :svg, :for => Renderer::Graph
|
92
92
|
|
@@ -94,7 +94,7 @@ module Ruport
|
|
94
94
|
#
|
95
95
|
# You can use these by setting options.theme like this:
|
96
96
|
#
|
97
|
-
# Graph.render_svg
|
97
|
+
# Graph.render_svg(:theme => :mephisto)
|
98
98
|
#
|
99
99
|
# Available themes: ( :mephisto, :keynote, :ruby_blog )
|
100
100
|
#
|
@@ -122,9 +122,8 @@ module Ruport
|
|
122
122
|
#
|
123
123
|
def prepare_graph
|
124
124
|
@graph.title ||= options.title
|
125
|
-
@graph.theme = options.theme if options.theme
|
125
|
+
@graph.theme = themes[options.theme] if options.theme
|
126
126
|
@graph.point_markers ||= data.column_names
|
127
|
-
|
128
127
|
end
|
129
128
|
|
130
129
|
# Generates an SVG using Scruffy.
|
@@ -134,7 +133,8 @@ module Ruport
|
|
134
133
|
end
|
135
134
|
|
136
135
|
output << @graph.render(
|
137
|
-
:size => [options.width||500, options.height||300]
|
136
|
+
:size => [options.width||500, options.height||300],
|
137
|
+
:min_value => options[:min], :max_value => options[:max]
|
138
138
|
)
|
139
139
|
end
|
140
140
|
|
@@ -148,7 +148,7 @@ module Ruport
|
|
148
148
|
|
149
149
|
end
|
150
150
|
|
151
|
-
class XML_SWF < Formatter
|
151
|
+
class Formatter::XML_SWF < Formatter
|
152
152
|
|
153
153
|
renders :xml_swf, :for => Renderer::Graph
|
154
154
|
|
data/lib/ruport/util/invoice.rb
CHANGED
data/lib/ruport/util/mailer.rb
CHANGED
@@ -38,7 +38,9 @@ module Ruport
|
|
38
38
|
#
|
39
39
|
class Mailer
|
40
40
|
|
41
|
-
class InvalidMailerConfigurationError < RuntimeError
|
41
|
+
class InvalidMailerConfigurationError < RuntimeError #:nodoc:
|
42
|
+
end
|
43
|
+
|
42
44
|
extend Forwardable
|
43
45
|
|
44
46
|
# Creates a new Mailer object. Optionally, you can select a mailer
|
data/lib/ruport/util/report.rb
CHANGED
@@ -317,8 +317,6 @@ module Ruport
|
|
317
317
|
# Defines an instance method which will be run before the
|
318
318
|
# <tt>generate</tt> method when Ruport.run is executed.
|
319
319
|
#
|
320
|
-
# Good for setting config info and perhaps files and/or loggers.
|
321
|
-
#
|
322
320
|
def prepare(&block); define_method(:prepare,&block) end
|
323
321
|
|
324
322
|
# Defines an instance method which will be executed by Report.run.
|
@@ -46,48 +46,4 @@ class Ruport::Report
|
|
46
46
|
def self.acts_as_managed_report
|
47
47
|
Ruport::ReportManager.add_report(self)
|
48
48
|
end
|
49
|
-
end
|
50
|
-
|
51
|
-
if __FILE__ == $PROGRAM_NAME
|
52
|
-
|
53
|
-
include Ruport
|
54
|
-
|
55
|
-
require "test/unit"
|
56
|
-
|
57
|
-
# we'll autoregister this one
|
58
|
-
class FakeModel
|
59
|
-
ReportManager.add_model(self)
|
60
|
-
end
|
61
|
-
|
62
|
-
# we'll add these afterwards
|
63
|
-
class FakeModel2;end
|
64
|
-
class FakeModel3;end
|
65
|
-
|
66
|
-
|
67
|
-
class TestReportManager < Test::Unit::TestCase
|
68
|
-
|
69
|
-
def test_simple_usage
|
70
|
-
assert_equal [FakeModel], ReportManager.models
|
71
|
-
assert_equal FakeModel, ReportManager["FakeModel"]
|
72
|
-
end
|
73
|
-
|
74
|
-
def test_add_models_externally
|
75
|
-
klass = ReportManager.dup # we need to do this to make the tests work
|
76
|
-
# no need in production code
|
77
|
-
assert_equal [FakeModel], klass.models
|
78
|
-
|
79
|
-
klass.add_model(FakeModel2)
|
80
|
-
assert_equal [FakeModel,FakeModel2], klass.models
|
81
|
-
|
82
|
-
klass.add_model(FakeModel3)
|
83
|
-
assert_equal [FakeModel,FakeModel2, FakeModel3], klass.models
|
84
|
-
|
85
|
-
# let's make sure we can still grab these by name (a string)
|
86
|
-
[FakeModel,FakeModel2,FakeModel3].each do |m|
|
87
|
-
assert_equal m, klass[m.name]
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
49
|
+
end
|
data/lib/ruport/util.rb
CHANGED
data/test/test_invoice.rb
CHANGED
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
|
|
3
3
|
specification_version: 1
|
4
4
|
name: ruport-util
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2007-05-
|
6
|
+
version: 0.5.0
|
7
|
+
date: 2007-05-14 00:00:00 -04:00
|
8
8
|
summary: A set of tools and helper libs for Ruby Reports
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -54,6 +54,7 @@ files:
|
|
54
54
|
- test/samples/foo.rtxt
|
55
55
|
- bin/rope
|
56
56
|
- Rakefile
|
57
|
+
- INSTALL
|
57
58
|
test_files:
|
58
59
|
- test/test_graph_renderer.rb
|
59
60
|
- test/test_invoice.rb
|
@@ -62,9 +63,12 @@ test_files:
|
|
62
63
|
- test/test_report_manager.rb
|
63
64
|
rdoc_options:
|
64
65
|
- --title
|
65
|
-
-
|
66
|
-
|
67
|
-
|
66
|
+
- ruport-util Documentation
|
67
|
+
- --main
|
68
|
+
- INSTALL
|
69
|
+
- -q
|
70
|
+
extra_rdoc_files:
|
71
|
+
- INSTALL
|
68
72
|
executables:
|
69
73
|
- rope
|
70
74
|
extensions: []
|
@@ -79,7 +83,7 @@ dependencies:
|
|
79
83
|
requirements:
|
80
84
|
- - ">="
|
81
85
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.
|
86
|
+
version: 0.11.0
|
83
87
|
version:
|
84
88
|
- !ruby/object:Gem::Dependency
|
85
89
|
name: scruffy
|