ruport 0.2.9 → 0.3.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. data/ACKNOWLEDGEMENTS +33 -0
  2. data/AUTHORS +13 -1
  3. data/CHANGELOG +76 -1
  4. data/README +208 -89
  5. data/Rakefile +12 -8
  6. data/TODO +14 -122
  7. data/lib/ruport.rb +58 -0
  8. data/lib/ruport/config.rb +114 -0
  9. data/lib/ruport/data_row.rb +144 -0
  10. data/lib/ruport/data_set.rb +221 -0
  11. data/lib/ruport/format.rb +116 -0
  12. data/lib/ruport/format/builder.rb +29 -5
  13. data/lib/ruport/format/document.rb +77 -0
  14. data/lib/ruport/format/open_node.rb +36 -0
  15. data/lib/ruport/parser.rb +202 -0
  16. data/lib/ruport/query.rb +208 -0
  17. data/lib/ruport/query/sql_split.rb +33 -0
  18. data/lib/ruport/report.rb +116 -0
  19. data/lib/ruport/report/mailer.rb +17 -15
  20. data/test/{addressbook.csv → samples/addressbook.csv} +0 -0
  21. data/test/samples/car_ads.txt +505 -0
  22. data/test/{data.csv → samples/data.csv} +0 -0
  23. data/test/samples/document.xml +22 -0
  24. data/test/samples/five_lines.txt +5 -0
  25. data/test/samples/five_paragraphs.txt +9 -0
  26. data/test/samples/ross_report.txt +58530 -0
  27. data/test/samples/ruport_test.sql +8 -0
  28. data/test/samples/stonecodeblog.sql +279 -0
  29. data/test/{test.sql → samples/test.sql} +2 -1
  30. data/test/{test.yaml → samples/test.yaml} +0 -0
  31. data/test/tc_builder.rb +7 -4
  32. data/test/tc_config.rb +41 -0
  33. data/test/tc_data_row.rb +16 -26
  34. data/test/tc_data_set.rb +60 -41
  35. data/test/tc_database.rb +25 -0
  36. data/test/tc_document.rb +42 -0
  37. data/test/tc_element.rb +18 -0
  38. data/test/tc_page.rb +42 -0
  39. data/test/tc_query.rb +55 -0
  40. data/test/tc_reading.rb +60 -0
  41. data/test/tc_report.rb +31 -0
  42. data/test/tc_section.rb +45 -0
  43. data/test/tc_sql_split.rb +18 -0
  44. data/test/tc_state.rb +142 -0
  45. data/test/ts_all.rb +6 -3
  46. data/test/ts_format.rb +5 -0
  47. data/test/ts_parser.rb +10 -0
  48. metadata +102 -60
  49. data/bin/ruport +0 -104
  50. data/lib/ruport/format/chart.rb +0 -1
  51. data/lib/ruport/report/data_row.rb +0 -79
  52. data/lib/ruport/report/data_set.rb +0 -153
  53. data/lib/ruport/report/engine.rb +0 -201
  54. data/lib/ruport/report/fake_db.rb +0 -54
  55. data/lib/ruport/report/fake_engine.rb +0 -26
  56. data/lib/ruport/report/fake_mailer.rb +0 -23
  57. data/lib/ruport/report/sql.rb +0 -95
  58. data/lib/ruportlib.rb +0 -11
  59. data/test/tc_engine.rb +0 -102
  60. data/test/tc_mailer.rb +0 -21
