module Hoe::Package

Package plugin for hoe.

Tasks Provided:

#install_gem

Install the package as a gem.

release

Package and upload the release.

Attributes

need_tar[RW]

Optional: Should package create a tarball? [default: true]

need_zip[RW]

Optional: Should package create a zipfile? [default: false]

Public Instance Methods

define_package_tasks() click to toggle source

Define tasks for plugin.

# File lib/hoe/package.rb, line 39
def define_package_tasks
  prerelease_version

  Gem::PackageTask.new spec do |pkg|
    pkg.need_tar = @need_tar
    pkg.need_zip = @need_zip
  end

  desc 'Install the package as a gem. (opt. NOSUDO=1)'
  task :install_gem => [:clean, :package, :check_extra_deps] do
    install_gem Dir['pkg/*.gem'].first
  end

  desc 'Package and upload; Requires VERSION=x.y.z (optional PRE=a.1)'
  task :release => [:prerelease, :release_to, :postrelease]

  # no doco, invisible hook
  task :prerelease do
    abort "Fix your version before you release" if spec.version =~ /borked/
  end

  # no doco, invisible hook
  task :release_to

  # no doco, invisible hook
  task :postrelease

  desc "Sanity checks for release"
  task :release_sanity do
    v = ENV["VERSION"] or abort "Must supply VERSION=x.y.z"

    pre = ENV['PRERELEASE'] || ENV['PRE']
    v += ".#{pre}" if pre

    abort "Versions don't match #{v} vs #{version}" if v != version
  end
end
initialize_package() click to toggle source

Initialize variables for plugin.

# File lib/hoe/package.rb, line 31
def initialize_package
  self.need_tar ||= false
  self.need_zip ||= false
end
install_gem(name, version = nil) click to toggle source

Install the named gem.

# File lib/hoe/package.rb, line 88
def install_gem name, version = nil
  should_not_sudo = Hoe::WINDOZE || ENV["NOSUDO"] || File.writable?(Gem.dir)

  gem_cmd = Gem.default_exec_format % 'gem'
  sudo    = 'sudo '                  unless should_not_sudo
  local   = '--local'                unless version
  version = "--version '#{version}'" if     version
  sh "#{sudo}#{gem_cmd} install #{local} #{name} #{version}"
end
pkg_path() click to toggle source

Returns the path used for packaging. Convenience method for those that need to write a package hook.

# File lib/hoe/package.rb, line 81
def pkg_path
  "pkg/#{spec.full_name}"
end