Permalink
Browse files

Dynamic Reports 0.0.0

  • Loading branch information...
0 parents commit b68914b9950caf8251725355878046ede21e5fe1 @wayneeseguin committed Jun 27, 2009
Showing with 7,436 additions and 0 deletions.
  1. 0 .gitignore
  2. +2 −0 HISTORY
  3. +11 −0 NOTES
  4. +146 −0 README.rdoc
  5. +45 −0 Rakefile
  6. +8 −0 TODO
  7. +258 −0 doc/DynamicReports.html
  8. +618 −0 doc/DynamicReports/Chart.html
  9. +386 −0 doc/DynamicReports/Charts.html
  10. +1,175 −0 doc/DynamicReports/Report.html
  11. +783 −0 doc/DynamicReports/Templates.html
  12. +372 −0 doc/DynamicReports/View.html
  13. +92 −0 doc/HISTORY.html
  14. +232 −0 doc/README_rdoc.html
  15. +1 −0 doc/created.rid
  16. +178 −0 doc/index.html
  17. +54 −0 doc/lib/dynamic_reports/charts_rb.html
  18. +58 −0 doc/lib/dynamic_reports/reports_rb.html
  19. +54 −0 doc/lib/dynamic_reports/templates_rb.html
  20. +52 −0 doc/lib/dynamic_reports/views_rb.html
  21. +62 −0 doc/lib/dynamic_reports_rb.html
  22. +696 −0 doc/rdoc.css
  23. +132 −0 examples/rails.rb
  24. 0 examples/ruby.rb
  25. +24 −0 gemspec.rb
  26. +47 −0 lib/dynamic_reports.rb
  27. +217 −0 lib/dynamic_reports/charts.rb
  28. +252 −0 lib/dynamic_reports/reports.rb
  29. +178 −0 lib/dynamic_reports/templates.rb
  30. +11 −0 lib/dynamic_reports/vendor/google_chart.rb
  31. +90 −0 lib/dynamic_reports/vendor/google_chart/bar_chart.rb
  32. +539 −0 lib/dynamic_reports/vendor/google_chart/base.rb
  33. +31 −0 lib/dynamic_reports/vendor/google_chart/financial_line_chart.rb
  34. +79 −0 lib/dynamic_reports/vendor/google_chart/line_chart.rb
  35. +33 −0 lib/dynamic_reports/vendor/google_chart/pie_chart.rb
  36. +38 −0 lib/dynamic_reports/vendor/google_chart/scatter_chart.rb
  37. +36 −0 lib/dynamic_reports/vendor/google_chart/venn_diagram.rb
  38. +30 −0 lib/dynamic_reports/views.rb
  39. 0 lib/dynamic_reports/views/default_chart.html.erb
  40. +1 −0 lib/dynamic_reports/views/default_layout.html.erb
  41. +73 −0 lib/dynamic_reports/views/default_report.html.erb
  42. +62 −0 lib/dynamic_reports/views/default_report.html.haml
  43. +18 −0 test/dynamic_reports.rb
  44. +80 −0 test/dynamic_reports/charts_test.rb
  45. +87 −0 test/dynamic_reports/reports_test.rb
  46. +3 −0 test/dynamic_reports/templates_test.rb
  47. +1 −0 test/dynamic_reports/views/specific_template.html.erb
  48. +27 −0 test/dynamic_reports/views_test.rb
  49. 0 test/factories/records.rb
  50. +64 −0 test/test_helper.rb
