GemDev

Utilities simplifying gem development.

Introduction

GemDev provides some extensions to make it easy to develop multiple, interrelated gems at once by allowing you to specify your gem development folders in the RubyGems configuration file (.gemrc).

Additionally, test extensions are provided to permit test subsetting.

Copyright © 2006-2007, Regents of the University of Colorado.

Developer

Simon Chiang, Biomolecular Structure Program

Support

UCHSC School of Medicine Deans Academic Enrichment Fund

Licence

MIT-Style

GemDev Usage

Specify development folders using one big glob or an array of globs keyed by ‘development’ in the ‘.gemrc’ file. GemDev will load each ‘gemspecs/*.gemspec’ file along every path specified, and set the gem path so you can require the gems as if they were already installed.

Say you were developing ‘ioutils’ with the following:

/path/to/ioutils # => your development folder
/path/to/ioutils/gemspecs/0.7.0.gemspec  # => a released gemspec
/path/to/ioutils/gemspecs/0.8.0.gemspec  # => the lastest, unreleased gemspec

To specify this gem, you add to ‘.gemrc’:

development: /path/to/ioutils

or if you have a bunch of other gems:

development: 
  - /path/to/{ioutils,another_gem}
  - /path/to/yet_another_gem

In your scripts:

require 'gemdev'
require 'ioutils' # => now works without installing ioutils

Requiring ioutils as above will load the latest version (0.8.0) by default, but nothing prevents you from requiring a different version if you need to.

Working with Rakefiles

Splitting gemspecs out of a Rakefile while preserving a GemPackageTask is easy:

# Normally here you'd have your definition
# Gem::Specification.new ... 
#
# Just replace with the path to the gemspec you want to package
spec = Gem::SourceIndex.load_specification("./gemspecs/0.8.0.gemspec")
Rake::GemPackageTask.new(spec) do |pkg|

pkg.need_tar = true

end

Subsets Usage

Subsets are provided to make unit testing more convenient.

Example:

require 'gemdev'
require 'test/unit/subsets'
class YourTest < Test::Unit::TestCase
  # only runs if ENV['benchmark']=true
  def test_benchmark_some_method
    benchmark_test do |x|
       x.report("speed") {...}
    end
  end
end