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/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, 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)
  # 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.
  yield(self) if block_given?

  @plugins.values.each do |plugin|
    begin
      plugin.create_rake_tasks
    rescue
      warn "plugin #{plugin.class} failed: #{$ERROR_INFO}"
    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:


110
111
112
# File 'lib/gemma/rake_tasks.rb', line 110

def gem
  @plugins[:gem]
end

#rdocRDocTasks

Returns:


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

def rdoc
  @plugins[:rdoc]
end

#testMinitestTasks

Returns:


96
97
98
# File 'lib/gemma/rake_tasks.rb', line 96

def test
  @plugins[:test]
end

#yardYardTasks

Returns:


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

def yard
  @plugins[:yard]
end