ruport 0.4.23 → 0.4.99
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/AUTHORS +16 -8
- data/CHANGELOG +30 -1
- data/README +144 -114
- data/Rakefile +12 -4
- data/TODO +4 -7
- data/bin/rope +21 -28
- data/examples/line_graph.rb +36 -0
- data/examples/sample_invoice_report.rb +1 -1
- data/examples/simple_graph.rb +8 -0
- data/lib/SVG/Graph/Bar.rb +137 -0
- data/lib/SVG/Graph/BarBase.rb +140 -0
- data/lib/SVG/Graph/BarHorizontal.rb +136 -0
- data/lib/SVG/Graph/Graph.rb +977 -0
- data/lib/SVG/Graph/Line.rb +444 -0
- data/lib/SVG/Graph/Pie.rb +394 -0
- data/lib/SVG/Graph/Plot.rb +494 -0
- data/lib/SVG/Graph/Schedule.rb +373 -0
- data/lib/SVG/Graph/TimeSeries.rb +241 -0
- data/lib/ruport.rb +2 -2
- data/lib/ruport/config.rb +47 -3
- data/lib/ruport/data/collection.rb +17 -1
- data/lib/ruport/data/record.rb +101 -8
- data/lib/ruport/data/set.rb +81 -2
- data/lib/ruport/data/set.rb.rej +147 -0
- data/lib/ruport/data/set.rb~ +73 -0
- data/lib/ruport/data/table.rb +127 -2
- data/lib/ruport/data/taggable.rb +21 -2
- data/lib/ruport/format.rb +36 -44
- data/lib/ruport/format/engine.rb +21 -1
- data/lib/ruport/format/plugin.rb +64 -1
- data/lib/ruport/mailer.rb +70 -36
- data/lib/ruport/meta_tools.rb +15 -6
- data/lib/ruport/query.rb +1 -1
- data/lib/ruport/rails/reportable.rb +23 -1
- data/lib/ruport/report.rb +11 -11
- data/lib/ruport/report/invoice.rb +16 -0
- data/lib/ruport/system_extensions.rb +3 -55
- data/test/{tc_database.rb → _test_database.rb} +0 -0
- data/test/{tc_config.rb → test_config.rb} +0 -0
- data/test/{tc_format.rb → test_format.rb} +1 -0
- data/test/{tc_format_engine.rb → test_format_engine.rb} +14 -2
- data/test/test_graph.rb +101 -0
- data/test/{tc_invoice.rb → test_invoice.rb} +7 -1
- data/test/test_mailer.rb +108 -0
- data/test/test_meta_tools.rb +14 -0
- data/test/{tc_plugin.rb → test_plugin.rb} +12 -1
- data/test/{tc_query.rb → test_query.rb} +0 -0
- data/test/{tc_record.rb → test_record.rb} +9 -0
- data/test/{tc_report.rb → test_report.rb} +2 -1
- data/test/{tc_ruport.rb → test_ruport.rb} +0 -0
- data/test/test_set.rb +118 -0
- data/test/test_set.rb.rej +16 -0
- data/test/{tc_set.rb → test_set.rb~} +17 -0
- data/test/{tc_sql_split.rb → test_sql_split.rb} +0 -0
- data/test/{tc_table.rb → test_table.rb} +15 -0
- data/test/{tc_taggable.rb → test_taggable.rb} +0 -0
- data/test/unit.log +361 -0
- metadata +52 -30
- data/examples/bar.pdf +0 -193
- data/examples/f.log +0 -5
- data/examples/foo.pdf +0 -193
- data/lib/ruport/format/document.rb +0 -78
- data/lib/ruport/format/open_node.rb +0 -38
- data/test/tc_data_row.rb +0 -132
- data/test/tc_data_set.rb +0 -386
- data/test/tc_document.rb +0 -42
- data/test/tc_element.rb +0 -18
- data/test/tc_page.rb +0 -42
- data/test/tc_section.rb +0 -45
- data/test/ts_all.rb +0 -12
- data/test/ts_format.rb +0 -7
data/AUTHORS
CHANGED
@@ -1,15 +1,13 @@
|
|
1
|
-
Developers
|
2
|
-
---------------------------------------------------
|
1
|
+
= Developers
|
3
2
|
|
4
|
-
{Gregory Brown}[mailto:gregory.t.brown@gmail.com]
|
5
|
-
{Dudley Flanders}[mailto:dudley@misnomer.us]
|
3
|
+
- {Gregory Brown}[mailto:gregory.t.brown@gmail.com]
|
4
|
+
- {Dudley Flanders}[mailto:dudley@misnomer.us]
|
6
5
|
|
7
|
-
Contributors / People we've (legally) stolen from:
|
8
|
-
---------------------------------------------------
|
6
|
+
= Contributors / People we've (legally) stolen from:
|
9
7
|
|
10
8
|
James Edward Gray II:
|
11
|
-
- Original inspiration via query.rb
|
12
|
-
- system_extensions.rb
|
9
|
+
- Original inspiration via query.rb
|
10
|
+
- system_extensions.rb
|
13
11
|
|
14
12
|
Francis Hwang:
|
15
13
|
- SQLSplit
|
@@ -19,3 +17,13 @@ Simon Claret:
|
|
19
17
|
|
20
18
|
Dinko Mehinovic:
|
21
19
|
- util/release/raa.rb
|
20
|
+
- util/release/freshmeat.rb
|
21
|
+
|
22
|
+
James Healy:
|
23
|
+
- original inspiration for Invoice engine
|
24
|
+
- SVG::Graph integration
|
25
|
+
|
26
|
+
The SVG Graph support is made possible by SVG::Graph, which we have vendored
|
27
|
+
because a gem is not available.
|
28
|
+
See: http://www.germane-software.com/software/SVG/SVG::Graph/
|
29
|
+
|
data/CHANGELOG
CHANGED
@@ -1,4 +1,33 @@
|
|
1
|
-
The current version of Ruby Reports is 0.4.
|
1
|
+
The current version of Ruby Reports is 0.4.99
|
2
|
+
|
3
|
+
changes since 0.4.23
|
4
|
+
|
5
|
+
- Removed the legacy Format::Document|Element|Page|OpenNode classes
|
6
|
+
|
7
|
+
- Added lots of API documentation
|
8
|
+
|
9
|
+
- actions now will throw an error if they are already defined.
|
10
|
+
(Temporary collision remedy)
|
11
|
+
|
12
|
+
- You can now dup Sets
|
13
|
+
|
14
|
+
- Unit tests should no longer explode when PDF::Writer is not installed
|
15
|
+
|
16
|
+
- Added a simplistic Rake task for building the recipe book
|
17
|
+
|
18
|
+
- Added intuitive error message for invalid plugins
|
19
|
+
|
20
|
+
- Fixed an error in Tag duplication for Data::Record
|
21
|
+
|
22
|
+
- Ruport now has charting support via SVG::Graph
|
23
|
+
|
24
|
+
- reordering now has intuitive error messages
|
25
|
+
|
26
|
+
- Trimmed down system_extensions.rb to only include the relevant terminal
|
27
|
+
geometry code
|
28
|
+
|
29
|
+
- Record/Table reordering can now be expressed either as a splatted list or an
|
30
|
+
array. Eg %w[a b c] and "a","b","c" are both acceptable as arguments.
|
2
31
|
|
3
32
|
changes since 0.4.21
|
4
33
|
|
data/README
CHANGED
@@ -8,161 +8,191 @@
|
|
8
8
|
#
|
9
9
|
# Contents:
|
10
10
|
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
11
|
+
# - What Ruport Is.
|
12
|
+
# - Installation
|
13
|
+
# - Getting Started
|
14
|
+
# - Caveats.
|
15
|
+
# - Resources
|
16
|
+
# - Background and Summary
|
16
17
|
#
|
17
|
-
#
|
18
|
+
# = What Ruport Is.
|
18
19
|
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
20
|
+
# Ruby Reports is a software library that aims to make the task of reporting
|
21
|
+
# less tedious and painful. It provides tools for data acquisition, database
|
22
|
+
# interaction, formatting, and parsing/munging. Designed to be extensible,
|
23
|
+
# it is possible to use Ruport for quick specific tasks as well as to build
|
24
|
+
# robust reporting applications.
|
24
25
|
#
|
25
|
-
#
|
26
|
+
# = Installation
|
26
27
|
#
|
27
|
-
#
|
28
|
+
# Dependencies:
|
28
29
|
#
|
29
|
-
#
|
30
|
+
# Ruport has a number of dependencies.
|
30
31
|
#
|
31
|
-
#
|
32
|
-
#
|
32
|
+
# Ruby/DBI and appropriate dbds: Makes Query useable
|
33
|
+
# (must be installed manually)
|
33
34
|
#
|
34
|
-
#
|
35
|
-
#
|
35
|
+
# FasterCSV: Enables fast CSV parsing
|
36
|
+
# (available via rubygems)
|
36
37
|
#
|
37
|
-
#
|
38
|
-
#
|
38
|
+
# RedCloth: Enables textile/markdown filtering
|
39
|
+
# (available via rubygems)
|
39
40
|
#
|
40
|
-
#
|
41
|
-
#
|
41
|
+
# PDF::Writer: Enables printable documents
|
42
|
+
# (available via rubygems)
|
42
43
|
#
|
43
|
-
#
|
44
|
+
# MailFactory: For email support.
|
44
45
|
#
|
45
|
-
#
|
46
|
-
#
|
46
|
+
# Note that by installing any of the dependencies, either via gems or manually,
|
47
|
+
# their functionality will automatically be enabled.
|
47
48
|
#
|
48
|
-
#
|
49
|
+
# To install ruport via rubygems with all it's dependencies (except DBI):
|
49
50
|
#
|
50
|
-
#
|
51
|
+
# sudo gem install ruport
|
51
52
|
#
|
52
|
-
#
|
53
|
+
# To install ruport manually via setup.rb:
|
53
54
|
#
|
54
|
-
#
|
55
|
+
# sudo ruby setup.rb
|
55
56
|
#
|
56
|
-
#
|
57
|
+
# To not install ruport at all:
|
57
58
|
#
|
58
|
-
#
|
59
|
+
# ruby -Ipath/to/ruport/lib my_script.rb
|
59
60
|
#
|
60
|
-
#
|
61
|
+
# Check to see if it installed properly:
|
61
62
|
#
|
62
|
-
#
|
63
|
-
#
|
63
|
+
# ruby -rubygems -e "require 'ruport'; puts Ruport::VERSION"
|
64
|
+
# (omit the -rubygems flag if installed manually)
|
64
65
|
#
|
65
|
-
#
|
66
|
+
# If you get an error, please consult the mailing list.
|
66
67
|
#
|
67
|
-
#
|
68
|
+
# = Getting Started
|
68
69
|
#
|
69
|
-
#
|
70
|
-
# changing rapidly from version to version. Test suites are becoming
|
71
|
-
# increasingly robust, but have not identified all possible edge cases. If
|
72
|
-
# Ruport goes wild on you, it's because it hasn't been tamed yet.
|
70
|
+
# Building a report can be broadly broken up into two phases.
|
73
71
|
#
|
74
|
-
#
|
75
|
-
#
|
76
|
-
#
|
72
|
+
# == Data Collection and Manipulation
|
73
|
+
#
|
74
|
+
# To begin, your data must be read from its source and stored in Ruports
|
75
|
+
# standard data structures. Ruport::Data::Set, Ruport::Data::Table and
|
76
|
+
# Ruport::Data::Record have further information on how to work with with
|
77
|
+
# and store data in ruport.
|
78
|
+
#
|
79
|
+
# If you wish to retrieve your data using Ruby on Rails and ActiveRecord,
|
80
|
+
# Ruport::Reportable has some useful information; To pull your data directly
|
81
|
+
# from a database, Ruport::Query will be useful, and to build it manually
|
82
|
+
# Array has been extended with a convenience function or two.
|
83
|
+
#
|
84
|
+
# == Report Generation
|
85
|
+
#
|
86
|
+
# Once the data is ready, it can be rendered using a combination of
|
87
|
+
# Ruport::Format, Ruport::Format::Engine and Ruport::Format::Plugin.
|
88
|
+
# The engine defines the report type (tablular, invoice, graph, etc), and
|
89
|
+
# the plugin renders the engine into a final format (PDF, CSV, HTML, SVG).
|
90
|
+
# Engines will often interact with more than one plugin, to allow the same
|
91
|
+
# report to be rendered in multiple ways ie. as HTML and a PDF.
|
92
|
+
#
|
93
|
+
# To tie these together, a basic DSL is provided by Ruport::Report
|
94
|
+
#
|
95
|
+
# For further reading and specific examples, please explore the examples/
|
96
|
+
# directory in the source tree and read the Ruport Cookbook.
|
97
|
+
#
|
98
|
+
# = Caveats
|
99
|
+
#
|
100
|
+
# Ruport is experimental software. It's not completely tested and the API is
|
101
|
+
# changing rapidly from version to version. Test suites are becoming
|
102
|
+
# increasingly robust, but have not identified all possible edge cases. If
|
103
|
+
# Ruport goes wild on you, it's because it hasn't been tamed yet.
|
104
|
+
#
|
105
|
+
# The functionality is also not complete yet. There is a lot left to be added
|
106
|
+
# and there is a lot to think about. If you find yourself wondering why
|
107
|
+
# feature foo is in Ruport, chances are it just hasn't been written yet.
|
77
108
|
#
|
78
|
-
#
|
79
|
-
#
|
80
|
-
#
|
109
|
+
# Documentation so far is something that is a struggle to keep up with. As of
|
110
|
+
# this release, there is at least partial documentation for the API. This
|
111
|
+
# will continue to get better as time goes on.
|
81
112
|
#
|
82
|
-
#
|
83
|
-
#
|
84
|
-
#
|
113
|
+
# Platform independence is a priority, but I don't absolutely always have
|
114
|
+
# access to every OS / DBMS combination, so if something breaks on your
|
115
|
+
# system, please feel free to yell loud at the mailing list.
|
85
116
|
#
|
86
|
-
#
|
87
|
-
#
|
117
|
+
# That having been said, I do use ruport in my daily work. That means that it
|
118
|
+
# will probably have at least something you will find useful. Or so I hope.
|
88
119
|
#
|
89
|
-
#
|
120
|
+
# = Resources
|
90
121
|
#
|
91
|
-
#
|
92
|
-
#
|
93
|
-
#
|
122
|
+
# The best way to get help and make suggestions is the Ruport mailing list.
|
123
|
+
# This software is on the move, so the list is the most reliable way of getting
|
124
|
+
# up to date information.
|
94
125
|
#
|
95
|
-
#
|
96
|
-
#
|
126
|
+
# - You can sign up and/or view the archives here:
|
127
|
+
# http://lists.stonecode.org/listinfo.cgi/ruport-stonecode.org
|
97
128
|
#
|
98
|
-
#
|
99
|
-
#
|
100
|
-
#
|
129
|
+
# Please do not hesitate to use this list! I am happily accepting patches and
|
130
|
+
# documentation, as well as encouraging design discussions and also am quite
|
131
|
+
# curious about what people use or want to use ruport for.
|
101
132
|
#
|
102
|
-
#
|
103
|
-
#
|
104
|
-
#
|
133
|
+
# I will announce Ruport releases on RubyTalk, on the Ruport mailing list, on
|
134
|
+
# Freshmeat, RAA, and the new_haven.rb mailing list. If you would like to
|
135
|
+
# keep an eye out for releases, please monitor one of those places.
|
105
136
|
#
|
106
|
-
#
|
107
|
-
#
|
137
|
+
# - You may download Ruport's source from the project page:
|
138
|
+
# http://rubyforge.org/projects/ruport
|
108
139
|
#
|
109
|
-
#
|
110
|
-
#
|
140
|
+
# - The latest stable API documentation is available at:
|
141
|
+
# http://reporting.stonecode.org/docs
|
111
142
|
#
|
112
|
-
#
|
143
|
+
# There also will be some tutorials on ruport.infogami.com
|
113
144
|
#
|
114
|
-
#
|
115
|
-
#
|
116
|
-
#
|
117
|
-
#
|
118
|
-
#
|
145
|
+
# If you are interested in developing Ruport, please *never* study code in
|
146
|
+
# official releases. As this software is in it's early stages, it's essential
|
147
|
+
# to keep an eye on the subversion repository. If you let me know you are
|
148
|
+
# interested in working on something, I will let you know if I'm actively
|
149
|
+
# working on that section.
|
119
150
|
#
|
120
|
-
#
|
151
|
+
# - Grabbing the code from the svn trunk is simple:
|
121
152
|
#
|
122
|
-
#
|
153
|
+
# svn co svn://rubyforge.org//var/svn/ruport/trunk/
|
123
154
|
#
|
124
|
-
#
|
125
|
-
#
|
126
|
-
#
|
127
|
-
#
|
128
|
-
#
|
155
|
+
# Those who would like to become regular contributors will be given write
|
156
|
+
# access. Also, anyone interested in the internal design and project
|
157
|
+
# management aspects of Ruport can request to be added to our Trac
|
158
|
+
# account. This is primarily intended for people who are working on the
|
159
|
+
# project actively, though.
|
129
160
|
#
|
130
|
-
#
|
161
|
+
# = Background / Summary
|
131
162
|
#
|
132
|
-
#
|
133
|
-
#
|
134
|
-
#
|
135
|
-
#
|
136
|
-
#
|
137
|
-
#
|
138
|
-
#
|
139
|
-
#
|
140
|
-
#
|
141
|
-
#
|
142
|
-
#
|
143
|
-
#
|
144
|
-
#
|
145
|
-
#
|
146
|
-
#
|
147
|
-
#
|
148
|
-
#
|
149
|
-
#
|
150
|
-
#
|
151
|
-
#
|
152
|
-
#
|
153
|
-
# systems.
|
163
|
+
# Ruport aims to help you fetch data from various sources, perform
|
164
|
+
# manipulations on them as needed, and then output them in a variety
|
165
|
+
# of formats easily. The powerful ERb templating engine is integrated
|
166
|
+
# to let you embed Ruport code into your formatted data. Also, Ruport
|
167
|
+
# provides a high level interface to databases, to make getting
|
168
|
+
# your data easy.
|
169
|
+
#
|
170
|
+
# The core of Ruport is it's datastructures. Data::Record, Data::Table, and
|
171
|
+
# Data::Set provide tools that help with manipulation and preperation of data
|
172
|
+
# for reporting.
|
173
|
+
#
|
174
|
+
# The rest of the code is organized into three main models, Report, Query,
|
175
|
+
# and Format. Each is meant to be a high level interface to Ruport.
|
176
|
+
# The inner classes can be used where a decent level of customization
|
177
|
+
# is needed.
|
178
|
+
#
|
179
|
+
# Report is in some sense the 'controller' of your application, and provides
|
180
|
+
# methods to help you write a Reporting application
|
181
|
+
#
|
182
|
+
# Format provides support for building filters and specialized formatting
|
183
|
+
# systems.
|
154
184
|
#
|
155
|
-
#
|
156
|
-
#
|
157
|
-
#
|
158
|
-
#
|
185
|
+
# Query currently provides a high level interface to DBI.
|
186
|
+
# If you would like to query a database or load a sql dump,
|
187
|
+
# this class can help you do that. It can generate Data::Table objects on
|
188
|
+
# the fly, or feed you DBI:Rows, depending on what you need.
|
159
189
|
#
|
160
|
-
#
|
161
|
-
#
|
162
|
-
#
|
163
|
-
#
|
190
|
+
# Finally, Please consult the API documentation and/or source code for more
|
191
|
+
# information. (http://reporting.stonecode.org/docs). Not all classes have been
|
192
|
+
# documented but the ones that have may be easier to understand when their docs
|
193
|
+
# have been read. Also, feel free to contribute documentation.
|
164
194
|
#
|
165
|
-
#
|
195
|
+
# If you have any questions or concerns, hop on the mailing list and fire away!
|
166
196
|
#
|
167
|
-
#
|
168
|
-
#
|
197
|
+
# Thanks for downloading my software and I hope you enjoy it!
|
198
|
+
# -Greg
|
data/Rakefile
CHANGED
@@ -17,13 +17,13 @@ task :default => [:test]
|
|
17
17
|
|
18
18
|
Rake::TestTask.new do |test|
|
19
19
|
test.libs << "test"
|
20
|
-
test.test_files = [ "test/
|
20
|
+
test.test_files = Dir[ "test/test_*.rb" ]
|
21
21
|
test.verbose = true
|
22
22
|
end
|
23
23
|
|
24
24
|
spec = Gem::Specification.new do |spec|
|
25
25
|
spec.name = LEAN ? "lean-ruport" : "ruport"
|
26
|
-
spec.version = "0.4.
|
26
|
+
spec.version = "0.4.99"
|
27
27
|
spec.platform = Gem::Platform::RUBY
|
28
28
|
spec.summary = "A generalized Ruby report generation and templating engine."
|
29
29
|
spec.files = Dir.glob("{examples,lib,test,bin}/**/**/*") +
|
@@ -31,7 +31,7 @@ spec = Gem::Specification.new do |spec|
|
|
31
31
|
|
32
32
|
spec.require_path = "lib"
|
33
33
|
|
34
|
-
spec.
|
34
|
+
spec.test_files = Dir[ "test/test_*.rb" ]
|
35
35
|
spec.bindir = "bin"
|
36
36
|
spec.executables = FileList["rope"]
|
37
37
|
spec.has_rdoc = true
|
@@ -74,8 +74,16 @@ end
|
|
74
74
|
begin
|
75
75
|
require 'rcov/rcovtask'
|
76
76
|
Rcov::RcovTask.new do |t|
|
77
|
-
t.test_files = [ "test/
|
77
|
+
t.test_files = Dir[ "test/test_*.rb" ]
|
78
78
|
end
|
79
79
|
rescue LoadError
|
80
80
|
nil
|
81
81
|
end
|
82
|
+
|
83
|
+
desc "Generate Ruport Recipes. Assumes you have erb, redcloth, and htmldoc."
|
84
|
+
task :cookbook do
|
85
|
+
sh "erb doc/ruport_recipes.textile | redcloth >doc/temp.html"
|
86
|
+
sh "htmldoc --batch doc/ruport.book" rescue nil
|
87
|
+
rm "doc/temp.html"
|
88
|
+
mv "out.pdf", "doc/out.pdf"
|
89
|
+
end
|
data/TODO
CHANGED
@@ -1,8 +1,5 @@
|
|
1
|
-
TODO
|
1
|
+
= TODO
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
http://stonecode.svnrepository.com/ruport
|
7
|
-
|
8
|
-
- Check out the way Ruport.log prints
|
3
|
+
Any future plans are available on Ruports Trac website
|
4
|
+
|
5
|
+
http://stonecode.svnrepository.com/ruport/trac.cgi
|
data/bin/rope
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
1
3
|
require "fileutils"
|
2
4
|
include FileUtils
|
3
5
|
|
@@ -7,21 +9,20 @@ if ARGV.empty?
|
|
7
9
|
end
|
8
10
|
project = ARGV[0]
|
9
11
|
|
10
|
-
RAKEFILE =
|
11
|
-
require "rubygems" rescue LoadError
|
12
|
+
RAKEFILE = <<END_RAKEFILE
|
13
|
+
begin; require "rubygems"; rescue LoadError; end
|
12
14
|
require "rake/testtask"
|
13
15
|
|
14
16
|
task :default => [:test]
|
15
17
|
|
16
18
|
Rake::TestTask.new do |test|
|
17
|
-
test.libs
|
18
|
-
test.pattern =
|
19
|
-
test.verbose
|
19
|
+
test.libs << "test"
|
20
|
+
test.pattern = 'test/**/test_*.rb'
|
21
|
+
test.verbose = true
|
20
22
|
end
|
23
|
+
END_RAKEFILE
|
21
24
|
|
22
|
-
|
23
|
-
|
24
|
-
CONFIG = <<-EOS
|
25
|
+
CONFIG = <<END_CONFIG
|
25
26
|
require "ruport"
|
26
27
|
|
27
28
|
# For details, see Ruport::Config documentation
|
@@ -30,11 +31,9 @@ Ruport.configure { |c|
|
|
30
31
|
:dsn => "dbi:mysql:mydb"
|
31
32
|
c.log_file "log/ruport.log"
|
32
33
|
}
|
34
|
+
END_CONFIG
|
33
35
|
|
34
|
-
|
35
|
-
|
36
|
-
BUILD = '
|
37
|
-
|
36
|
+
BUILD = <<'END_BUILD'
|
38
37
|
def format_class_name(string)
|
39
38
|
string.downcase.split("_").map { |s| s.capitalize }.join
|
40
39
|
end
|
@@ -51,8 +50,8 @@ if ARGV[0].eql? "report"
|
|
51
50
|
File.open("app/reports.rb", "a") { |f|
|
52
51
|
f << "require \"app/reports/#{ARGV[1]}\""
|
53
52
|
}
|
54
|
-
REP =
|
55
|
-
require "rubygems" rescue LoadError
|
53
|
+
REP = <<EOR
|
54
|
+
begin; require "rubygems"; rescue LoadError; end
|
56
55
|
require "ruport"
|
57
56
|
require "config/ruport_config"
|
58
57
|
|
@@ -72,8 +71,8 @@ end
|
|
72
71
|
##{class_name}.run { |res| puts res.results }
|
73
72
|
EOR
|
74
73
|
|
75
|
-
TEST =
|
76
|
-
require "rubygems" rescue LoadError
|
74
|
+
TEST = <<EOR
|
75
|
+
begin; require "rubygems"; rescue LoadError; end
|
77
76
|
require "ruport"
|
78
77
|
require "test/unit"
|
79
78
|
require "app/reports/#{ARGV[1]}"
|
@@ -81,36 +80,30 @@ require "config/ruport_config"
|
|
81
80
|
|
82
81
|
class Test#{class_name} < Test::Unit::TestCase
|
83
82
|
def test_flunk
|
84
|
-
flunk "Write your real tests here or in any test/
|
83
|
+
flunk "Write your real tests here or in any test/test_* file"
|
85
84
|
end
|
86
85
|
end
|
87
86
|
EOR
|
88
87
|
File.open("app/reports/#{ARGV[1]}.rb", "w") { |f| f << REP }
|
89
|
-
File.open("test/
|
88
|
+
File.open("test/test_#{ARGV[1]}.rb","w") { |f| f << TEST }
|
90
89
|
end
|
91
|
-
|
90
|
+
END_BUILD
|
92
91
|
|
93
|
-
SQL_EXEC = '
|
94
|
-
require "rubygems" rescue LoadError
|
92
|
+
SQL_EXEC = <<'END_SQL'
|
93
|
+
begin; require "rubygems"; rescue LoadError; end
|
95
94
|
require "ruport"
|
96
95
|
require "config/ruport_config"
|
97
96
|
|
98
97
|
puts Ruport::Query.new(ARGF.read).result
|
99
|
-
|
98
|
+
END_SQL
|
100
99
|
|
101
100
|
mkdir project
|
102
|
-
|
103
101
|
%w[test config output data app app/reports templates sql log util].each do |d|
|
104
102
|
mkdir "#{project}/#{d}"
|
105
103
|
end
|
106
104
|
|
107
|
-
|
108
105
|
touch("#{project}/app/reports.rb")
|
109
106
|
File.open("#{project}/config/ruport_config.rb","w") { |f| f << CONFIG }
|
110
107
|
File.open("#{project}/Rakefile","w") { |f| f << RAKEFILE }
|
111
108
|
File.open("#{project}/util/build.rb","w") { |f| f << BUILD }
|
112
109
|
File.open("#{project}/util/sql_exec.rb","w") { |f| f << SQL_EXEC }
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|