ruport 0.10.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +55 -9
- data/Rakefile +3 -5
- data/examples/line_plotter.rb +3 -0
- data/examples/pdf_complex_report.rb +0 -1
- data/examples/pdf_report_with_common_base.rb +72 -0
- data/examples/pdf_styles.rb +16 -0
- data/examples/simple_pdf_lines.rb +0 -1
- data/lib/ruport.rb +5 -66
- data/lib/ruport/acts_as_reportable.rb +122 -51
- data/lib/ruport/data/grouping.rb +30 -13
- data/lib/ruport/data/record.rb +26 -25
- data/lib/ruport/data/table.rb +91 -34
- data/lib/ruport/formatter.rb +86 -11
- data/lib/ruport/formatter/csv.rb +29 -2
- data/lib/ruport/formatter/html.rb +23 -1
- data/lib/ruport/formatter/pdf.rb +123 -32
- data/lib/ruport/formatter/text.rb +62 -6
- data/lib/ruport/query.rb +75 -39
- data/lib/ruport/renderer.rb +250 -35
- data/lib/ruport/renderer/grouping.rb +2 -2
- data/test/html_formatter_test.rb +4 -1
- data/test/pdf_formatter_test.rb +30 -7
- data/test/query_test.rb +12 -0
- data/test/renderer_test.rb +33 -2
- data/test/table_test.rb +8 -2
- data/test/text_formatter_test.rb +11 -1
- metadata +53 -107
- data/bin/rope +0 -12
- data/examples/rope_examples/itunes/README +0 -12
- data/examples/rope_examples/itunes/Rakefile +0 -39
- data/examples/rope_examples/itunes/config/environment.rb +0 -4
- data/examples/rope_examples/itunes/data/mix.txt +0 -1
- data/examples/rope_examples/itunes/lib/helpers.rb +0 -0
- data/examples/rope_examples/itunes/lib/init.rb +0 -39
- data/examples/rope_examples/itunes/lib/reports.rb +0 -1
- data/examples/rope_examples/itunes/lib/reports/playlist.rb +0 -17
- data/examples/rope_examples/itunes/log/ruport.log +0 -1
- data/examples/rope_examples/itunes/test/test_playlist.rb +0 -8
- data/examples/rope_examples/itunes/util/build +0 -96
- data/examples/rope_examples/itunes/util/sql_exec +0 -5
- data/examples/rope_examples/sales_report/README +0 -4
- data/examples/rope_examples/sales_report/Rakefile +0 -39
- data/examples/rope_examples/sales_report/config/environment.rb +0 -4
- data/examples/rope_examples/sales_report/lib/helpers.rb +0 -0
- data/examples/rope_examples/sales_report/lib/init.rb +0 -39
- data/examples/rope_examples/sales_report/lib/reports.rb +0 -1
- data/examples/rope_examples/sales_report/lib/reports/sales.rb +0 -132
- data/examples/rope_examples/sales_report/log/ruport.log +0 -1
- data/examples/rope_examples/sales_report/output/books.pdf +0 -170
- data/examples/rope_examples/sales_report/output/books.txt +0 -11
- data/examples/rope_examples/sales_report/test/test_sales.rb +0 -8
- data/examples/rope_examples/sales_report/util/build +0 -96
- data/examples/rope_examples/sales_report/util/sql_exec +0 -5
- data/examples/sample.rb +0 -16
- data/lib/ruport/generator.rb +0 -294
- data/lib/ruport/report.rb +0 -262
- data/setup.rb +0 -1585
- data/test/report_test.rb +0 -218
- data/test/samples/foo.rtxt +0 -3
@@ -1 +0,0 @@
|
|
1
|
-
# Logfile created on Sat Feb 03 20:02:43 -0500 2007 by logger.rb/1.5.2.9
|
@@ -1,170 +0,0 @@
|
|
1
|
-
%PDF-1.3
|
2
|
-
%����
|
3
|
-
|
4
|
-
1 0 obj
|
5
|
-
<< /Type /Catalog
|
6
|
-
/Outlines 2 0 R
|
7
|
-
/Pages 3 0 R>>
|
8
|
-
endobj
|
9
|
-
2 0 obj
|
10
|
-
<< /Type /Outlines >>
|
11
|
-
endobj
|
12
|
-
3 0 obj
|
13
|
-
<< /Type /Pages
|
14
|
-
/Kids [6 0 R
|
15
|
-
]
|
16
|
-
/Count 1
|
17
|
-
/Resources <<
|
18
|
-
/ProcSet 4 0 R
|
19
|
-
/Font <<
|
20
|
-
/F1 8 0 R
|
21
|
-
/F2 10 0 R >>
|
22
|
-
>>
|
23
|
-
/MediaBox [0 0 612.0 792.0]
|
24
|
-
>>
|
25
|
-
endobj
|
26
|
-
4 0 obj
|
27
|
-
[/PDF /Text ]
|
28
|
-
endobj
|
29
|
-
5 0 obj
|
30
|
-
<<
|
31
|
-
/CreationDate (D:200702040113)
|
32
|
-
/Creator (sales.rb)
|
33
|
-
/Producer (PDF::Writer for Ruby)
|
34
|
-
>>
|
35
|
-
endobj
|
36
|
-
6 0 obj
|
37
|
-
<< /Type /Page
|
38
|
-
/Parent 3 0 R
|
39
|
-
/Contents [
|
40
|
-
7 0 R
|
41
|
-
11 0 R
|
42
|
-
]
|
43
|
-
>>
|
44
|
-
endobj
|
45
|
-
7 0 obj
|
46
|
-
<<
|
47
|
-
/Length 811 >>
|
48
|
-
stream
|
49
|
-
|
50
|
-
0.000 0.000 0.000 rg
|
51
|
-
0.000 0.000 0.000 RG
|
52
|
-
q
|
53
|
-
0.800 0.800 0.800 rg
|
54
|
-
381.000 756.000 m
|
55
|
-
571.000 756.000 l
|
56
|
-
573.500 756.000 576.000 753.500 576.000 751.000 c
|
57
|
-
576.000 741.000 l
|
58
|
-
576.000 738.500 573.500 736.000 571.000 736.000 c
|
59
|
-
381.000 736.000 l
|
60
|
-
378.500 736.000 376.000 738.500 376.000 741.000 c
|
61
|
-
376.000 751.000 l
|
62
|
-
376.000 753.500 378.500 756.000 381.000 756.000 c
|
63
|
-
576.000 736.000 m B
|
64
|
-
1 w
|
65
|
-
Q
|
66
|
-
BT 391.292 742.128 Td /F2 12.0 Tf 0 Tr (December 2006 Sales Figures) Tj ET
|
67
|
-
0.800 0.800 0.800 RG
|
68
|
-
BT 158.443 670.128 Td /F1 12.0 Tf 0 Tr (isbn) Tj ET
|
69
|
-
BT 235.830 670.128 Td /F1 12.0 Tf 0 Tr (title) Tj ET
|
70
|
-
BT 345.760 670.128 Td /F1 12.0 Tf 0 Tr (author) Tj ET
|
71
|
-
BT 415.269 670.128 Td /F1 12.0 Tf 0 Tr (sales) Tj ET
|
72
|
-
q
|
73
|
-
0.800 0.800 0.800 rg
|
74
|
-
153.443 648.068 295.114 15.560 re f
|
75
|
-
0.800 0.800 0.800 rg
|
76
|
-
153.443 616.948 295.114 15.560 re f
|
77
|
-
1 w
|
78
|
-
Q
|
79
|
-
endstream
|
80
|
-
endobj
|
81
|
-
|
82
|
-
8 0 obj
|
83
|
-
<< /Type /Font
|
84
|
-
/Subtype /Type1
|
85
|
-
/Name /F1
|
86
|
-
/BaseFont /Helvetica
|
87
|
-
/Encoding /WinAnsiEncoding
|
88
|
-
>>
|
89
|
-
endobj
|
90
|
-
9 0 obj
|
91
|
-
<< /Type /Encoding
|
92
|
-
/BaseEncoding /WinAnsiEncoding
|
93
|
-
|
94
|
-
>>
|
95
|
-
endobj
|
96
|
-
10 0 obj
|
97
|
-
<< /Type /Font
|
98
|
-
/Subtype /Type1
|
99
|
-
/Name /F2
|
100
|
-
/BaseFont /Helvetica-Bold
|
101
|
-
/Encoding 9 0 R
|
102
|
-
>>
|
103
|
-
endobj
|
104
|
-
11 0 obj
|
105
|
-
<<
|
106
|
-
/Length 1255 >>
|
107
|
-
stream
|
108
|
-
|
109
|
-
BT 158.443 652.318 Td /F1 10.0 Tf 0 Tr (978111111111) Tj ET
|
110
|
-
BT 235.830 652.318 Td /F1 10.0 Tf 0 Tr (Book Number One) Tj ET
|
111
|
-
BT 345.760 652.318 Td /F1 10.0 Tf 0 Tr (me) Tj ET
|
112
|
-
BT 415.269 652.318 Td /F1 10.0 Tf 0 Tr (10) Tj ET
|
113
|
-
BT 158.443 636.758 Td /F1 10.0 Tf 0 Tr (978222222222) Tj ET
|
114
|
-
BT 235.830 636.758 Td /F1 10.0 Tf 0 Tr (Two is better than one) Tj ET
|
115
|
-
BT 345.760 636.758 Td /F1 10.0 Tf 0 Tr (you) Tj ET
|
116
|
-
BT 415.269 636.758 Td /F1 10.0 Tf 0 Tr (267) Tj ET
|
117
|
-
BT 158.443 621.198 Td /F1 10.0 Tf 0 Tr (978333333333) Tj ET
|
118
|
-
BT 235.830 621.198 Td /F1 10.0 Tf 0 Tr (Three Blind Mice) Tj ET
|
119
|
-
BT 345.760 621.198 Td /F1 10.0 Tf 0 Tr (John Howard) Tj ET
|
120
|
-
BT 415.269 621.198 Td /F1 10.0 Tf 0 Tr (1) Tj ET
|
121
|
-
BT 158.443 605.638 Td /F1 10.0 Tf 0 Tr (978444444444) Tj ET
|
122
|
-
BT 235.830 605.638 Td /F1 10.0 Tf 0 Tr (The number 4) Tj ET
|
123
|
-
BT 345.760 605.638 Td /F1 10.0 Tf 0 Tr (George Bush) Tj ET
|
124
|
-
BT 415.269 605.638 Td /F1 10.0 Tf 0 Tr (1829) Tj ET
|
125
|
-
0.000 0.000 0.000 RG
|
126
|
-
1 w
|
127
|
-
153.443 686.000 m
|
128
|
-
153.443 601.388 l S
|
129
|
-
1 w
|
130
|
-
230.830 686.000 m
|
131
|
-
230.830 601.388 l S
|
132
|
-
340.760 686.000 m
|
133
|
-
340.760 601.388 l S
|
134
|
-
410.269 686.000 m
|
135
|
-
410.269 601.388 l S
|
136
|
-
1 w
|
137
|
-
448.557 686.000 m
|
138
|
-
448.557 601.388 l S
|
139
|
-
152.943 686.000 m
|
140
|
-
449.057 686.000 l S
|
141
|
-
153.443 665.878 m
|
142
|
-
448.557 665.878 l S
|
143
|
-
152.943 601.388 m
|
144
|
-
449.057 601.388 l S
|
145
|
-
endstream
|
146
|
-
endobj
|
147
|
-
|
148
|
-
xref
|
149
|
-
0 12
|
150
|
-
0000000000 65535 f
|
151
|
-
0000000015 00000 n
|
152
|
-
0000000079 00000 n
|
153
|
-
0000000116 00000 n
|
154
|
-
0000000269 00000 n
|
155
|
-
0000000298 00000 n
|
156
|
-
0000000403 00000 n
|
157
|
-
0000000477 00000 n
|
158
|
-
0000001340 00000 n
|
159
|
-
0000001447 00000 n
|
160
|
-
0000001516 00000 n
|
161
|
-
0000001618 00000 n
|
162
|
-
|
163
|
-
trailer
|
164
|
-
<< /Size 12
|
165
|
-
/Root 1 0 R
|
166
|
-
/Info 5 0 R
|
167
|
-
>>
|
168
|
-
startxref
|
169
|
-
2927
|
170
|
-
%%EOF
|
@@ -1,11 +0,0 @@
|
|
1
|
-
***************************************************************************
|
2
|
-
December 2006 Sales Figures
|
3
|
-
***************************************************************************
|
4
|
-
|
5
|
-
isbn |title |author |sales
|
6
|
-
###########################################################################
|
7
|
-
978111111111 |Book Number One |me |10
|
8
|
-
978222222222 |Two is better than one |you |267
|
9
|
-
978333333333 |Three Blind Mice |John Howard |1
|
10
|
-
978444444444 |The number 4 |George Bush |1829
|
11
|
-
###########################################################################
|
@@ -1,96 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'fileutils'
|
4
|
-
require 'lib/init.rb'
|
5
|
-
require "ruport/generator"
|
6
|
-
include FileUtils
|
7
|
-
include Ruport::Generator::Helpers
|
8
|
-
|
9
|
-
unless ARGV.length > 1
|
10
|
-
puts "usage: build [command] [options]"
|
11
|
-
exit
|
12
|
-
end
|
13
|
-
|
14
|
-
class_name = format_class_name(ARGV[1])
|
15
|
-
|
16
|
-
if ARGV[0].eql? "report"
|
17
|
-
check_for_files
|
18
|
-
File.open("lib/reports.rb", "a") { |f|
|
19
|
-
f.puts("require \"lib/reports/#{ARGV[1]}\"")
|
20
|
-
}
|
21
|
-
REP = <<EOR
|
22
|
-
require "lib/init"
|
23
|
-
class #{class_name} < Ruport::Report
|
24
|
-
|
25
|
-
def generate
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
if __FILE__ == $0
|
32
|
-
puts #{class_name}.run
|
33
|
-
end
|
34
|
-
EOR
|
35
|
-
|
36
|
-
TEST = <<EOR
|
37
|
-
require "test/unit"
|
38
|
-
require "lib/reports/#{ARGV[1]}"
|
39
|
-
|
40
|
-
class Test#{class_name} < Test::Unit::TestCase
|
41
|
-
def test_flunk
|
42
|
-
flunk "Write your real tests here or in any test/test_* file"
|
43
|
-
end
|
44
|
-
end
|
45
|
-
EOR
|
46
|
-
|
47
|
-
File.open("lib/reports/#{ARGV[1]}.rb", "w") { |f| f << REP }
|
48
|
-
puts "reports file: lib/reports/#{ARGV[1]}.rb"
|
49
|
-
puts "test file: test/test_#{ARGV[1]}.rb"
|
50
|
-
puts "class name: #{class_name}"
|
51
|
-
File.open("test/test_#{ARGV[1]}.rb","w") { |f| f << TEST }
|
52
|
-
|
53
|
-
elsif ARGV[0].eql? "renderer"
|
54
|
-
|
55
|
-
check_for_files
|
56
|
-
File.open("lib/renderers.rb","a") { |f|
|
57
|
-
f.puts("require \"lib/renderers/#{ARGV[1]}\"")
|
58
|
-
}
|
59
|
-
REP = <<EOR
|
60
|
-
require "lib/init"
|
61
|
-
|
62
|
-
class #{class_name} < Ruport::Renderer
|
63
|
-
stage :#{class_name.downcase}
|
64
|
-
end
|
65
|
-
|
66
|
-
class #{class_name}Formatter < Ruport::Formatter
|
67
|
-
|
68
|
-
# change to your format name, or add additional formats
|
69
|
-
renders :my_format, :for => #{class_name}
|
70
|
-
|
71
|
-
def build_#{class_name.downcase}
|
72
|
-
|
73
|
-
end
|
74
|
-
|
75
|
-
end
|
76
|
-
EOR
|
77
|
-
|
78
|
-
TEST = <<EOR
|
79
|
-
require "test/unit"
|
80
|
-
require "lib/renderers/#{ARGV[1]}"
|
81
|
-
|
82
|
-
class Test#{class_name} < Test::Unit::TestCase
|
83
|
-
def test_flunk
|
84
|
-
flunk "Write your real tests here or in any test/test_* file"
|
85
|
-
end
|
86
|
-
end
|
87
|
-
EOR
|
88
|
-
puts "renderer file: lib/renderers/#{ARGV[1]}.rb"
|
89
|
-
File.open("lib/renderers/#{ARGV[1]}.rb", "w") { |f| f << REP }
|
90
|
-
puts "test file: test/test_#{ARGV[1]}.rb"
|
91
|
-
|
92
|
-
puts "class name: #{class_name}"
|
93
|
-
File.open("test/test_#{ARGV[1]}.rb","w") { |f| f << TEST }
|
94
|
-
else
|
95
|
-
puts "Incorrect usage."
|
96
|
-
end
|
data/examples/sample.rb
DELETED
data/lib/ruport/generator.rb
DELETED
@@ -1,294 +0,0 @@
|
|
1
|
-
module Ruport
|
2
|
-
class Generator
|
3
|
-
extend FileUtils
|
4
|
-
|
5
|
-
module Helpers
|
6
|
-
def format_class_name(string)
|
7
|
-
string.downcase.split("_").map { |s| s.capitalize }.join
|
8
|
-
end
|
9
|
-
|
10
|
-
def check_for_files
|
11
|
-
if File.exist? "lib/reports/#{ARGV[1]}.rb"
|
12
|
-
raise "Report #{ARGV[1]} exists!"
|
13
|
-
end
|
14
|
-
|
15
|
-
if File.exist? "lib/renderers/#{ARGV[1]}.rb"
|
16
|
-
raise "Renderer #{ARGV[1]} exists!"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
begin
|
22
|
-
require "rubygems"
|
23
|
-
rescue LoadError
|
24
|
-
nil
|
25
|
-
end
|
26
|
-
require "ruport"
|
27
|
-
|
28
|
-
def self.build(proj)
|
29
|
-
@project = proj
|
30
|
-
build_directory_structure
|
31
|
-
build_init
|
32
|
-
build_config
|
33
|
-
build_utils
|
34
|
-
build_rakefile
|
35
|
-
puts "\nSuccessfully generated project: #{proj}"
|
36
|
-
end
|
37
|
-
|
38
|
-
|
39
|
-
def self.build_init
|
40
|
-
m = "#{project}/lib/init.rb"
|
41
|
-
puts " #{m}"
|
42
|
-
File.open(m,"w") { |f| f << INIT }
|
43
|
-
end
|
44
|
-
|
45
|
-
# Generates a trivial rakefile for use with Ruport.
|
46
|
-
def self.build_rakefile
|
47
|
-
m = "#{project}/Rakefile"
|
48
|
-
puts " #{m}"
|
49
|
-
File.open(m,"w") { |f| f << RAKEFILE }
|
50
|
-
end
|
51
|
-
|
52
|
-
# Generates the build.rb and sql_exec.rb utilities
|
53
|
-
def self.build_utils
|
54
|
-
|
55
|
-
m = "#{project}/util/build"
|
56
|
-
puts " #{m}"
|
57
|
-
File.open(m,"w") { |f| f << BUILD }
|
58
|
-
chmod(0755, m)
|
59
|
-
|
60
|
-
m = "#{project}/util/sql_exec"
|
61
|
-
puts " #{m}"
|
62
|
-
File.open(m,"w") { |f| f << SQL_EXEC }
|
63
|
-
chmod(0755, m)
|
64
|
-
end
|
65
|
-
|
66
|
-
# sets up the basic directory layout for a Ruport application
|
67
|
-
def self.build_directory_structure
|
68
|
-
mkdir project
|
69
|
-
puts "creating directories.."
|
70
|
-
%w[ test config output data lib lib/reports
|
71
|
-
lib/renderers templates sql log util].each do |d|
|
72
|
-
m="#{project}/#{d}"
|
73
|
-
puts " #{m}"
|
74
|
-
mkdir(m)
|
75
|
-
end
|
76
|
-
|
77
|
-
puts "creating files.."
|
78
|
-
%w[reports helpers renderers].each { |f|
|
79
|
-
m = "#{project}/lib/#{f}.rb"
|
80
|
-
puts " #{m}"
|
81
|
-
touch(m)
|
82
|
-
}
|
83
|
-
end
|
84
|
-
|
85
|
-
def self.build_config
|
86
|
-
m = "#{project}/config/environment.rb"
|
87
|
-
puts " #{m}"
|
88
|
-
File.open(m,"w") { |f| f << CONFIG }
|
89
|
-
end
|
90
|
-
|
91
|
-
# returns the project's name
|
92
|
-
def self.project; @project; end
|
93
|
-
|
94
|
-
RAKEFILE = <<'END_RAKEFILE'
|
95
|
-
begin; require "rubygems"; rescue LoadError; end
|
96
|
-
require "rake/testtask"
|
97
|
-
|
98
|
-
task :default => [:test]
|
99
|
-
|
100
|
-
Rake::TestTask.new do |test|
|
101
|
-
test.libs << "test"
|
102
|
-
test.pattern = 'test/**/test_*.rb'
|
103
|
-
test.verbose = true
|
104
|
-
end
|
105
|
-
|
106
|
-
task :build do
|
107
|
-
if ENV['report']
|
108
|
-
sh "ruby util/build report #{ENV['report']}"
|
109
|
-
elsif ENV['renderer']
|
110
|
-
sh "ruby util/build renderer #{ENV['renderer']}"
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
task :run do
|
115
|
-
sh "ruby lib/reports/#{ENV['report']}.rb"
|
116
|
-
end
|
117
|
-
|
118
|
-
task :use_utils do
|
119
|
-
raise "File lib/init_utils.rb exists!" if File.exist?('lib/init_utils.rb')
|
120
|
-
File.open('lib/init_utils.rb','w') { |f|
|
121
|
-
if ENV['only']
|
122
|
-
ENV['only'].split(',').each { |e|
|
123
|
-
f.puts "require 'ruport/util/#{e}'"
|
124
|
-
}
|
125
|
-
else
|
126
|
-
f.puts "require 'ruport/util'"
|
127
|
-
end
|
128
|
-
}
|
129
|
-
File.open('lib/init.rb','a') { |f|
|
130
|
-
f.puts '#comment out the line below to disable auto-loading of utils'
|
131
|
-
f.puts 'require "lib/init_utils.rb"'
|
132
|
-
}
|
133
|
-
end
|
134
|
-
END_RAKEFILE
|
135
|
-
|
136
|
-
CONFIG = <<END_CONFIG
|
137
|
-
require "ruport"
|
138
|
-
|
139
|
-
Ruport::Query.add_source :default, :user => "root",
|
140
|
-
:dsn => "dbi:mysql:mydb"
|
141
|
-
END_CONFIG
|
142
|
-
|
143
|
-
BUILD = <<'END_BUILD'
|
144
|
-
#!/usr/bin/env ruby
|
145
|
-
|
146
|
-
require 'fileutils'
|
147
|
-
require 'lib/init.rb'
|
148
|
-
require "ruport/generator"
|
149
|
-
include FileUtils
|
150
|
-
include Ruport::Generator::Helpers
|
151
|
-
|
152
|
-
unless ARGV.length > 1
|
153
|
-
puts "usage: build [command] [options]"
|
154
|
-
exit
|
155
|
-
end
|
156
|
-
|
157
|
-
class_name = format_class_name(ARGV[1])
|
158
|
-
|
159
|
-
if ARGV[0].eql? "report"
|
160
|
-
check_for_files
|
161
|
-
File.open("lib/reports.rb", "a") { |f|
|
162
|
-
f.puts("require \"lib/reports/#{ARGV[1]}\"")
|
163
|
-
}
|
164
|
-
REP = <<EOR
|
165
|
-
require "lib/init"
|
166
|
-
class #{class_name} < Ruport::Report
|
167
|
-
|
168
|
-
def generate
|
169
|
-
|
170
|
-
end
|
171
|
-
|
172
|
-
end
|
173
|
-
|
174
|
-
if __FILE__ == $0
|
175
|
-
puts #{class_name}.run
|
176
|
-
end
|
177
|
-
EOR
|
178
|
-
|
179
|
-
TEST = <<EOR
|
180
|
-
require "test/unit"
|
181
|
-
require "lib/reports/#{ARGV[1]}"
|
182
|
-
|
183
|
-
class Test#{class_name} < Test::Unit::TestCase
|
184
|
-
def test_flunk
|
185
|
-
flunk "Write your real tests here or in any test/test_* file"
|
186
|
-
end
|
187
|
-
end
|
188
|
-
EOR
|
189
|
-
|
190
|
-
File.open("lib/reports/#{ARGV[1]}.rb", "w") { |f| f << REP }
|
191
|
-
puts "reports file: lib/reports/#{ARGV[1]}.rb"
|
192
|
-
puts "test file: test/test_#{ARGV[1]}.rb"
|
193
|
-
puts "class name: #{class_name}"
|
194
|
-
File.open("test/test_#{ARGV[1]}.rb","w") { |f| f << TEST }
|
195
|
-
|
196
|
-
elsif ARGV[0].eql? "renderer"
|
197
|
-
|
198
|
-
check_for_files
|
199
|
-
File.open("lib/renderers.rb","a") { |f|
|
200
|
-
f.puts("require \"lib/renderers/#{ARGV[1]}\"")
|
201
|
-
}
|
202
|
-
REP = <<EOR
|
203
|
-
require "lib/init"
|
204
|
-
|
205
|
-
class #{class_name} < Ruport::Renderer
|
206
|
-
stage :#{class_name.downcase}
|
207
|
-
end
|
208
|
-
|
209
|
-
class #{class_name}Formatter < Ruport::Formatter
|
210
|
-
|
211
|
-
# change to your format name, or add additional formats
|
212
|
-
renders :my_format, :for => #{class_name}
|
213
|
-
|
214
|
-
def build_#{class_name.downcase}
|
215
|
-
|
216
|
-
end
|
217
|
-
|
218
|
-
end
|
219
|
-
EOR
|
220
|
-
|
221
|
-
TEST = <<EOR
|
222
|
-
require "test/unit"
|
223
|
-
require "lib/renderers/#{ARGV[1]}"
|
224
|
-
|
225
|
-
class Test#{class_name} < Test::Unit::TestCase
|
226
|
-
def test_flunk
|
227
|
-
flunk "Write your real tests here or in any test/test_* file"
|
228
|
-
end
|
229
|
-
end
|
230
|
-
EOR
|
231
|
-
puts "renderer file: lib/renderers/#{ARGV[1]}.rb"
|
232
|
-
File.open("lib/renderers/#{ARGV[1]}.rb", "w") { |f| f << REP }
|
233
|
-
puts "test file: test/test_#{ARGV[1]}.rb"
|
234
|
-
|
235
|
-
puts "class name: #{class_name}"
|
236
|
-
File.open("test/test_#{ARGV[1]}.rb","w") { |f| f << TEST }
|
237
|
-
else
|
238
|
-
puts "Incorrect usage."
|
239
|
-
end
|
240
|
-
END_BUILD
|
241
|
-
|
242
|
-
SQL_EXEC = <<'END_SQL'
|
243
|
-
#!/usr/bin/env ruby
|
244
|
-
|
245
|
-
require "lib/init"
|
246
|
-
|
247
|
-
puts Ruport::Query.new(ARGF.read).result
|
248
|
-
END_SQL
|
249
|
-
|
250
|
-
INIT = <<END_INIT
|
251
|
-
begin
|
252
|
-
require "rubygems"
|
253
|
-
gem "ruport","=#{Ruport::VERSION}"
|
254
|
-
rescue LoadError
|
255
|
-
nil
|
256
|
-
end
|
257
|
-
require "ruport"
|
258
|
-
require "lib/helpers"
|
259
|
-
require "config/environment"
|
260
|
-
|
261
|
-
class String
|
262
|
-
def /(other)
|
263
|
-
self + "/" + other
|
264
|
-
end
|
265
|
-
end
|
266
|
-
|
267
|
-
class Ruport::Report
|
268
|
-
|
269
|
-
def output_dir
|
270
|
-
config.output_dir or dir('output')
|
271
|
-
end
|
272
|
-
|
273
|
-
def data_dir
|
274
|
-
config.data_dir or dir('data')
|
275
|
-
end
|
276
|
-
|
277
|
-
def query_dir
|
278
|
-
config.query_dir or dir('sql')
|
279
|
-
end
|
280
|
-
|
281
|
-
def template_dir
|
282
|
-
config.template_dir or dir('templates')
|
283
|
-
end
|
284
|
-
|
285
|
-
private
|
286
|
-
def dir(name)
|
287
|
-
"#{FileUtils.pwd}/#{ARGV[0]}/\#{name}"
|
288
|
-
end
|
289
|
-
end
|
290
|
-
END_INIT
|
291
|
-
|
292
|
-
|
293
|
-
end
|
294
|
-
end
|