Class: Gem::PackageTask
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
Rake::PackageTask
|
|
Instance Chain:
self,
Rake::PackageTask
|
|
Inherits: |
Rake::PackageTask
|
Defined in: | lib/rubygems/package_task.rb |
Overview
Create a package based upon a 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 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 Specification
:
require 'rubygems'
require 'rubygems/package_task'
spec = Gem::Specification.new do |s|
s.summary = "Ruby based make-like utility."
s.name = 'rake'
s.version = PKG_VERSION
s.requirements << 'none'
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
Class Method Summary
-
.new(gem_spec) {|_self| ... } ⇒ PackageTask
constructor
Create a
::Gem
Package task library.
Instance Attribute Summary
-
#gem_spec
rw
Ruby
Specification
containing the metadata for this package.
Instance Method Summary
-
#define
Create the Rake tasks and actions specified by this
PackageTask
. -
#init(gem)
Initialization tasks without the “yield self” or define operations.
Constructor Details
.new(gem_spec) {|_self| ... } ⇒ PackageTask
Instance Attribute Details
#gem_spec (rw)
Ruby 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.
# File 'lib/rubygems/package_task.rb', line 66
attr_accessor :gem_spec
Instance Method Details
#define
Create the Rake tasks and actions specified by this PackageTask
. (define
is automatically called if a block is given to .new).
# File 'lib/rubygems/package_task.rb', line 93
def define super gem_file = File.basename gem_spec.cache_file gem_path = File.join package_dir, gem_file gem_dir = File.join package_dir, gem_spec.full_name task :package => [:gem] directory package_dir directory gem_dir desc "Build the gem file #{gem_file}" task :gem => [gem_path] trace = Rake.application. .trace Gem.configuration.verbose = trace file gem_path => [package_dir, gem_dir] + @gem_spec.files do chdir(gem_dir) do when_writing "Creating #{gem_spec.file_name}" do Gem::Package.build gem_spec verbose trace do mv gem_file, ".." end end end end end
#init(gem)
Initialization tasks without the “yield self” or define operations.