Class Gem::PackageTask
In: lib/rubygems/package_task.rb
Parent: Rake::PackageTask

Create a package based upon a Gem::Specification. 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 Rake::PackageTask, a Gem::PackageTask will also generate the following tasks:

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

Example using a Gem::Specification:

  require 'rubygems'
  require 'rubygems/package_task'

  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

  Gem::PackageTask.new(spec) do |pkg|
    pkg.need_zip = true
    pkg.need_tar = true
  end

Methods

define   init   new  

Attributes

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

Public Class methods

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/rubygems/package_task.rb, line 79
79:   def initialize(gem_spec)
80:     init gem_spec
81:     yield self if block_given?
82:     define if block_given?
83:   end

Public Instance methods

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

[Source]

     # File lib/rubygems/package_task.rb, line 98
 98:   def define
 99:     super
100: 
101:     task :package => [:gem]
102: 
103:     gem_file = gem_spec.file_name
104:     gem_path = File.join package_dir, gem_file
105:     gem_dir  = File.join package_dir, gem_spec.full_name
106: 
107:     desc "Build the gem file #{gem_file}"
108:     task :gem => [gem_path]
109: 
110:     trace = Rake.application.options.trace
111:     Gem.configuration.verbose = trace
112: 
113:     file gem_path => [package_dir, gem_dir] + @gem_spec.files do
114:       when_writing "Creating #{gem_spec.file_name}" do
115:         Gem::Builder.new(gem_spec).build
116:         verbose trace do
117:           mv gem_file, gem_path
118:         end
119:       end
120:     end
121:   end

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

[Source]

    # File lib/rubygems/package_task.rb, line 88
88:   def init(gem)
89:     super gem.name, gem.version
90:     @gem_spec = gem
91:     @package_files += gem_spec.files if gem_spec.files
92:   end

[Validate]