Class | Rake::GemPackageTask
In: | lib/rake/gempackagetask.rb
Parent: | PackageTask

Create a package based upon a Gem spec. Gem packages, as well as zip files and tar/gzipped packages can be produced by this task.

In addition to the Rake targets generated by PackageTask, a GemPackageTask will also generate the following tasks:

"package_dir/name-version.gem"
  Create a Ruby GEM package with the given name and version.

Example using a Ruby GEM spec:

      require 'rubygems'

      spec = Gem::Specification.new do |s|
        s.platform = Gem::Platform::RUBY
        s.summary = "Ruby based make-like utility."
        s.name = 'rake'
        s.version = PKG_VERSION
        s.requirements << 'none'
        s.require_path = 'lib'
        s.autorequire = 'rake'
        s.files = PKG_FILES
        s.description = <<EOF
      Rake is a Make-like program implemented in Ruby. Tasks
      and dependencies are specified in standard Ruby syntax.
      EOF
      end

      Rake::GemPackageTask.new(spec) do |pkg|
        pkg.need_zip = true
        pkg.need_tar = true
      end

### Methods

define gem_file init new

### Attributes

gem_spec | [RW] | Ruby GEM spec containing the metadata for this package. The name, version and package_files are automatically determined from the GEM spec and don‘t need to be explicitly provided.

### Public Class methods

new(gem_spec) {|self if block_given?| ...}

Create a GEM Package task library. Automatically define the gem if a block is given. If no block is supplied, then `define` needs to be called to define the task.

[Source]

        # File lib/rake/gempackagetask.rb, line 60
    60:     def initialize(gem_spec)
    61:       init(gem_spec)
    62:       yield self if block_given?
    63:       define if block_given?
    64:     end

### Public Instance methods

define()

Create the Rake tasks and actions specified by this GemPackageTask. (`define` is automatically called if a block is given to `new`).

[Source]

        # File lib/rake/gempackagetask.rb, line 77
    77:     def define
    78:       super
    79:       task :package => [:gem]
    80:       desc "Build the gem file #{gem_file}"
    81:       task :gem => ["#{package_dir}/#{gem_file}"]
    82:       file "#{package_dir}/#{gem_file}" => [package_dir] + @gem_spec.files do
    83:         when_writing("Creating GEM") {
    84:           Gem::Builder.new(gem_spec).build
    85:           verbose(true) {
    86:             mv gem_file, "#{package_dir}/#{gem_file}"
    87:           }
    88:         }
    89:       end
    90:     end

gem_file()

[Source]

        # File lib/rake/gempackagetask.rb, line 92
    92:     def gem_file
    93:       if @gem_spec.platform == Gem::Platform::RUBY
    94:         "#{package_name}.gem"
    95:       else
    96:         "#{package_name}-#{@gem_spec.platform}.gem"
    97:       end
    98:     end

init(gem)

Initialization tasks without the "yield self" or define operations.

[Source]

        # File lib/rake/gempackagetask.rb, line 68
    68:     def init(gem)
    69:       super(gem.name, gem.version)
    70:       @gem_spec = gem
    71:       @package_files += gem_spec.files if gem_spec.files
    72:     end

[Validate]