ruport 0.4.23 → 0.4.99

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. data/AUTHORS +16 -8
  2. data/CHANGELOG +30 -1
  3. data/README +144 -114
  4. data/Rakefile +12 -4
  5. data/TODO +4 -7
  6. data/bin/rope +21 -28
  7. data/examples/line_graph.rb +36 -0
  8. data/examples/sample_invoice_report.rb +1 -1
  9. data/examples/simple_graph.rb +8 -0
  10. data/lib/SVG/Graph/Bar.rb +137 -0
  11. data/lib/SVG/Graph/BarBase.rb +140 -0
  12. data/lib/SVG/Graph/BarHorizontal.rb +136 -0
  13. data/lib/SVG/Graph/Graph.rb +977 -0
  14. data/lib/SVG/Graph/Line.rb +444 -0
  15. data/lib/SVG/Graph/Pie.rb +394 -0
  16. data/lib/SVG/Graph/Plot.rb +494 -0
  17. data/lib/SVG/Graph/Schedule.rb +373 -0
  18. data/lib/SVG/Graph/TimeSeries.rb +241 -0
  19. data/lib/ruport.rb +2 -2
  20. data/lib/ruport/config.rb +47 -3
  21. data/lib/ruport/data/collection.rb +17 -1
  22. data/lib/ruport/data/record.rb +101 -8
  23. data/lib/ruport/data/set.rb +81 -2
  24. data/lib/ruport/data/set.rb.rej +147 -0
  25. data/lib/ruport/data/set.rb~ +73 -0
  26. data/lib/ruport/data/table.rb +127 -2
  27. data/lib/ruport/data/taggable.rb +21 -2
  28. data/lib/ruport/format.rb +36 -44
  29. data/lib/ruport/format/engine.rb +21 -1
  30. data/lib/ruport/format/plugin.rb +64 -1
  31. data/lib/ruport/mailer.rb +70 -36
  32. data/lib/ruport/meta_tools.rb +15 -6
  33. data/lib/ruport/query.rb +1 -1
  34. data/lib/ruport/rails/reportable.rb +23 -1
  35. data/lib/ruport/report.rb +11 -11
  36. data/lib/ruport/report/invoice.rb +16 -0
  37. data/lib/ruport/system_extensions.rb +3 -55
  38. data/test/{tc_database.rb → _test_database.rb} +0 -0
  39. data/test/{tc_config.rb → test_config.rb} +0 -0
  40. data/test/{tc_format.rb → test_format.rb} +1 -0
  41. data/test/{tc_format_engine.rb → test_format_engine.rb} +14 -2
  42. data/test/test_graph.rb +101 -0
  43. data/test/{tc_invoice.rb → test_invoice.rb} +7 -1
  44. data/test/test_mailer.rb +108 -0
  45. data/test/test_meta_tools.rb +14 -0
  46. data/test/{tc_plugin.rb → test_plugin.rb} +12 -1
  47. data/test/{tc_query.rb → test_query.rb} +0 -0
  48. data/test/{tc_record.rb → test_record.rb} +9 -0
  49. data/test/{tc_report.rb → test_report.rb} +2 -1
  50. data/test/{tc_ruport.rb → test_ruport.rb} +0 -0
  51. data/test/test_set.rb +118 -0
  52. data/test/test_set.rb.rej +16 -0
  53. data/test/{tc_set.rb → test_set.rb~} +17 -0
  54. data/test/{tc_sql_split.rb → test_sql_split.rb} +0 -0
  55. data/test/{tc_table.rb → test_table.rb} +15 -0
  56. data/test/{tc_taggable.rb → test_taggable.rb} +0 -0
  57. data/test/unit.log +361 -0
  58. metadata +52 -30
  59. data/examples/bar.pdf +0 -193
  60. data/examples/f.log +0 -5
  61. data/examples/foo.pdf +0 -193
  62. data/lib/ruport/format/document.rb +0 -78
  63. data/lib/ruport/format/open_node.rb +0 -38
  64. data/test/tc_data_row.rb +0 -132
  65. data/test/tc_data_set.rb +0 -386
  66. data/test/tc_document.rb +0 -42
  67. data/test/tc_element.rb +0 -18
  68. data/test/tc_page.rb +0 -42
  69. data/test/tc_section.rb +0 -45
  70. data/test/ts_all.rb +0 -12
  71. 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.23
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
- # - What Ruport Is.
12
- # - Installation
13
- # - Caveats.
14
- # - Resources
15
- # - Background and Summary
11
+ # - What Ruport Is.
12
+ # - Installation
13
+ # - Getting Started
14
+ # - Caveats.
15
+ # - Resources
16
+ # - Background and Summary
16
17
  #