data/ACKNOWLEDGEMENTS ADDED
@@ -0,0 +1,33 @@
1
+ Sometimes you just gotta pay some mad propz to the peoples.
2
+
3
+ - Daniel Berger for releasing gruf to the community
4
+
5
+ - James Edward Gray II for letting me take query.rb and mash it into something
6
+ that eventually became Ruport 0.1.0
7
+
8
+ - Austin Ziegler for suggesting the Ruby License, which hopefully keeps everyone
9
+ happy.
10
+
11
+ - All the people at RubyConf 2005, new_haven.rb, and NYC.rb that made
12
+ suggestions and let me know what kind of problems they were dealing with.
13
+
14
+ - The people on the Ruport mailing list who will happily run unit tests and
15
+ check out little things for me when I need it.
16
+
17
+ - Francis Hwang for overall design suggestions and the contribution of SqlSplit.
18
+ Additionally, his efforts on DBI to bring it back to life. (Along with the
19
+ rest of the new DBI team)
20
+
21
+ - Mathijs Mohlmann for pointing out that the DataRow constructor sucks and
22
+ offering some patches for changes to Ruport.
23
+
24
+ - JEG2 again for letting me ape Parse::Input from him ;)
25
+
26
+ - Gregory Gibson for pretending like I'm a worthwhile business investment, and
27
+ providing funding to let me work on Ruport, instead of like... working in a
28
+ coffee shop or something.
29
+
30
+ - 'A Monkey' for catching a bug before I even commited it to SVN.
31
+
32
+ - RubyTalk, #ruby-lang and the Ruby community in general.
33
+ Each and every one of you is my homie.
data/AUTHORS CHANGED
@@ -1,7 +1,19 @@
1
+ Developers:
2
+ ---------------------------------------------------
1
3
  {Gregory Brown}[mailto:gregory.t.brown@gmail.com]:
2
4
 
3
5
  Original Author and Ruport::Report hacker.
4
6
 
5
7
  {Robert Canieso}[mailto:rcanieso@gmail.com]:
6
8
 
7
- Guy in charge of the Ruport::Format module
9
+ Currently lurking. Soon to be tester / developer
10
+
11
+ Contributors / People we've stole from:
12
+ ---------------------------------------------------
13
+
14
+ James Edward Gray II:
15
+ Original inspiration via query.rb
16
+ Parse::Input which is the base for Ruport::Parser
17
+
18
+ Francis Hwang:
19
+ SQLSplit
data/CHANGELOG CHANGED
@@ -1,4 +1,79 @@
1
- The current version of Ruby Reports is 0.2.9
1
+ The current version of Ruby Reports is 0.3.8
2
+ key features of Ruport 0.3.8:
3
+
4
+ - New configuration system
5
+
6
+ - New query model
7
+
8
+ - New formatting system
9
+
10
+ - Total API redesign
11
+
12
+ - Lots more API documentation
13
+
14
+ - A parser adapted from Parse::Input
15
+
16
+ - ruport executable was deprecated
17
+
18
+ [ Code was redesigned completely after 0.2.9 ]
19
+
20
+ changes since Ruport 0.2.9:
21
+
22
+ - Report::SQL dropped.
23
+
24
+ - Fixed a bug in query that made ODBC driver not work at ALL!
25
+ (AFAIK, this bug was ONLY in Ruport 0.2.9)
26
+
27
+ - removed render() from the engine and implemented DataSet#render_as()
28
+ example:
29
+ @report = render(data) do |builder| builder.format = :some_format end
30
+ is now: @report = data.render_as(:some_format)
31
+ which takes an optional block that works as before.
32
+
33
+ - removed method DataSet#select_field() because it was the same as
34
+ DataSet#select_fields() and of limited utility.
35
+
36
+ - added method DataSet#remove_fields and DataSet#remove_fields!
37
+ to make data manipulation easier.
38
+
39
+ - added DataSet#empty?
40
+
41
+ - added DataSet#clone which will actually deep copy a DataSet.
42
+
43
+ - cleaned up incredibly annoying DataSet constructor so you can now pass
44
+ field names and data to new()
45
+
46
+ - Report::DataSet now documented
47
+
48
+ - added hacks.rb which will include a random collection of potentially
49
+ useful functions. (Already cool for making Ruport easy to use with irb).
50
+
51
+ - added Document class and unit tests. Needs to be completed.
52
+
53
+ - added Report::DataSet.clone for making deep copies of DataSets.
54
+
55
+ - added Element, Section, Page, and Document formatting classes.
56
+
57
+ - restructured unit tests, adding ts_format and ts_report
58
+ and moving all non-testcase data into test/samples
59
+
60
+ - restuctured library, adding ruport/format.rb and ruport/report.rb
61
+ made format and report into classes, with nested classes within.
62
+
63
+ - Moved the Report::Engine class into Report
64
+
65
+ - reorginized DataSet#<< to be more efficient. Thanks Francis!
66
+
67
+ - added OpenNode. Which is a little scary.
68
+
69
+ - Francis Hwang has added SqlSplit, which has been tied into query.
70
+ Now multiple statement SQL dumps can be processed by ruport.
71
+
72
+ - DataSet can now safely execute commands that return no rows.
73
+ (This was a bug in RubyDBI which ruport now has a workaround for)
74
+
75
+ - require "ruportlib" becomes require "ruport"
76
+
2
77
 
