Class: Rake::GemPackageTask
- Inherits:
-
PackageTask
- Object
- TaskLib
- PackageTask
- Rake::GemPackageTask
- Defined in:
- lib/rake/gempackagetask.rb
Overview
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
Instance Attribute Summary collapse
-
#gem_spec ⇒ Object
Ruby GEM spec containing the metadata for this package.
Attributes inherited from PackageTask
#name, #need_tar, #need_tar_bz2, #need_tar_gz, #need_zip, #package_dir, #package_files, #tar_command, #version, #zip_command
Instance Method Summary collapse
-
#define ⇒ Object
Create the Rake tasks and actions specified by this GemPackageTask.
- #gem_file ⇒ Object
-
#init(gem) ⇒ Object
Initialization tasks without the “yield self” or define operations.
-
#initialize(gem_spec) {|_self| ... } ⇒ GemPackageTask
constructor
Create a GEM Package task library.
Methods inherited from PackageTask
#package_dir_path, #package_name, #tar_bz2_file, #tar_gz_file, #tgz_file, #zip_file
Methods inherited from TaskLib
Methods included from Cloneable
Constructor Details
#initialize(gem_spec) {|_self| ... } ⇒ GemPackageTask
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.
62 63 64 65 66 |
# File 'lib/rake/gempackagetask.rb', line 62 def initialize(gem_spec) init(gem_spec) yield self if block_given? define if block_given? end |
Instance Attribute Details
#gem_spec ⇒ Object
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.
57 58 59 |
# File 'lib/rake/gempackagetask.rb', line 57 def gem_spec @gem_spec end |
Instance Method Details
#define ⇒ Object
Create the Rake tasks and actions specified by this GemPackageTask. (define
is automatically called if a block is given to new
).
79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/rake/gempackagetask.rb', line 79 def define super task :package => [:gem] desc "Build the gem file #{gem_file}" task :gem => ["#{package_dir}/#{gem_file}"] file "#{package_dir}/#{gem_file}" => [package_dir] + @gem_spec.files do when_writing("Creating GEM") { Gem::Builder.new(gem_spec).build verbose(true) { mv gem_file, "#{package_dir}/#{gem_file}" } } end end |
#gem_file ⇒ Object
94 95 96 97 98 99 100 |
# File 'lib/rake/gempackagetask.rb', line 94 def gem_file if @gem_spec.platform == Gem::Platform::RUBY "#{package_name}.gem" else "#{package_name}-#{@gem_spec.platform}.gem" end end |
#init(gem) ⇒ Object
Initialization tasks without the “yield self” or define operations.
70 71 72 73 74 |
# File 'lib/rake/gempackagetask.rb', line 70 def init(gem) super(gem.name, gem.version) @gem_spec = gem @package_files += gem_spec.files if gem_spec.files end |