Class: Gem::Tasks::Build::Gem

Inherits:
Task
  • Object
show all
Defined in:
lib/rubygems/tasks/build/gem.rb

Overview

The build:gem task.

Constant Summary

Constants included from Printing

Printing::ANSI_BRIGHT, Printing::ANSI_CLEAR, Printing::ANSI_GREEN, Printing::ANSI_RED, Printing::ANSI_YELLOW, Printing::DEBUG_PREFIX, Printing::ERROR_PREFIX, Printing::STATUS_PREFIX

Instance Attribute Summary

Attributes inherited from Task

#project

Instance Method Summary collapse

Methods inherited from Task

#bundle, #gem, #gemspec_tasks, #invoke, #namespaced_tasks, #run, #task?

Methods included from Printing

#debug, #error, #status

Constructor Details

#initialize(options = {}) {|_self| ... } ⇒ Gem

Initializes the build:gem task.

Parameters:

  • options (Hash) (defaults to: {})

    Additional options.

Yields:

  • (_self)

Yield Parameters:



21
22
23
24
25
26
# File 'lib/rubygems/tasks/build/gem.rb', line 21

def initialize(options={})
  super()

  yield self if block_given?
  define
end

Instance Method Details

#build(path, gemspec) ⇒ Object

Builds the .gem package.

Parameters:

  • path (String)

    The path for the .gem package.

  • gemspec (Gem::Specification)

    The gemspec to build the .gem package from.



52
53
54
55
56
57
58
59
60
# File 'lib/rubygems/tasks/build/gem.rb', line 52

def build(path,gemspec)
  gem = if ::Gem::VERSION > '2.'
          ::Gem::Package.build(gemspec)
        else
          ::Gem::Builder.new(gemspec).build
        end

  mv gem, Project::PKG_DIR
end

#defineObject

Defines the build:gem task.



31
32
33
34
35
36
37
38
39
# File 'lib/rubygems/tasks/build/gem.rb', line 31

def define
  build_task :gem

  # backwards compatibility for Gem::PackageTask
  task :gem => 'build:gem'

  # backwards compatibility for Hoe
  task :package => 'build:gem'
end