No changes.
@@ -0,0 +1,2 @@
+0.0.0
+ - Initial dynamic reports codebase.
@@ -0,0 +1,11 @@
+# Feedback
+# it would be nice if it was just a template handler in Rails
+# ActionView::TemplateHandlers::ERB
+# since your stuff is all ERB you can just return the file contents I think
+# and then you also want to add a RenderOption, but I think RenderOptions are limited to completely taking over the process atm, instead of supplementing
+# so we have to do something about that
+
+
+
+# Should be able to hook reports into models directly somehow, cleanly
+#
@@ -0,0 +1,146 @@
+= Dynamic Reports
+
+ A dynamic reporting engine for Ruby / Rails
+
+== Reports
+
+ The dynamic reports gem was created to fill a HUGE hole that we felt existed in the
+ Ruby community - the ability to QUICKLY create stylized admin reports and charts for
+ people to use to view key metrics and data.
+
+ Sample uses include the ability to quickly display sales data if your an eShop, our
+ site metrics if you are recording your own site visits, or user feedback if you are storing
+ feedback in a model somewhere.
+
+ Basically, with DR you can create a stylized table of ANY information found in a model
+ (kind of like looking at the grid output from a GUI query analyzer) as well as add Google
+ Charts API powered line, pie, bar or column charts of any numeric data. All this can
+ be done by simply creating a report definition and feeding it your data.
+
+ While this library is usable in any Ruby application it was made mainly with Rails in mind.
+ Suppose we have an online store and we wish to add reporting to the admin area quickly and easily.
+ First we define a report in app/reports/orders_report.rb, something like:
+
+ class OrdersReport < DynamicReports::Report
+ columns :total, :created_at
+ end
+
+ Then in our admin/reports controller (this can be any controller) we define an action to deliver the report:
+
+ def orders
+ @orders = Order.find(:all, :limit => 25)
+ render :text => OrdersReport.on(@orders).to_html, :layout => "application"
+ end
+
+ This will render an html table containing some basic styling and containing the columns 'total' and 'created_at' from the order objects.
+ Note that the report Title will be "Orders Report" and it's name will be :orders_report
+ Report#on expects that it receives an object that responds to #each and
+ That each object that it iterates over is either a
+ * An object
+ * A Hash
+ that responds to a method / has keys for each column defined within the report.
+
+
+ Templating engines may also be specified, currently :erb and :haml are supported (we will soon be adding :csv and :pdf) like so:
+
+ render :text => OrdersReport.on(@orders).to_html(:engine => :haml), :layout => "application"
+
+ Note that erb is the default templating engine since it is available by default in Ruby.
+
+ One may also surpress the default rendered styles you may specify that as an option as well:
+
+ render :text => OrdersReport.on(@orders).to_html(:style => false), :layout => "application"
+
+ Now let us extend our report definition to specify a template to use!
+
+ class OrdersReport < DynamicReports::Report
+ columns :total, :created_at
+ template :orders_report
+ end
+
+ This will look in app/views/reports/ for a template named "orders_report.html.erb" by default.
+ If you specify :engine => :haml then it will look for "orders_report.html.haml"
+
+ If you happen to have your report templates in a different location you can specify this as follows:
+
+ class OrdersReport < DynamicReports::Report
+ columns :total, :created_at
+ template :orders_report
+ views "app/views/admin/reports/"
+ end
+
+ And DynamicReports will look for the specified template in app/views/reports as well as app/views/admin/reports.
+
+== Charts
+
+ Charts can be defined on a report easily. Let's say we wish to chart the total versus the item quantity sold for our Orders Report exmaple:
+
+ class OrdersReport < DynamicReports::Report
+ columns :total, :created_at
+
+ chart :total_vs_quantity do
+ columns :total, :quantity
+ end
+ end
+
+ This will render a *line* chart by default displaying the columns total and quantity.
+ Chart types may be specified easily:
+
+ type :bar
+
+ Available chart types are:
+
+ * :line (default)
+ * :bar
+ * :pie
+
+ Other chart types are planned.
+
+== Rails Usage
+
+ Inside the initializer block in config/environment.rb
+
+ config.gem "dynamic_reports"
+
+ Then define your reports (as exampled above) in app/reports/*_report.rb
+ If you would like to customize the default report simply create your report templates
+ within app/views/reports/*_report.<content-type>.<engine>.
+
+ Two Rails features that we are currently working on are:
+
+ * generator
+ * render extensions
+
+== Optional Dependencies
+
+ We are currently examining solutions for csv, pdf and charting.
+
+ * Fastercsv # csv
+ * Prawn # pdf
+ * flying saucer # html => PDF - if jRuby available
+ * amcharts # Charting, note that default is built in google charts.
+
+ These will be defined/implemented using DynamicReports plugin API (not implemented yet)
+ Which allows for user defined plugins of arbitrary types beyond html,csv,pdf,xml
+
+== Contact / Feedback
+
+ If you have any suggestions on improvement please send us an email.
+
+== Authors (alphabetically)
+
+ Joshua Lippiner (jlippiner@gmail.com)
+
+ Wayne E. Seguin (wayneeseguin@gmail.com, irc: wayneeseguin)
+
+== Thanks To
+
+ * Daniel Neighman
+ * Kenneth Kalmer (And his friend :))
+ * Yehuda Katz
+
+ For their encouragement, feedback and advise.
+
+== Source
+ http://github.com/wayneeseguin/dynamic_reports
+
@@ -0,0 +1,45 @@
+require "rake/testtask"
+
+task :default => ["test:all"]
+task :test => ["test:all"]
+namespace :test do
+ desc "Run Test Suite"
+ Rake::TestTask.new("all") do |test|
+ test.pattern = "test/dynamic_reports.rb"
+ test.verbose = true
+ test.warning = true
+ end
+end
+
+desc "Build the dynamic_reports gem and then install it."
+task :gem do
+ puts `gem uninstall dynamic_reports ; rm -f dynamic_reports-0.0.0.gem; gem build gemspec.rb ; gem install ./dynamic_reports-0.0.0.gem --no-ri -l`
+end
+namespace :gem do
+ desc "Build the dynamic_reports gem."
+ task :build do
+ puts `gem build gemspec.rb`
+ end
+
+ desc "Install the dynamic_reports gem."
+ task :install do
+ %x{gem install dynamic_reports*.gem --no-rdoc --no-ri -l}
+ end
+end
+
+begin
+require "rake/rdoctask"
+require "rdoc/generator"
+Rake::RDocTask.new do |rdoc|
+ rdoc.rdoc_dir = "doc"
+ rdoc.title = "Dynamic Reports"
+ rdoc.options << "--line-numbers"
+ rdoc.options << "--charset" << "utf-8"
+ rdoc.rdoc_files.include("README.rdoc", "HISTORY")
+ rdoc.rdoc_files.include("lib/*.rb")
+ rdoc.rdoc_files.include("lib/dynamic_reports/*.rb")
+end
+
+rescue
+ puts "Skipping loading of rdoc tasks, missing rdoc gem."
+end
@@ -0,0 +1,8 @@
+= General
+ *
+= Reports
+ * Factory Generators (for records data)
+ * Pdf engine option
+ *
+= Charts
+ *
Oops, something went wrong.

0 comments on commit b68914b

Please sign in to comment.