17
- # - What Ruport Is.
18
+ # = What Ruport Is.
18
19
  #
19
- # Ruby Reports is a software library that aims to make the task of reporting
20
- # less tedious and painful. It provides tools for data acquisition, database
21
- # interaction, formatting, and parsing/munging. Designed to be extensible,
22
- # it is possible to use Ruport for quick specific tasks as well as to build
23
- # robust reporting applications.
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
- # - Installation
26
+ # = Installation
26
27
  #
27
- # Dependencies:
28
+ # Dependencies:
28
29
  #
29
- # Ruport has a number of dependencies.
30
+ # Ruport has a number of dependencies.
30
31
  #
31
- # Ruby/DBI and appropriate dbds: Makes Query useable
32
- # (must be installed manually)
32
+ # Ruby/DBI and appropriate dbds: Makes Query useable
33
+ # (must be installed manually)
33
34
  #
34
- # FasterCSV: Enables fast CSV parsing
35
- # (available via rubygems)
35
+ # FasterCSV: Enables fast CSV parsing
36
+ # (available via rubygems)
36
37
  #
37
- # RedCloth: Enables textile/markdown filtering
38
- # (available via rubygems)
38
+ # RedCloth: Enables textile/markdown filtering
39
+ # (available via rubygems)
39
40
  #
40
- # PDF::Writer: Enables printable documents
41
- # (available via rubygems)
41
+ # PDF::Writer: Enables printable documents
42
+ # (available via rubygems)
42
43
  #
43
- # MailFactory: For email support.
44
+ # MailFactory: For email support.
44
45
  #
45
- # Note that by installing any of the dependencies, either via gems or manually,
46
- # their functionality will automatically be enabled.
46
+ # Note that by installing any of the dependencies, either via gems or manually,
47
+ # their functionality will automatically be enabled.
47
48
  #
48
- # To install ruport via rubygems with all it's dependencies (except DBI):
49
+ # To install ruport via rubygems with all it's dependencies (except DBI):
49
50
  #
50
- # sudo gem install ruport
51
+ # sudo gem install ruport
51
52
  #
52
- # To install ruport manually via setup.rb:
53
+ # To install ruport manually via setup.rb:
53
54
  #
54
- # sudo ruby setup.rb
55
+ # sudo ruby setup.rb
55
56
  #
56
- # To not install ruport at all:
57
+ # To not install ruport at all:
57
58
  #
58
- # ruby -Ipath/to/ruport/lib my_script.rb
59
+ # ruby -Ipath/to/ruport/lib my_script.rb
59
60
  #
60
- # Check to see if it installed properly:
61
+ # Check to see if it installed properly:
61
62
  #
62
- # ruby -rubygems -e "require 'ruport'; puts Ruport::VERSION"
63
- # (omit the -rubygems flag if installed manually)
63
+ # ruby -rubygems -e "require 'ruport'; puts Ruport::VERSION"
64
+ # (omit the -rubygems flag if installed manually)
64
65
  #
65
- # If you get an error, please consult the mailing list.
66
+ # If you get an error, please consult the mailing list.
66
67
  #
67
- # - Caveats
68
+ # = Getting Started
68
69
  #
69
- # Ruport is experimental software. It's not completely tested and the API is
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
- # The functionality is also not complete yet. There is a lot left to be added
75
- # and there is a lot to think about. If you find yourself wondering why
76
- # feature foo is in Ruport, chances are it just hasn't been written yet.
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
- # Documentation so far is something that is a struggle to keep up with. As of
79
- # this release, there is at least partial documentation for the API. This
80
- # will continue to get better as time goes on.
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
- # Platform independence is a priority, but I don't absolutely always have
83
- # access to every OS / DBMS combination, so if something breaks on your
84
- # system, please feel free to yell loud at the mailing list.
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
- # That having been said, I do use ruport in my daily work. That means that it
87
- # will probably have at least something you will find useful. Or so I hope.
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
- # - Resources
120
+ # = Resources
90
121
  #
91
- # The best way to get help and make suggestions is the Ruport mailing list.
92
- # This software is on the move, so the list is the most reliable way of getting
93
- # up to date information.
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
- # - You can sign up and/or view the archives here:
96
- # http://lists.stonecode.org/listinfo.cgi/ruport-stonecode.org
126
+ # - You can sign up and/or view the archives here:
127
+ # http://lists.stonecode.org/listinfo.cgi/ruport-stonecode.org
97
128
  #