3
78
  changes since Ruport 0.2.5:
4
79
 
data/README CHANGED
@@ -1,90 +1,209 @@
1
- Thank you for taking the time to download Ruby Reports. (Ruport)
2
-
3
- This software is a powerful report generation engine that allows users to
4
- generate custom ERb and pure ruby templates that can easily query various forms
5
- of databases via DBI. It also provides helper methods and utilities to generate professional reports quickly and cleanly.
6
-
7
- It happens to be alpha software, so if it offends your mother, burns out the innards of your computer, or threatens you in any other way, you may want to wait until further releases to play around with it.
8
-
9
- Please take the time to run through the examples available on RubyForge!
10
- This is the best way of learning the system:
11
-
12
- http://rubyforge.org/frs/?group_id=856&release_id=3656
13
-
14
- Otherwise, here is a brief set of installation and setup instructions which will
15
- hopefully get you going:
16
-
17
- Ruport itself is very easy to install. However, you will need to install some
18
- dependencies which the system relies on. The most important of these
19
- (and unfortunately the most complex to install) is the Ruby/DBI library.
20
- Because this library has many possible installation instructions depending on
21
- your database and operating system setup, I will not go into the instructions
22
- in detail here. However, it essentially boils down to finding your database
23
- software in the list of drivers on http://ruby-dbi.sourceforge.net/ and
24
- downloading and installing the driver. Once this is complete, you download and install DBI using the instructions at the aformentioned link. We have
25
- successfully installed RubyDBI with a MySQL driver on Gentoo Linux, Windows
26
- 2000/XP and Mac OS X.3, X.4.
27
-
28
- There is a tutorial available for installing Ruport and MySQL on Windows
29
- at: http://stonecode.org:2501/stonecodeproductions/published/Ruport%2C+MySQL+and+Windows
30
-
31
- If you're having problems getting mysqld_safe running on Mac OS X,
32
- you might check out this:
33
-
34
- http://stonecode.org:2501/stonecodeproductions/published/Why+OS+X+MySQL+won%27t+start+the+server
35
-
36
- We have also successfully installed RubyDBI on Windows 2000 using ODBC.
37
- If you are running a similar setup, feel free to email gregory.t.brown@gmail.comwith any questions. If you successfully install Ruby/DBI on another system /
38
- database combination, we'd love to hear how you did it so that we can improve
39
- this documentation for the next version of Ruport. Once you've got DBI
40
- installed, the Ruport installation is a piece of cake.
41
-
42
- Ruport is a gem. It relies on FasterCSV but this can easily be installed using the --include-dependencies flag. Make sure you have adequete permissions and run:
43
-
44
- sudo gem install ruport
45
-
46
- on Linux, OS X, and other Unix like systems.
47
-
48
- On Windows, ensure that you have adequete permission to install
49
- software and run:
50
-
51
- gem install ruport
52
-
53
- With any luck, Ruport is now installed and you are ready to move on to
54
- setting up and configuring a sandbox.
55
-
56
- To check to see if the ruport executable has been added to you path and is
57
- working in at least minimal capacity, type:
58
-
59
- ruport -v
60
-
61
- at the command prompt.
62
-
63
- If you see something like this:
64
-
65
- Ruport Version x.y.z ...
66
-
67
- then Ruport is at least installed and running.
68
-
69
- If you get an error instead, feel free to email me,
70
- but please include the error message.
71
-
72
- To generate a new project, type:
1
+ # ------------------------------------------------------------------------
2
+ # The <em>true story</em> behind Ruby Reports...
3
+ #
4
+ # ------ __________________ -------
5
+ # / \ o ( I miss pacman... ) / \
6
+ # o | O O | o o o ------------------ o o | O O |
7
+ # o | | ___________________________ o | |
8
+ # o \/\/\/\/\/ ( At least we're l33t now.. )o \/\/\/\/
9
+ # o ---------------------------
10
+ # o _________________________________________________
11
+ # o (vintage video game bad guys... ah... true l33tn355)
12
+ # --------------------------------------------------
13
+ #
14
+ # Not impressed? Fine, here's ya damn DOCS!
15
+ # -------------------------------------------------------------------------
16
+ #
17
+ # Contents:
18
+ #
19
+ # - What Ruport Is.
20
+ # - Installation
21
+ # - Caveats.
22
+ # - Resources
23
+ # - Background and Summary
24
+ #
25
+ # - What Ruport Is.
26
+ #
27
+ # Ruby Reports is a software library that aims to make the task of reporting
28
+ # less tedious and painful. It provides tools for data acquisition, database
29
+ # interaction, formatting, and parsing/munging. Designed to be extensible,
30
+ # it is possible to use Ruport for quick specific tasks as well as to build
31
+ # robust reporting applications.
32
+ #
33
+ # - Installation
34
+ #
35
+ # Optional Dependencies:
36
+ #
37
+ # Ruport has a number of optional dependencies:
38
+ #
39
+ # Ruby/DBI and appropriate dbds: Makes Query useable
40
+ # (must be installed manually)
41
+ #
42
+ # FasterCSV: Silently enables fast CSV parsing
43
+ # (available via rubygems)
44
+ #
45
+ # RedCloth: Enables textile/markdown filtering
46
+ # (available via rubygems)
47
+ #
48
+ # PDF::Writer: Enables printable documents via render_pdf (Experimental)
49
+ # (available via rubygems)
50
+ #
51
+ # The recommended method of installing ruport is RubyGems. It has been
52
+ # split into two packages, one that installs all of the dependencies
53
+ # by default, and one which does not install them.
54
+ #
55
+ # None of the dependencies are mandatory, so you can still use Ruport
56
+ # without them, as long as you don't need their functionality.
57
+ #
58
+ # To install ruport via rubygems with all it's dependencies (except DBI):
59
+ #
60
+ # sudo gem install ruport
61
+ #
62
+ # To install ruport via rubygems with no dependencies:
63
+ #
64
+ # sudo gem install ruport-lean
65
+ #
66
+ # Note that by installing any of the dependencies, either via gems or manually,
67
+ # their functionality will automatically be enabled in ruport-lean.
68
+ #
69
+ # To install ruport manually:
70
+ #
71
+ # sudo ruby setup.rb
72
+ #
73
+ # To not install ruport at all:
74
+ #
75
+ # ruby -Ipath/to/ruport/lib my_script.rb
76
+ #
77
+ # Check to see if it installed properly:
78
+ #
79
+ # ruby -rubygems -e "require 'ruport'; puts Ruport::VERSION"
80
+ # (omit the -rubygems flag if installed manually)
81
+ #
82
+ # If you get an error, please consult the mailing list.
83
+ #
84
+ # - Caveats
85
+ #
86
+ # Ruport is alpha software. It's not completely tested and the API is
87
+ # changing rapidly from version to version. Test suites are becoming
88
+ # increasingly robust, but have not identified all possible edge cases. If
89
+ # Ruport goes wild on you, it's because it hasn't been tamed yet.
90
+ #
91
+ # The functionality is also not complete yet. There is a lot left to be added
92
+ # and there is a lot to think about. If you find yourself wondering why
93
+ # feature foo is in Ruport, chances are it just hasn't been written yet.
94
+ #
95
+ # Documentation so far is something that is a struggle to keep up with. As of
96
+ # this release, there is at least partial documentation for the API. This
97
+ # will continue to get better as time goes on.
98
+ #
99
+ # Platform independence is a priority, but I don't absolutely always have
100
+ # access to every OS / DBMS combination, so if something breaks on your
101
+ # system, please feel free to yell loud at the mailing list.
102
+ #
103
+ # That having been said, I do use ruport in my daily work. That means that it
104
+ # will probably have at least something you will find useful. Or so I hope.
105
+ #
106
+ # - Resources
107
+ #
108
+ # The best way to get help and make suggestions is the Ruport mailing list.
109
+ # This software is on the move, so the list is the most reliable way of getting
110
+ # up to date information.
111
+ #
112
+ # - You can sign up and/or view the archives here:
113
+ # http://lists.stonecode.org/listinfo.cgi/ruport-stonecode.org
114
+ #
115
+ # Please do not hesitate to use this list! I am happily accepting patches and
116
+ # documentation, as well as encouraging design discussions and also am quite
117
+ # curious about what people use or want to use ruport for.
118
+ #
119
+ # Ruby Reports (Ruport) is a report generation and formatting toolset.
120
+ #
121
+ # I will announce Ruport releases on RubyTalk, on the Ruport mailing list, on
122
+ # Freshmeat, RAA, and the new_haven.rb mailing list. If you would like to
123
+ # keep an eye out for releases, please monitor one of those places.
124
+ #
125
+ # - You may download Ruport's source from the project page:
126
+ # http://rubyforge.org/projects/ruport
127
+ #
128
+ # - The latest stable API documentation is available at:
129
+ # http://ruport.rubyforge.org/docs
130
+ #
131
+ # - If you'd like to get some news on Ruport, you can check out my blog.
132
+ # (http://stonecode.org/blog)
133
+ #
134
+ # There also will be some tutorials on stonecode.org
135
+ #
136
+ # From time to time I will release example packages on RubyForge. Keep an eye
137
+ # out for these on ruport's project page and please note that unless otherwise
138
+ # noted, these examples are meant ONLY for the versions which they correspond
139
+ # to. (i.e. ruport-example-0.2.9 will NOT work with Ruport 0.3.8)
140
+ #
141
+ # If you are interested in developing Ruport, please *never* study code in
142
+ # official releases. As this software is in it's early stages, it's essential
143
+ # to keep an eye on the subversion repository. If you let me know you are
144
+ # interested in working on something, I will let you know if I'm actively
145
+ # working on that section.
146
+ #
147
+ # - Grabbing the code from the svn trunk is simple:
148
+ #
149
+ # svn checkout svn://rubyforge.org//var/svn/ruport
150
+ #
151
+ # Those who would like to become regular contributors will be given write
152
+ # access. Also, anyone interested in the internal design and project
153
+ # management aspects of Ruport can request to be added to our basecamp
154
+ # account. This is primarily intended for people who are working on the
155
+ # project actively, though.
156
+ #
157
+ # - Background / Summary
158
+ #
159
+ # Ruport aims to help you fetch data from various sources, perform
160
+ # manipulations on them as needed, and then output them in a variety
161
+ # of formats easily. The powerful ERb templating engine is integrated
162
+ # to let you embed Ruport code into your formatted data. Also, Ruport
163
+ # provides a high level interface to databases, to make getting
164
+ # your data easy.
165
+ #
166
+ # The standard datastructure for Ruport is the DataSet. It is an enumerable
167
+ # ordered list which consists of DataRow objects that can be accessed
168
+ # by field names or ordinal position. DataRows can be arbitrarily tagged,
169
+ # allowing for easy retrieval of the same rows for many different purposes.
170
+ #
171
+ # The rest of the code is organized into three main models, Report, Query,
172
+ # and Format. Each is meant to be a high level interface to Ruport.
173
+ # The inner classes can be used where a decent level of customization
174
+ # is needed.
175
+ #
176
+ # Report is in some sense the 'controller' of your application, and provides
177
+ # methods to help you write a Reporting application
178
+ #
179
+ # Format provides support for building filters and specialized formatting
180
+ # systems. Format::Builder can be used to add additional formats which can be
181
+ # used by DataSet#as, and the Format class can add filters to Report#render
182
+ #
183
+ # Query currently provides a high level interface to DBI. Soon it will support
184
+ # a mixin wrapper called Fetchable which will enable you to wrap whatever data
185
+ # source you choose. If you would like to query a database or load a sql dump,
186
+ # this class can help you do that. It can generate DataSets on the fly, or feed
187
+ # you DBI:Rows, depending on what you need.
188
+ #
189
+ # There is also a Config class which allows you to set things such as data
190
+ # sources, mailer information, and logging. Ruport#complain provides a robust
191
+ # way to handle error logging and warnings.
192
+ #
193
+ # Finally, Ruport provides a powerful yet oh-so-scary parsing tool. It is
194
+ # essentially James Edward Gray II's Parse::Input library within the Ruport
195
+ # library. (And will soon be integrated nicely too)
196
+ #
197
+ # Read the source of ruport/parser.rb if you have some gnarly data you need to
198
+ # munge.
199
+ #
200
+ # Finally, Please consult the API documentation and/or source code for more
201
+ # information. (http://ruport.rubyforge.org/docs). Not all classes have been
202
+ # documented but the ones that have may be easier to understand when their docs
203
+ # have been read. Also, feel free to contribute documentation.
204
+ #
205
+ # If you have any questions or concerns, hop on the mailing list and fire away!
206
+ #
207
+ # Thanks for downloading my software and I hope you enjoy it!
208
+ # -Greg
73
209
 
