Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Replace Rake::GemPackageTask with Gem::PackageTask

  • Loading branch information...
commit c225f5d5eeb0668aa5e02fbe52ef62952d9757eb 1 parent 2365bd2
Eric Hodel drbrain authored
1  Rakefile
View
@@ -195,6 +195,7 @@ else
#### Dependencies and requirements.
+ s.required_rubygems_version '>= 1.3.2'
#s.add_dependency('log4r', '> 1.0.4')
#s.requirements << ""
96 lib/rake/gempackagetask.rb
View
@@ -1,97 +1,13 @@
-#!/usr/bin/env ruby
+# rake/gempackagetask is deprecated in favor of rubygems/package_task
-# Define a package task library to aid in the definition of GEM
-# packages.
+warn 'rake/gempackagetask is deprecated. Use rubygems/package_task instead'
require 'rubygems'
+require 'rubygems/package_task'
+
require 'rake'
-require 'rake/packagetask'
-require 'rubygems/user_interaction'
-require 'rubygems/builder'
module Rake
-
- # 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:
- #
- # [<b>"<em>package_dir</em>/<em>name</em>-<em>version</em>.gem"</b>]
- # 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
- #
- class GemPackageTask < PackageTask
- # 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.
- attr_accessor :gem_spec
-
- # 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.
- def initialize(gem_spec)
- init(gem_spec)
- yield self if block_given?
- define if block_given?
- end
-
- # Initialization tasks without the "yield self" or define
- # operations.
- def init(gem)
- super(gem.name, gem.version)
- @gem_spec = gem
- @package_files += gem_spec.files if gem_spec.files
- end
-
- # Create the Rake tasks and actions specified by this
- # GemPackageTask. (+define+ is automatically called if a block is
- # given to +new+).
- 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
-
- def gem_file
- if @gem_spec.platform == Gem::Platform::RUBY
- "#{package_name}.gem"
- else
- "#{package_name}-#{@gem_spec.platform}.gem"
- end
- end
-
- end
+ GemPackageTask = Gem::PackageTask
end
+
55 test/lib/package_task_test.rb
View
@@ -2,6 +2,7 @@
require 'test/unit'
require 'rake/packagetask'
+require 'rake/gempackagetask'
require 'test/rake_test_setup'
class TestPackageTask < Test::Unit::TestCase
@@ -62,57 +63,3 @@ def test_clone
end
end
-
-begin
- require 'rubygems'
- require 'rake/gempackagetask'
-rescue Exception
- puts "WARNING: RubyGems not installed"
-end
-
-if ! defined?(Gem)
- puts "WARNING: Unable to test GemPackaging ... requires RubyGems"
-else
- class TestGemPackageTask < Test::Unit::TestCase
- def test_gem_package
- gem = Gem::Specification.new do |g|
- g.name = "pkgr"
- g.version = "1.2.3"
- g.files = FileList["x"].resolve
- end
- pkg = Rake::GemPackageTask.new(gem) do |p|
- p.package_files << "y"
- end
- assert_equal ["x", "y"], pkg.package_files
- assert_equal "pkgr-1.2.3.gem", pkg.gem_file
- end
-
- def test_gem_package_with_current_platform
- gem = Gem::Specification.new do |g|
- g.name = "pkgr"
- g.version = "1.2.3"
- g.files = FileList["x"].resolve
- g.platform = Gem::Platform::CURRENT
- end
- pkg = Rake::GemPackageTask.new(gem) do |p|
- p.package_files << "y"
- end
- assert_equal ["x", "y"], pkg.package_files
- assert_match(/^pkgr-1\.2\.3-(\S+)\.gem$/, pkg.gem_file)
- end
-
- def test_gem_package_with_ruby_platform
- gem = Gem::Specification.new do |g|
- g.name = "pkgr"
- g.version = "1.2.3"
- g.files = FileList["x"].resolve
- g.platform = Gem::Platform::RUBY
- end
- pkg = Rake::GemPackageTask.new(gem) do |p|
- p.package_files << "y"
- end
- assert_equal ["x", "y"], pkg.package_files
- assert_equal "pkgr-1.2.3.gem", pkg.gem_file
- end
- end
-end
Please sign in to comment.
Something went wrong with that request. Please try again.