98
- # Please do not hesitate to use this list! I am happily accepting patches and
99
- # documentation, as well as encouraging design discussions and also am quite
100
- # curious about what people use or want to use ruport for.
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
- # I will announce Ruport releases on RubyTalk, on the Ruport mailing list, on
103
- # Freshmeat, RAA, and the new_haven.rb mailing list. If you would like to
104
- # keep an eye out for releases, please monitor one of those places.
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
- # - You may download Ruport's source from the project page:
107
- # http://rubyforge.org/projects/ruport
137
+ # - You may download Ruport's source from the project page:
138
+ # http://rubyforge.org/projects/ruport
108
139
  #
109
- # - The latest stable API documentation is available at:
110
- # http://reporting.stonecode.org/docs
140
+ # - The latest stable API documentation is available at:
141
+ # http://reporting.stonecode.org/docs
111
142
  #
112
- # There also will be some tutorials on ruport.infogami.com
143
+ # There also will be some tutorials on ruport.infogami.com
113
144
  #
114
- # If you are interested in developing Ruport, please *never* study code in
115
- # official releases. As this software is in it's early stages, it's essential
116
- # to keep an eye on the subversion repository. If you let me know you are
117
- # interested in working on something, I will let you know if I'm actively
118
- # working on that section.
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
- # - Grabbing the code from the svn trunk is simple:
151
+ # - Grabbing the code from the svn trunk is simple:
121
152
  #
122
- # svn co svn://rubyforge.org//var/svn/ruport/trunk/
153
+ # svn co svn://rubyforge.org//var/svn/ruport/trunk/
123
154
  #
124
- # Those who would like to become regular contributors will be given write
125
- # access. Also, anyone interested in the internal design and project
126
- # management aspects of Ruport can request to be added to our Trac
127
- # account. This is primarily intended for people who are working on the
128
- # project actively, though.
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
- # - Background / Summary
161
+ # = Background / Summary
131
162
  #
132
- # Ruport aims to help you fetch data from various sources, perform
133
- # manipulations on them as needed, and then output them in a variety
134
- # of formats easily. The powerful ERb templating engine is integrated
135
- # to let you embed Ruport code into your formatted data. Also, Ruport
136
- # provides a high level interface to databases, to make getting
137
- # your data easy.
138
- #
139
- # The standard datastructure for Ruport is the DataSet. It is an enumerable
140
- # ordered list which consists of DataRow objects that can be accessed
141
- # by field names or ordinal position. DataRows can be arbitrarily tagged,
142
- # allowing for easy retrieval of the same rows for many different purposes.
143
- #
144
- # The rest of the code is organized into three main models, Report, Query,
145
- # and Format. Each is meant to be a high level interface to Ruport.
146
- # The inner classes can be used where a decent level of customization
147
- # is needed.
148
- #
149
- # Report is in some sense the 'controller' of your application, and provides
150
- # methods to help you write a Reporting application
151
- #
152
- # Format provides support for building filters and specialized formatting
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
- # Query currently provides a high level interface to DBI.
156
- # If you would like to query a database or load a sql dump,
157
- # this class can help you do that. It can generate DataSets on the fly,
158
- # or feed you DBI:Rows, depending on what you need.
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
- # Finally, Please consult the API documentation and/or source code for more
161
- # information. (http://reporting.stonecode.org/docs). Not all classes have been
162
- # documented but the ones that have may be easier to understand when their docs
163
- # have been read. Also, feel free to contribute documentation.
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
- # If you have any questions or concerns, hop on the mailing list and fire away!
195
+ # If you have any questions or concerns, hop on the mailing list and fire away!
166
196
  #
167
- # Thanks for downloading my software and I hope you enjoy it!
168
- # -Greg
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/ts_all.rb" ]
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.23"
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.test_file = "test/ts_all.rb"
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/ts_all.rb" ]
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
- This file needs updating badly.
4
-
5
- In the interim, check the Roadmap at
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 = <<-EOS
11
- require "rubygems" rescue LoadError nil
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 << "test"
18
- test.pattern = 'test/**/tc_*.rb'
19
- test.verbose = true
19
+ test.libs << "test"
20
+ test.pattern = 'test/**/test_*.rb'
21
+ test.verbose = true
20
22
  end
23
+ END_RAKEFILE
21
24
 
22
- EOS
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
- EOS
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 = <<-EOR
55
- require "rubygems" rescue LoadError nil
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 = <<-EOR
76
- require "rubygems" rescue LoadError nil
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/tc_* file"
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/tc_#{ARGV[1]}.rb","w") { |f| f << 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 nil
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
-