Class: Gemma::RakeTasks

Inherits:
Object
  • Object
show all
Defined in:
lib/gemma/rake_tasks.rb,
lib/gemma/rake_tasks/plugin.rb,
lib/gemma/rake_tasks/gem_tasks.rb,
lib/gemma/rake_tasks/run_tasks.rb,
lib/gemma/rake_tasks/rdoc_tasks.rb,
lib/gemma/rake_tasks/yard_tasks.rb,
lib/gemma/rake_tasks/minitest_tasks.rb

Overview

Generate standard gem development tasks; the tasks are configured using the settings in the given gemspec file.

Examples:

To create the default tasks based on your mygem.gemspec file:

# At the top of Rakefile.rb.
require 'rubygems'
require 'bundler/setup'
require 'gemma'

Gemma::RakeTasks.with_gemspec_file 'mygem.gemspec'

# ... other tasks ...

Defined Under Namespace

Classes: GemTasks, MinitestTasks, Plugin, RDocTasks, RunTasks, YardTasks

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gemspec) {|tasks| ... } ⇒ RakeTasks

Constructor mainly for internal use; you should usually use the ‘with_gemspec_file` alias (see examples in Gemma::RakeTasks).

file or a gemspec object; the latter is intended mainly for testing

Parameters:

  • gemspec (String, Gem::Specification)

    either the name of a gemspec

Yields:

  • (tasks)

    used to customize the tasks to be created

Yield Parameters:



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/gemma/rake_tasks.rb', line 38

def initialize gemspec, &block
  # Load gemspec.
  if gemspec.is_a?(String)
    @gemspec_file_name = gemspec
    @gemspec = Gem::Specification::load(gemspec_file_name)
  elsif gemspec.is_a?(Gem::Specification)
    @gemspec_file_name = nil
    @gemspec = gemspec
  else
    raise ArgumentError, 'bad gemspec argument'
  end

  @plugins = {}
  create_default_plugins

  # Let the user add more plugins and alter settings.
  block.call(self) if block_given?

  @plugins.values.each do |plugin|
    begin
      plugin.create_rake_tasks
    rescue 
      warn "plugin #{plugin.class} failed: #{$!}"
    end
  end
end

Instance Attribute Details

#gemspecGem::Specification (readonly)

The specification used to configure the rake tasks.

(make the changes in the gemspec file instead).

Returns:

  • (Gem::Specification)

    not nil; you should not modify this object



79
80
81
# File 'lib/gemma/rake_tasks.rb', line 79

def gemspec
  @gemspec
end

#gemspec_file_nameString (readonly)

File from which the #gemspec was loaded.

constructor; otherwise, nil

Returns:

  • (String)

    not nil if a gemspec file name was passed to the



71
72
73
# File 'lib/gemma/rake_tasks.rb', line 71

def gemspec_file_name
  @gemspec_file_name
end

#pluginsHash<Symbol, Plugin> (readonly)

Returns:



84
85
86
# File 'lib/gemma/rake_tasks.rb', line 84

def plugins
  @plugins
end

Instance Method Details

#gemGemTasks

Returns:



109
# File 'lib/gemma/rake_tasks.rb', line 109

def gem; @plugins[:gem] end

#rdocRDocTasks

Returns:



89
# File 'lib/gemma/rake_tasks.rb', line 89

def rdoc; @plugins[:rdoc] end

#runRunTasks

Returns:



94
# File 'lib/gemma/rake_tasks.rb', line 94

def run; @plugins[:run] end

#testMinitestTasks

Returns:



99
# File 'lib/gemma/rake_tasks.rb', line 99

def test; @plugins[:test] end

#yardYardTasks

Returns:



104
# File 'lib/gemma/rake_tasks.rb', line 104

def yard; @plugins[:yard] end