1. Gem::
  2. PackageTask

class Gem::PackageTask

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

package_dir/name-version.gem”

Create a RubyGems package with the given name and version.

Example using aGem::Specification:

require'rubygems'require'rubygems/package_task'spec =Gem::Specification.newdo|s|s.summary ="Ruby based make-like utility."s.name ='rake's.version =PKG_VERSIONs.requirements<<'none's.files =PKG_FILESs.description =<<-EOFRake is a Make-like program implemented in Ruby. Tasksand dependencies are specified in standard Ruby syntax.  EOFendGem::PackageTask.new(spec)do|pkg|pkg.need_zip =truepkg.need_tar =trueend

Attributes

gem_spec[RW]

RubyGem::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

Source
# File lib/rubygems/package_task.rb, line 73definitialize(gem_spec)initgem_specyieldselfifblock_given?defineifblock_given?end

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

Public Instance Methods

Source
# File lib/rubygems/package_task.rb, line 93defdefinesupergem_file =File.basenamegem_spec.cache_filegem_path =File.joinpackage_dir,gem_filegem_dir  =File.joinpackage_dir,gem_spec.full_nametaskpackage: [:gem]directorypackage_dirdirectorygem_dirdesc"Build the gem file #{gem_file}"taskgem: [gem_path]trace =Rake.application.options.traceGem.configuration.verbose =tracefilegem_path=> [package_dir,gem_dir]+@gem_spec.filesdochdir(gem_dir)dowhen_writing"Creating #{gem_spec.file_name}"doGem::Package.buildgem_specverbosetracedomvgem_file,".."endendendendend

Create the Rake tasks and actions specified by thisGem::PackageTask. (define is automatically called if a block is given tonew).

Calls superclass method
Source
# File lib/rubygems/package_task.rb, line 82definit(gem)supergem.full_name,:noversion@gem_spec =gem@package_files+=gem_spec.filesifgem_spec.files@fileutils_output =$stdoutend

Initialization tasks without the “yield self” or define operations.

Calls superclass method