74
- ruport generate ProjectName
75
-
76
- This will dump a directory structure for you to start with.
77
-
78
- You'll need to edit config/ruport.yaml to get things up and running, and at this
79
- point, unless you're magic, you'll probably need to either read the
80
- {API Documentation}[http://ruport.rubyforge.org/docs/] or the source, whichever
81
- you're most comfortable with.
82
-
83
- There is also a set of examples at:
84
- http://rubyforge.org/frs/?group_id=856&release_id=3481
85
-
86
- I hope you enjoy this software and that it is useful to you.
87
-
88
- -Greg
89
-
90
- gregory.t.brown@gmail.com
data/Rakefile CHANGED
@@ -4,6 +4,8 @@ require "rake/gempackagetask"
4
4
 
5
5
  require "rubygems"
6
6
 
7
+ LEAN=false
8
+
7
9
  task :default => [:test]
8
10
 
9
11
  Rake::TestTask.new do |test|
@@ -13,8 +15,8 @@ Rake::TestTask.new do |test|
13
15
  end
14
16
 
15
17
  spec = Gem::Specification.new do |spec|
16
- spec.name = "ruport"
17
- spec.version = "0.2.9"
18
+ spec.name = LEAN ? "ruport-lean" : "ruport"
19
+ spec.version = "0.3.8"
18
20
  spec.platform = Gem::Platform::RUBY
19
21
  spec.summary = "A generalized Ruby report generation and templating engine."
20
22
 
@@ -22,17 +24,19 @@ spec = Gem::Specification.new do |spec|
22
24
  'lib/**/*.rb', 'bin/*', '[A-Z]*','test/**/*'].to_a.delete_if { |item|
23
25
  item.include?("CVS") } + ["Rakefile"]
