| CODENOTIFIER | HelpYou are not signed inSign in |
Project: Ruport
Revision: 1303
Author: sandal
Date: 14 Apr 2008 11:05:35
Changes:release
Files:| ... | ...@@ -0,0 +1,94 @@ | |
| 1 | require "rake/rdoctask" | |
| 2 | require "rake/testtask" | |
| 3 | require "rake/gempackagetask" | |
| 4 | ||
| 5 | RUPORT_VERSION = "1.6.1" | |
| 6 | ||
| 7 | begin | |
| 8 | require "rubygems" | |
| 9 | rescue LoadError | |
| 10 | nil | |
| 11 | end | |
| 12 | ||
| 13 | task :default => [:test] | |
| 14 | ||
| 15 | Rake::TestTask.new do |test| | |
| 16 | test.libs << "test" | |
| 17 | test.test_files = Dir[ "test/*_test.rb" ] | |
| 18 | test.verbose = true | |
| 19 | end | |
| 20 | ||
| 21 | spec = Gem::Specification.new do |spec| | |
| 22 | spec.name = "ruport" | |
| 23 | spec.version = RUPORT_VERSION | |
| 24 | spec.platform = Gem::Platform::RUBY | |
| 25 | spec.summary = "A generalized Ruby report generation and templating engine." | |
| 26 | spec.files = Dir.glob("{examples,lib,test,bin,util/bench}/**/**/*") + | |
| 27 | ["Rakefile"] | |
| 28 | spec.require_path = "lib" | |
| 29 | ||
| 30 | spec.test_files = Dir[ "test/*_test.rb" ] | |
| 31 | spec.has_rdoc = true | |
| 32 | spec.extra_rdoc_files = %w{README LICENSE AUTHORS} | |
| 33 | spec.rdoc_options << '--title' << 'Ruport Documentation' << | |
| 34 | '--main' << 'README' << '-q' | |
| 35 | spec.add_dependency('fastercsv', '= 1.2.3') | |
| 36 | spec.add_dependency('pdf-writer','= 1.1.8') | |
| 37 | spec.author = "Gregory Brown" | |
| 38 | spec.email = " gregory.t.brown@gmail.com" | |
| 39 | spec.rubyforge_project = "ruport" | |
| 40 | spec.homepage = "http://rubyreports.org" | |
| 41 | spec.description = <<END_DESC | |
| 42 | Ruby Reports is a software library that aims to make the task of reporting | |
| 43 | less tedious and painful. It provides tools for data acquisition, | |
| 44 | database interaction, formatting, and parsing/munging. | |
| 45 | END_DESC | |
| 46 | end | |
| 47 | ||
| 48 | Rake::RDocTask.new do |rdoc| | |
| 49 | rdoc.rdoc_files.include( "README", | |
| 50 | #"CHANGELOG", | |
| 51 | "AUTHORS", "COPYING", | |
| 52 | "LICENSE", "lib/" ) | |
| 53 | rdoc.main = "README" | |
| 54 | rdoc.rdoc_dir = "doc/html" | |
| 55 | rdoc.title = "Ruport Documentation" | |
| 56 | end | |
| 57 | ||
| 58 | Rake::GemPackageTask.new(spec) do |pkg| | |
| 59 | pkg.need_zip = true | |
| 60 | pkg.need_tar = true | |
| 61 | end | |
| 62 | ||
| 63 | task :build_archives => [:package,:rcov,:rdoc] do | |
| 64 | mv "pkg/ruport-#{RUPORT_VERSION}.tgz", "pkg/ruport-#{RUPORT_VERSION}.tar.gz" | |
| 65 | sh "tar cjvf pkg/ruport_coverage-#{RUPORT_VERSION}.tar.bz2 coverage" | |
| 66 | sh "tar cjvf pkg/ruport_doc-#{RUPORT_VERSION}.tar.bz2 doc/html" | |
| 67 | cd "pkg" | |
| 68 | sh "tar cjvf ruport-#{RUPORT_VERSION}.tar.bz2 ruport-#{RUPORT_VERSION}" | |
| 69 | end | |
| 70 | ||
| 71 | task :run_benchmarks do | |
| 72 | files = FileList["util/bench/**/**/*.rb"] | |
| 73 | files.sort! | |
| 74 | files.uniq! | |
| 75 | names = files.map { |r| r.sub("util/bench","").split("/").map { |e| e.capitalize } } | |
| 76 | names.map! { |e| e[1..-2].join("::") + " <BENCH: #{e[-1].sub('Bench_','').sub('.rb','')}>" } | |
| 77 | start_time = Time.now | |
| 78 | files.zip(names).each { |f,n| | |
| 79 | puts "\n#{n}\n\n" | |
| 80 | sh "ruby -Ilib #{f}" | |
| 81 | puts "\n" | |
| 82 | } | |
| 83 | end_time = Time.now | |
| 84 | puts "\n** Total Run Time: #{end_time-start_time}s **" | |
| 85 | end | |
| 86 | ||
| 87 | begin | |
| 88 | require 'rcov/rcovtask' | |
| 89 | Rcov::RcovTask.new do |t| | |
| 90 | t.test_files = Dir[ "test/*_test.rb" ] | |
| 91 | end | |
| 92 | rescue LoadError | |
| 93 | nil | |
| 94 | end |
| ... | ...@@ -0,0 +1,127 @@ | |
| 1 | # ruport.rb : Ruby Reports top level module | |
| 2 | # | |
| 3 | # Author: Gregory T. Brown (gregory.t.brown at gmail dot com) | |
| 4 | # | |
| 5 | # Copyright (c) 2005-2007, All Rights Reserved. | |
| 6 | # | |
| 7 | # This is free software. You may modify and redistribute this freely under | |
| 8 | # your choice of the GNU General Public License or the Ruby License. | |
| 9 | # | |
| 10 | # See LICENSE and COPYING for details | |
| 11 | # | |
| 12 | ||
| 13 | ||
| 14 | if RUBY_VERSION > "1.9" | |
| 15 | require "csv" | |
| 16 | unless defined? FCSV | |
| 17 | class Object | |
| 18 | FCSV = CSV | |
| 19 | alias_method :FCSV, :CSV | |
| 20 | end | |
| 21 | end | |
| 22 | end | |
| 23 | ||
| 24 | ||
| 25 | module Ruport #:nodoc:# | |
| 26 | ||
| 27 | VERSION = "1.6.1" | |
| 28 | ||
| 29 | class FormatterError < RuntimeError #:nodoc: | |
| 30 | end | |
| 31 | ||
| 32 | # SystemExtensions lovingly ganked from HighLine 1.2.1 | |
| 33 | # | |
| 34 | # The following modifications have been made by Gregory Brown on 2006.06.25 | |
| 35 | # | |
| 36 | # - Outer Module is changed from HighLine to Ruport | |
| 37 | # - terminal_width / terminal_height added | |
| 38 | # | |
| 39 | # The following modifications have been made by Gregory Brown on 2006.08.13 | |
| 40 | # - removed most methods, preserving only terminal geometry features | |
| 41 | # | |
| 42 | # All modifications are under the distributions terms of Ruport. | |
| 43 | # Copyright 2006, Gregory Brown. All Rights Reserved | |
| 44 | # | |
| 45 | # Original copyright notice preserved below. | |
| 46 | # -------------------------------------------------------------------------- | |
| 47 | # | |
| 48 | # Created by James Edward Gray II on 2006-06-14. | |
| 49 | # Copyright 2006 Gray Productions. All rights reserved. | |
| 50 | # | |
| 51 | # This is Free Software. See LICENSE and COPYING for details. | |
| 52 | ||
| 53 | module SystemExtensions #:nodoc: | |
| 54 | module_function | |
| 55 | ||
| 56 | # This section builds character reading and terminal size functions | |
| 57 | # to suit the proper platform we're running on. Be warned: Here be | |
| 58 | # dragons! | |
| 59 | # | |
| 60 | begin | |
| 61 | require "Win32API" # See if we're on Windows. | |
| 62 | ||
| 63 | # A Windows savvy method to fetch the console columns, and rows. | |
| 64 | def terminal_size | |
| 65 | m_GetStdHandle = Win32API.new( 'kernel32', | |
| 66 | 'GetStdHandle', | |
| 67 | ['L'], | |
| 68 | 'L' ) | |
| 69 | m_GetConsoleScreenBufferInfo = Win32API.new( | |
| 70 | 'kernel32', 'GetConsoleScreenBufferInfo', ['L', 'P'], 'L' | |
| 71 | ) | |
| 72 | ||
| 73 | format = 'SSSSSssssSS' | |
| 74 | buf = ([0] * format.size).pack(format) | |
| 75 | stdout_handle = m_GetStdHandle.call(0xFFFFFFF5) | |
| 76 | ||
| 77 | m_GetConsoleScreenBufferInfo.call(stdout_handle, buf) | |
| 78 | bufx, bufy, curx, cury, wattr, | |
| 79 | left, top, right, bottom, maxx, maxy = buf.unpack(format) | |
| 80 | return right - left + 1, bottom - top + 1 | |
| 81 | end | |
| 82 | rescue LoadError # If we're not on Windows try... | |
| 83 | # A Unix savvy method to fetch the console columns, and rows. | |
| 84 | def terminal_size | |
| 85 | size = if /solaris/ =~ RUBY_PLATFORM | |
| 86 | output = `stty` | |
| 87 | [output.match('columns = (\d+)')[1].to_i, | |
| 88 | output.match('rows = (\d+)')[1].to_i] | |
| 89 | else | |
| 90 | `stty size`.split.map { |x| x.to_i }.reverse | |
| 91 | end | |
| 92 | return $? == 0 ? size : [80,24] | |
| 93 | end | |
| 94 | ||
| 95 | end | |
| 96 | ||
| 97 | def terminal_width | |
| 98 | terminal_size.first | |
| 99 | end | |
| 100 | ||
| 101 | end | |
| 102 | ||
| 103 | # quiets warnings for block | |
| 104 | def quiet #:nodoc: | |
| 105 | warns = $VERBOSE | |
| 106 | $VERBOSE = nil | |
| 107 | result = yield | |
| 108 | $VERBOSE = warns | |
| 109 | return result | |
| 110 | end | |
| 111 | ||
| 112 | module_function :quiet | |
| 113 | ||
| 114 | end | |
| 115 | ||
| 116 | require "enumerator" | |
| 117 | require "ruport/controller" | |
| 118 | require "ruport/data" | |
| 119 | require "ruport/formatter" | |
| 120 | ||
| 121 | begin | |
| 122 | if Object.const_defined? :ActiveRecord | |
| 123 | require "ruport/acts_as_reportable" | |
| 124 | end | |
| 125 | rescue LoadError | |
| 126 | nil | |
| 127 | end |
| ... | ...@@ -0,0 +1,114 @@ | |
| 1 | # ----------------------------------------------------------------- | |
| 2 | # Contents: | |
| 3 | # | |
| 4 | # + What Ruport Is | |
| 5 | # + Installation | |
| 6 | # + Resources | |
| 7 | # + Hacking | |
| 8 | # | |
| 9 | # = What Ruport Is | |
| 10 | # | |
| 11 | # Ruby Reports (Ruport) is an extensible reporting system. | |
| 12 | # | |
| 13 | # It aims to be as lightweight as possible while still providing core support | |
| 14 | # for data aggregation and manipulation as well as multi-format rendering | |
| 15 | # of reports. | |
| 16 | # | |
| 17 | # Ruport provides tools for using a number of data sources, including CSV files, | |
| 18 | # ActiveRecord models, and raw SQL connections via RubyDBI (through ruport-util). | |
| 19 | # | |
| 20 | # Data manipulation is easy as there are standard structures that support | |
| 21 | # record, table, and grouping operations. These all can be extended to | |
| 22 | # implement custom behavior as needed. | |
| 23 | # | |
| 24 | # For common tasks, Ruport provides formatters for CSV, HTML, PDF, and text- | |
| 25 | # based reports. However, the real power lies in building custom report | |
| 26 | # controllers and formatters. The base formatting libraries provide a number | |
| 27 | # of helper functions that will let you build complex reports while maintaining | |
| 28 | # a DRY and consistent interface. | |
| 29 | # | |
| 30 | # To get a quick feel for what you can accomplish with Ruport, take a look at | |
| 31 | # a few simple examples provided on our web site. | |
| 32 | # | |
| 33 | # http://rubyreports.org/examples.html | |
| 34 | # | |
| 35 | # Since Ruport's core support is intentionally minimalistic, you may be looking | |
| 36 | # for some higher level support for specific needs such as graphing, invoices, | |
| 37 | # report mailing support, etc. For this, you may wish to take a look at the | |
| 38 | # ruport-util package, which contains some generally useful tools and libraries | |
| 39 | # to extend Ruport's capabilities. | |
| 40 | # | |
| 41 | # = Installation | |
| 42 | # | |
| 43 | # To install ruport via rubygems: | |
| 44 | # | |
| 45 | # sudo gem install ruport | |
| 46 | # | |
| 47 | # Check to see if it installed properly: | |
| 48 | # | |
| 49 | # ruby -rubygems -e "require 'ruport'; puts Ruport::VERSION" | |
| 50 | # | |
| 51 | # If you get an error, please let us know on our mailing list. | |
| 52 | # | |
| 53 | # Dependencies Details: | |
| 54 | # | |
| 55 | # -- formatting | |
| 56 | # | |
| 57 | # Ruport relies on PDF::Writer and FasterCSV for its formatting support. | |
| 58 | # If you want to make use of textile helpers, you'll also need RedCloth. | |
| 59 | # | |
| 60 | # -- database interaction | |
| 61 | # | |
| 62 | # If you wish to use Ruport to report against a rails project, | |
| 63 | # a camping project, or do standalone acts_as_reportable reports, you'll need | |
| 64 | # ActiveRecord and the acts_as_reportable gem. | |
| 65 | # | |
| 66 | # If you want to use Ruport::Query for raw SQL support, you'll need to | |
| 67 | # install ruport-util, RubyDBI and whatever database drivers you might need. | |
| 68 | # | |
| 69 | # = Resources | |
| 70 | # | |
| 71 | # Our developers have published a free-content book about all things | |
| 72 | # Ruport, including complete coverage of acts_as_reportable and some of | |
| 73 | # ruport-util's features. This book serves as the definitive guide to | |
| 74 | # Ruport, so all users should become acquainted with it: | |
| 75 | # | |
| 76 | # http://ruportbook.com | |
| 77 | # | |
| 78 | # The next best way to get help and make suggestions is the Ruport mailing list. | |
| 79 | # This software is on the move, so the list is the most reliable way of getting | |
| 80 | # up to date information. | |
| 81 | # | |
| 82 | # - You can sign up and/or view the archives here: | |
| 83 | # http://groups.google.com/group/ruby-reports | |
| 84 | # | |
| 85 | # If you are looking to dig a little deeper, there are a couple more resources | |
| 86 | # that may be helpful to you. | |
| 87 | # | |
| 88 | # - The latest stable API documentation is available at: | |
| 89 | # http://api.rubyreports.org | |
| 90 | # | |
| 91 | # - Our Trac is at: http://code.rubyreports.org/ruport | |
| 92 | # You may use the username ruport and password blinky to file tickets. | |
| 93 | # | |
| 94 | # = Hacking | |
| 95 | # | |
| 96 | # If you'd like to contribute code to Ruport, please join our development | |
| 97 | # mailing list, and let us know what you'd like to do! | |
| 98 | # | |
| 99 | # http://groups.google.com/group/ruport-dev | |
| 100 | # | |
| 101 | # It also may be worthwhile to join this list if you plan on running edge | |
| 102 | # versions of Ruport, as this is where we make announcements about major | |
| 103 | # breakage in trunk. | |
| 104 | # | |
| 105 | # We are very responsive to contributors, and review every patch we receive | |
| 106 | # fairly quickly. Most contributors who successfully get a patch or two applied | |
| 107 | # are given write access to the repositories and invited to join Ruport's | |
| 108 | # development team. Since we view every user as potential contributor, this | |
| 109 | # approach works well for us. | |
| 110 | # | |
| 111 | # So if you want to help out with Ruport, we'll happy accept your efforts! | |
| 112 | ||
| 113 | ||
| 114 |