Building Third Party Extensions to Ruport

We currently have a fairly vanilla, but experimental plugin system which uses Zed Shaw's gem_plugin under the hood. Nothing should be considered final until 1.0 in terms of our support for this system, but as of Ruport 0.8.10, you can now build gem based plugins

Existing Plugins For Ruport

See the List of available plugins. If you'd like, you can add your own entries there as well.

You can also keep an eye on development by watching our unofficial svn repository for plugins

Developing Plugins

The following conventions should be enough to get started.

Directory Structure

  my_app/
     lib/
       my_app/
          init.rb
          #any other files
      test/
        ...

init.rb

Example:

class RuportInvoiceLoader < GemPlugin::Plugin "ruport/invoice"
   require 'invoice'
   # or other setup stuff here.  
end

# here you can define more classes, reopen stuff, 
# do normal ruby, whatever, or stick things in other files.  
# Note it is the file that inherits from GemPlugin::Plugin that
# actually gets loaded.  (i think)

Rakefile

Adapt as needed, but you must make sure your plugin depends on ruport(at least 0.8.10) and gem_plugin

require "rake/rdoctask"
require "rake/testtask"
require "rake/gempackagetask"

begin
  require "rubygems"
rescue LoadError
  nil
end

Rake::TestTask.new do |test|
  test.libs << "test"
  test.test_files = Dir[ "test/test_*.rb" ]
  test.verbose = true
end

spec = Gem::Specification.new do |spec|
  spec.name = "ruport_invoice"
  spec.version = "0.1.0"
  spec.platform = Gem::Platform::RUBY
  spec.summary = "simple invoice support for Ruport"
  spec.files =  Dir.glob("{lib}/**/**/*") + ["Rakefile"]

  spec.require_path = "lib"
  spec.has_rdoc = false

  spec.add_dependency('gem_plugin', ">= 0.1")
  spec.add_dependency('ruport', '>= 0.8.99')
  spec.author = "Gregory Brown"
  spec.email = "  gregory.t.brown@gmail.com"
  spec.homepage = "http://code.rubyreports.org"
  spec.description = <<END_DESC
   Simple invoice support for Ruport
END_DESC
end

Rake::GemPackageTask.new(spec) do |pkg|
  pkg.need_zip = true
  pkg.need_tar = true
end