24
26
  spec.require_path = "lib"
25
- spec.bindir = "bin"
26
- spec.executables << "ruport"
27
27
 
28
28
  spec.test_file = "test/ts_all.rb"
29
29
 
30
30
  spec.has_rdoc = true
31
31
  spec.extra_rdoc_files = %w{README LICENSE TODO AUTHORS CHANGELOG}
32
32
  spec.rdoc_options << '--title' << 'Ruport Documentation' <<
33
- '--main' << 'README'
34
- spec.add_dependency('fastercsv', '>= 0.1.0')
35
- spec.author = "Gregory Brown"
33
+ '--main' << 'README' << '-q'
34
+ unless LEAN
35
+ spec.add_dependency('fastercsv', '>= 0.1.0')
36
+ spec.add_dependency('RedCloth', '>= 3.0.0')
37
+ spec.add_dependency('pdf-writer', '>= 1.1.3')
38
+ end
39
+ spec.author = "Gregory Brown"
36
40
  spec.email = " gregory.t.brown@gmail.com"
37
41
  spec.rubyforge_project = "ruport"
38
42
  spec.homepage = "http://ruport.rubyforge.org"
@@ -40,7 +44,7 @@ spec = Gem::Specification.new do |spec|
40
44
  Ruport is a powerful report generation engine that allows users to generate
41
45
  custom ERb templates and easily query various forms of SQL databases via DBI.
42
46
  It provides helper methods and utilities to generate professional reports
43
- quickly and cleanly.
47
+ quickly and cleanly.
44
48
  END_DESC
45
49
  end
46
50