ruport 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/AUTHORS ADDED
@@ -0,0 +1 @@
1
+ {Gregory Brown}[mailto:gregory.t.brown@gmail.com]
@@ -0,0 +1,45 @@
1
+ changes since Ruport 0.1.0:
2
+
3
+ CLEANUP / ORGANIZATION:
4
+
5
+ - Parseinput dependency removed for now
6
+
7
+ - setup.rb support removed
8
+
9
+ - gem install will now only install a single executable
10
+
11
+ - dropped undocumented YAML override feature
12
+
13
+ - Query class now called Report
14
+
15
+ - Project split into two parts lib/ruport/db and lib/ruport/format
16
+
17
+ - dropped questionable ruport_query manager function
18
+
19
+ - finally turned on expandtab and tabstop=2 for Ruby style ;)
20
+
21
+ FEATURES:
22
+
23
+ - require 'ruportlib' lets ruport be used as a library
24
+
25
+ - MockDB and MockReport added to simplify testing
26
+
27
+ - DataRow and DataSet added to provide munging with ease
28
+ (to_csv, DataSet.load("some.csv"), etc
29
+
30
+ - DataSet.load() can restore DataSet's that were YAML.dump()'ed
31
+
32
+ - load_file now supports absolute and relative paths
33
+
34
+ - added many automation features to templates
35
+
36
+ - added @pre and @post to Report which accept lambdas to execute
37
+ before and after generate_report()
38
+
39
+ - logger added.
40
+
41
+ - some friendly error messages added
42
+
43
+ - new method query() will eventually replace select() / execute()
44
+
45
+ - {examples}[http://ruport.rubyforge.org/examples.zip] available for download
data/README CHANGED
@@ -1,12 +1,14 @@
1
1
  Thank you for taking the time to download Ruby Reports. (Ruport)
2
2
 
3
- This software is a powerful report generation engine that allows users to generate custom ERb templates and easily query various forms of SQL databases via DBI.It provides helper methods and utilities to generate professional reports quickly and cleanly.
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.
4
6
 
5
- It is also alpha software, so if it offends your mother, burns out the innards
6
- of your computer, or threatens you in any other way, you may want to wait until
7
- further releases to play around with it.
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
8
 
9
- There is a user's manual for this application available at http://ruport.rubyforge.org/ruport_manual.pdf which I strongly recommend reading.
9
+ There is a set of examples and a brief walkthrough for this application
10
+ available at http://ruport.rubyforge.org/examples.zip which I strongly
11
+ recommend going through
10
12
 
11
13
  Otherwise, here is a brief set of installation and setup instructions which will
12
14
  hopefully get you going:
@@ -19,8 +21,18 @@ your database and operating system setup, I will not go into the instructions
19
21
  in detail here. However, it essentially boils down to finding your database
20
22
  software in the list of drivers on http://ruby-dbi.sourceforge.net/ and
21
23
  downloading and installing the driver. Once this is complete, you download and install DBI using the instructions at the aformentioned link. We have
22
- successfully installed RubyDBI with a MySQL driver on Gentoo Linux and Mac OS X.
23
- We have also successfully installed RubyDBI on Windows using ODBC.
24
+ successfully installed RubyDBI with a MySQL driver on Gentoo Linux, Windows
25
+ 2000/XP and Mac OS X.3, X.4.
26
+
27
+ There is a tutorial available for installing Ruport and MySQL on Windows
28
+ at: http://stonecode.org:2501/stonecodeproductions/published/Ruport%2C+MySQL+and+Windows
29
+
30
+ If you're having problems getting mysqld_safe running on Mac OS X,
31
+ you might check out this:
32
+
33
+ http://stonecode.org:2501/stonecodeproductions/published/Why+OS+X+MySQL+won%27t+start+the+server
34
+
35
+ We have also successfully installed RubyDBI on Windows 2000 using ODBC.
24
36
  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 /
25
37
  database combination, we'd love to hear how you did it so that we can improve
26
38
  this documentation for the next version of Ruport. Once you've got DBI
@@ -30,36 +42,43 @@ Ruport is a gem. It relies on Parse/Input (which will be linked to Ruport
30
42
  in future releases) but this can easily be installed using the
31
43
  --include-dependencies flag. Make sure you have adequete permissions and run:
32
44
 
33
- sudo gem install ruport --include-dependencies
45
+ sudo gem install ruport
34
46
 
35
47
  on Linux, OS X, and other Unix like systems.
36
48
 
37
49
  On Windows, ensure that you have adequete permission to install
38
50
  software and run:
39
51
 
40
- gem install ruport --include-dependencies
52
+ gem install ruport
41
53
 
42
54
  With any luck, Ruport is now installed and you are ready to move on to
43
55
  setting up and configuring a sandbox.
44
56
 
45
57
  To check to see if the ruport executable has been added to you path and is
46
- working in at least minimal capacity, type ruport -v at the command prompt.
58
+ working in at least minimal capacity, type:
59
+
60
+ ruport -v
61
+
62
+ at the command prompt.
47
63
 
48
64
  If you see something like this:
49
65
 
50
- Ruport Version 0.1.0 ...
66
+ Ruport Version x.y.z ...
51
67
 
52
68
  then Ruport is at least installed and running.
53
69
 
54
70
  If you get an error instead, feel free to email me,
55
71
  but please include the error message.
56
72
 
57
- To generate a sandbox, type ruport generate sandbox_name.
73
+ To generate a new project, type:
74
+
75
+ ruport generate ProjectName
76
+
58
77
  This will dump a directory structure for you to start with.
59
78
 
60
79
  You'll need to edit config/ruport.yaml to get things up and running, and at this
61
80
  point, unless you're magic, you'll probably need to either read the
62
- {manual}[http://ruport.rubyforge.org/ruport_manual.pdf] or the source, whichever
81
+ {API Documentation}[http://ruport.rubyforge.org/docs/] or the source, whichever
63
82
  you're most comfortable with.
64
83
 
65
84
  I hope you enjoy this software and that it is useful to you.
data/Rakefile CHANGED
@@ -1,51 +1,48 @@
1
- require "rake/rdoctask"
2
- require "rake/testtask"
3
- require "rake/gempackagetask"
4
-
5
- require "rubygems"
6
-
7
- task :default => [:test]
8
-
9
- Rake::TestTask.new do |test|
10
- test.libs << "test"
11
- test.test_files = [ "tests/tc_ruport.rb" ]
12
- test.verbose = true
13
- end
14
-
15
- spec = Gem::Specification.new do |spec|
16
- spec.name = "ruport"
17
- spec.version = "0.1.0"
18
- spec.platform = Gem::Platform::RUBY
19
- spec.summary = "A generalized Ruby report generation and templating engine."
20
-
21
- spec.files = Dir.glob("{bin,lib,tests}/**/*.rb").
22
- delete_if { |item| item.include?("CVS") } +
23
- ["Rakefile", "setup.rb"]
24
- spec.require_path = "lib"
25
- spec.bindir = "bin"
26
- spec.executables << "ruport" << "ruport.rb"
27
-
28
- spec.has_rdoc = true
29
- spec.extra_rdoc_files = %w{README LICENSE TODO}
30
- spec.rdoc_options << '--title' << 'Ruport Documentation' <<
31
- '--main' << 'README'
32
-
33
- spec.add_dependency("parseinput", ">= 0.0.1")
34
-
35
- spec.author = "Gregory Brown"
36
- spec.email = " gregory.t.brown@gmail.com"
37
- spec.rubyforge_project = "ruport"
38
- spec.homepage = "http://ruport.rubyforge.org"
39
- spec.description = <<END_DESC
40
- Ruport is a powerful report generation engine that allows users to generate
41
- custom ERb templates and easily query various forms of SQL databases via DBI.
42
- It provides helper methods and utilities to generate professional reports
43
- quickly and cleanly.
44
- END_DESC
45
- end
46
-
47
- Rake::GemPackageTask.new(spec) do |pkg|
48
- pkg.need_zip = true
49
- pkg.need_tar = true
50
- end
51
-
1
+ require "rake/rdoctask"
2
+ require "rake/testtask"
3
+ require "rake/gempackagetask"
4
+
5
+ require "rubygems"
6
+
7
+ task :default => [:test]
8
+
9
+ Rake::TestTask.new do |test|
10
+ test.libs << "test"
11
+ test.test_files = [ "test/ts_all.rb" ]
12
+ test.verbose = true
13
+ end
14
+
15
+ spec = Gem::Specification.new do |spec|
16
+ spec.name = "ruport"
17
+ spec.version = "0.2.0"
18
+ spec.platform = Gem::Platform::RUBY
19
+ spec.summary = "A generalized Ruby report generation and templating engine."
20
+
21
+ spec.files = Dir.glob("{bin,lib,test}/**/*.rb").
22
+ delete_if { |item| item.include?("CVS") } +
23
+ ["Rakefile"]
24
+ spec.require_path = "lib"
25
+ spec.bindir = "bin"
26
+ spec.executables << "ruport"
27
+
28
+ spec.has_rdoc = true
29
+ spec.extra_rdoc_files = %w{README LICENSE TODO AUTHORS CHANGELOG}
30
+ spec.rdoc_options << '--title' << 'Ruport Documentation' <<
31
+ '--main' << 'README'
32
+
33
+ spec.author = "Gregory Brown"
34
+ spec.email = " gregory.t.brown@gmail.com"
35
+ spec.rubyforge_project = "ruport"
36
+ spec.homepage = "http://ruport.rubyforge.org"
37
+ spec.description = <<END_DESC
38
+ Ruport is a powerful report generation engine that allows users to generate
39
+ custom ERb templates and easily query various forms of SQL databases via DBI.
40
+ It provides helper methods and utilities to generate professional reports
41
+ quickly and cleanly.
42
+ END_DESC
43
+ end
44
+
45
+ Rake::GemPackageTask.new(spec) do |pkg|
46
+ pkg.need_zip = true
47
+ pkg.need_tar = true
48
+ end
data/TODO CHANGED
@@ -1,19 +1,19 @@
1
1
  TODO:
2
2
 
3
- Take the following features and stabilize them for Ruport 0.2.0:
3
+ Improvement:
4
4
 
5
5
  - Mail system
6
-
7
- Hook up unit tests and solidify system
6
+ Hook up unit tests
7
+ Make attachments doable
8
8
 
9
9
  - Template Config / Line Editing
10
10
 
11
11
  Find a way to accept piped in values
12
- Hook up unit tests.
12
+ Make line editing work right
13
13
 
14
14
  - Queries Table System
15
15
 
16
- Write a cross-database table creation script
16
+ Automate the generation of the table. (Optionally)
17
17
  Hook up unit tests.
18
18
 
19
19
  - SQL builder
@@ -24,6 +24,16 @@ Take the following features and stabilize them for Ruport 0.2.0:
24
24
 
25
25
  Begin implementing new features:
26
26
 
27
+ DSNs:
28
+
29
+ It would be nice to be able to configure any number of databases
30
+ and then select them by name. (JEG2)
31
+
32
+ Charts:
33
+
34
+ Build something that'll take a data set and build a chart. (SVG?),
35
+ then dump it into PDF::Writer.
36
+
27
37
  Multiple query reports:
28
38
 
29
39
  Allow the user to make arbitrary SQL queries,
@@ -39,14 +49,6 @@ Begin implementing new features:
39
49
  regardless of database choice and import the data stored in a file into
40
50
  a specified table.
41
51
 
42
- YAML dump / restore:
43
-
44
- Make a nice way to dump the results of a query to a yaml file,
45
- potentially to be read back in and reconstructed by another ruport
46
- template. This would require splitting the formatting and data feeder
47
- functionality, but would allow a user to simply load in a YAML file and
48
- apply arbitrary formatting.
49
-
50
52
  Parse/Input tight integration:
51
53
 
52
54
  Write wrapper functions over the Parse/Input library to give Ruport the
@@ -60,11 +62,14 @@ Begin implementing new features:
60
62
  and over again. This would be especially useful for just dumping a
61
63
  table's values in a certain order with some fields removed.
62
64
 
65
+ [UPDATE: to_csv is in place but can use some additional frosting]
66
+
63
67
  Logger / Exception handler:
64
68
 
65
69
  Create a system to handle and log errors as well as provide log messages
66
70
  regarding what Ruport does when a template is run.
67
-
71
+
72
+ [UPDATE: Logger is in place but is not covering many functions]
68
73
 
69
74
  Design considerations:
70
75
 
@@ -72,18 +77,19 @@ Design considerations:
72
77
  tools and data feeders. This will likely happen in an early release, if not
73
78
  the next than the one after.
74
79
 
80
+ [ UPDATE: The folders have been seperated but need reworking. db/mailer ??
81
+ Ruport needs to be made into a module ]
82
+
75
83
  Ruport trys to use a lot of 'intelligent' defaults but it might try to be
76
84
  too clever in some places making it not clever at all. The community
77
85
  reaction will determine what places may need opening up more or need more
78
86
  consideration for the defaults.
79
-
80
- "Fix the lame hack that installs two executables" (James Edward Gray II)
81
-
87
+
88
+ [ UPDATE: See changelog for a list of dropped features. Complain about any
89
+ that you still think need to be dropped ]
82
90
 
83
91
  Other:
84
92
 
85
- A full set of examples should be made available for download.
86
-
87
93
  A quick reference page for templates and/or tutorial would be A Good Thing
88
94
 
89
95
  The RDOC sucks!
@@ -92,10 +98,18 @@ Other:
92
98
  of additional steps, they need to be expanded to cover the whole system, and
93
99
  they need to work in the Gem package as well as the source package.
94
100
 
101
+ [UPDATE: Mailer is the only class that needs to be unit tested still. The
102
+ units work out of the box via MockDB now. Functional tests with
103
+ scaffolding are needed, though ]
104
+
95
105
  Ruport needs to be modified to support as many databases as possibly
96
- internally. The system was written with Linux/MySQL and Windows/MS SQL
97
- (ODBC) in mind. This will change when feedback from the community is
98
- recieved.
106
+ internally. The system was written using MySQL on Gentoo Linux
107
+ and Mac OS X.3 / OS X.4, Windows 2000 / XP
108
+
109
+ and Microsoft SQL Server on Windows 2000 (via ODBC),
110
+
111
+ so the support for these platforms are best. An effort will be given to
112
+ make Ruport less hostile in other environments.
99
113
 
100
114
 
101
115
  This is only the tip of the iceburg. Please feel free to continue to fill my
@@ -103,4 +117,3 @@ plate by sending any suggestions to gregory.t.brown@gmail.com
103
117
 
104
118
 
105
119
 
106
-
data/bin/ruport CHANGED
@@ -13,74 +13,92 @@
13
13
  # for providing the original source code for this application
14
14
 
15
15
  require "rubygems"
16
- require "query"
17
- require "mailer"
18
16
  require "ftools"
17
+ require "yaml"
18
+ require "ruportlib"
19
19
 
20
- if ARGV[0].eql?("generate")
21
- if ARGV[1].nil?
22
- puts "You must specify a name for your ruport sandbox"
23
- exit
24
- end
25
- Dir.mkdir(ARGV[1])
26
- Dir.mkdir("#{ARGV[1]}/reports")
27
- Dir.mkdir("#{ARGV[1]}/templates")
28
- Dir.mkdir("#{ARGV[1]}/config")
29
- Dir.mkdir("#{ARGV[1]}/queries")
30
- conf = ":driver: 'DBI:mysql'\n"+
31
- ":database: test\n"+
32
- ":db_user:\n:db_password:\n:mail_host:\n:mail_account:\n"+
33
- ":mail_password:\n:mail_address:\n:mail_authentication:\n"+
34
- ":query_table: ruport_queries"
35
-
36
- File.open("#{ARGV[1]}/config/ruport.yaml", "w") { |f| f.puts(conf) }
37
- File.open("#{ARGV[1]}/templates/test.rb", "w") { |f|
38
- f.puts 'select "database()" do |r| puts r end'
39
- }
40
- exit
41
- elsif ARGV[0].eql?("-v")
42
- puts "Ruport Version 0.1.0 \nA ruby report generation system by Gregory " +
43
- "Brown.\nThis application is Free Software under the GPL/Ruby License. " +
44
- "\nAll praise and/or criticism can be directed to "+
45
- "gregory.t.brown@gmail.com"
46
- exit
47
- end
48
- config = YAML.load(File.open("config/ruport.yaml"))
49
- mailer = nil
20
+ # The whole codebase below is scary, dirty, and evil.
21
+ # The library itself is much cleaner. This is a total hack.
50
22
 
51
- if config.has_key?(:mail_host)
52
- mailer = Mailer.new( config[:mail_host],
53
- config[:mail_address],
54
- config[:mail_account],
55
- config[:mail_password],
56
- config[:mail_port],
57
- config[:mail_authentication] )
23
+ if ARGV[0].nil?
24
+ puts "Usage: ruport path/to/template or ruport generate project_name"
25
+ exit
58
26
  end
59
27
 
28
+ if ARGV[0].eql?("generate")
29
+ if ARGV[1].nil?
30
+ puts "You must specify a name for your ruport sandbox"
31
+ exit
32
+ end
33
+ Dir.mkdir(ARGV[1])
34
+ Dir.mkdir("#{ARGV[1]}/log")
35
+ Dir.mkdir("#{ARGV[1]}/reports")
36
+ Dir.mkdir("#{ARGV[1]}/templates")
37
+ Dir.mkdir("#{ARGV[1]}/config")
38
+ Dir.mkdir("#{ARGV[1]}/queries")
39
+ conf = (<<-END_CONF
40
+ # any DBI driver ('DBI:mysql', 'DBI:odbc', etc) or Ruport's mock ('ruport')
41
+ :driver:
42
+
43
+ #The database to connect to. For remote database: 'foo:hostname' or 'foo:ip'
44
+ :database:
60
45
 
61
- query = Query.new( "#{config[:driver]}:#{config[:database]}",
62
- config[:db_user], config[:db_password], mailer)
46
+ # username. for local auth, leave blank
47
+ :db_user:
63
48
 
64
- query.query_table = config[:query_table]
49
+ :db_password:
65
50
 
51
+ #mail info, if you want mail support, fill out. Otherwise leave blank
52
+ :mail_host:
53
+ :mail_account:
54
+ :mail_password:
55
+ :mail_address:
56
+ :mail_authentication:
57
+ :query_table:
66
58
 
67
- case(ARGV[0])
68
- when "ins_query", "insq"
69
- query_text = query.load_file(ARGV[2])
70
- query.execute("INSERT INTO #{query.query_table} " +
71
- "VALUES ('#{ARGV[1]}','#{query_text}' );")
72
- when "ls_queries", "lsq"
73
- query.select("label FROM #{query.query_table}") do |r| puts r end
74
- when "show_query", "sq"
75
- query.select( "query FROM #{query.query_table} " +
76
- "WHERE label LIKE '%#{ARGV[1]}%'" ) do |r| puts r end
77
- when "rm_query", "rmq"
78
- query.execute("DELETE FROM #{query.query_table} " +
79
- "WHERE label LIKE '#{ARGV[1]}'" )
80
- else
81
- query.eval_report(ARGF.filename, ARGF.read)
59
+ END_CONF
60
+ ).gsub(" ","")
61
+
62
+ File.open("#{ARGV[1]}/config/ruport.yaml", "w") { |f| f.puts(conf) }
63
+ File.open("#{ARGV[1]}/templates/test.rb", "w") { |f|
64
+ f.puts 'select "database()" do |r| puts r end'
65
+ }
66
+ exit
67
+ elsif ARGV[0].eql?("-v")
68
+ puts "Ruport Version 0.2.0 \nA ruby report generation system by Gregory " +
69
+ "Brown.\nThis application is Free Software under the GPL/Ruby License. " +
70
+ "\nAll praise and/or criticism can be directed to "+
71
+ "gregory.t.brown@gmail.com"
72
+ exit
73
+ end
74
+ unless (File.exist?("config/ruport.yaml"))
75
+ puts "You are trying to execute ruport from outside a ruport folder"
76
+ exit
82
77
  end
78
+ config = YAML.load(File.open("config/ruport.yaml"))
79
+ mailer = nil
83
80
 
81
+ if config.has_key?(:mail_host)
82
+ mailer = Mailer.new( config[:mail_host], config[:mail_address],
83
+ config[:mail_account], config[:mail_password],
84
+ 25, config[:mail_authentication] )
85
+ end
84
86
 
87
+ report = Report.new(
88
+ "#{config[:driver]}:#{config[:database]}",
89
+ config[:db_user], config[:db_password], mailer )
85
90
 
91
+ if config[:driver].eql?("ruport")
92
+ report = MockReport.new( "#{config[:driver]}:#{config[:database]}",
93
+ config[:db_user], config[:db_password], mailer )
94
+ end
86
95
 
96
+ report.query_table = config[:query_table]
97
+ report.file = ARGV[1] unless ARGV[1].nil?
98
+ unless ( File.exists? ARGV[0] )
99
+ report.logger.fatal("Could not open #{ARGV[0]}")
100
+ puts "Could not open #{ARGV[0]}"
101
+ exit
102
+ end
103
+ report.eval_report(ARGV[0], File.open(ARGV[0]) { |f| f.read })
104
+ report.generate_report if report.generate