module RJack::TarPit

Constants

MINOR_VERSION
VERSION

Attributes

last_spec[R]

The result of the last call to specify.

Public Class Methods

new( name ) { |tp| ... } click to toggle source

New task generator given name matching <name>.gemspec in the current directory. If block is given, yields self (err, actually the BaseStrategy) to block and calls define_tasks upon exit.

# File lib/rjack-tarpit.rb, line 26
def self.new( name )

  load( "#{name}.gemspec", true )

  tp = BaseStrategy.new( last_spec )

  if block_given?
    yield tp
    tp.define_tasks
  end

  tp
end
specify( &block ) click to toggle source

Produce a Gem::Specification embellished with SpecHelper, ReadmeParser, and yield to block. The specification name defaults to <name>.gemspec calling this. Within block, $LOAD_PATH will have the projects lib included.

# File lib/rjack-tarpit/spec.rb, line 46
def specify( &block )

  # Embellish a Specification instance with SpecHelper.
  #
  # This way spec.to_yaml continues to be a Gem::Specification
  # object. Deriving our own Specification subclass would cause
  # problems with to_yaml.
  spec = Gem::Specification.new
  spec.extend( SpecHelper )
  spec.extend( ReadmeParser )

  specfile = caller[0] =~ /^(.+\.gemspec):/ && $1

  if specfile
    # Default name to the (name).gemspec that should be calling us
    spec.name = File.basename( specfile, ".gemspec" )

    # Add project's lib/ to LOAD_PATH for block...
    ldir = File.expand_path( File.join( File.dirname( specfile ), 'lib' ) )
    $LOAD_PATH.unshift( ldir )
  end

  spec.tarpit_specify( &block )

  if specfile
    $LOAD_PATH.shift # ...then remove it to avoid pollution
  end

  @last_spec = spec
end