Module: RJack::TarPit

Defined in:
lib/rjack-tarpit/test.rb,
lib/rjack-tarpit/base.rb,
lib/rjack-tarpit/spec.rb,
lib/rjack-tarpit/util.rb,
lib/rjack-tarpit/clean.rb,
lib/rjack-tarpit/line_match.rb,
lib/rjack-tarpit/base_strategy.rb,
lib/rjack-tarpit/readme_parser.rb,
lib/rjack-tarpit/git.rb,
lib/rjack-tarpit/gem.rb,
lib/rjack-tarpit/doc.rb,
lib/rjack-tarpit.rb

Overview

– Copyright © 2009-2013 David Kellum

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ++

Defined Under Namespace

Modules: CleanTaskDefiner, DocTaskDefiner, GemTaskDefiner, GitTaskDefiner, LineMatchTaskDefiner, ManifestTracker, ReadmeParser, SpecHelper, TestTaskDefiner, Util Classes: BaseStrategy

Constant Summary collapse

MINOR_VERSION =
'2.1'
VERSION =
MINOR_VERSION + '.0'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.last_specObject (readonly)

The result of the last call to specify.



40
41
42
# File 'lib/rjack-tarpit/spec.rb', line 40

def last_spec
  @last_spec
end

Class Method Details

.new(name) ⇒ Object

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.



26
27
28
29
30
31
32
33
34
35
36
37
38
# 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) ⇒ Object

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.



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# 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

  # 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 )

  spec.tarpit_specify( &block )

  $LOAD_PATH.shift # ...then remove it to avoid pollution

  @last_spec = spec
end