class Rake::Gemcutter::Tasks

Attributes

gem_path[RW]
package_dir[RW]

Public Class Methods

new(gem_spec) { |self| ... } click to toggle source
# File lib/rake/rubygems.rb, line 13
def initialize(gem_spec)
  @gem_spec = gem_spec
  setup_fields
  yield self if block_given?
  finalize_fields
  define
end

Public Instance Methods

define() click to toggle source
# File lib/rake/rubygems.rb, line 65
def define
  namespace :gem do
    desc "Uninstall the gem" 
    task :uninstall do |t|
      when_writing("Uninstalling #{@gem_name}") do
        uninstall = get_command Gem::Commands::UninstallCommand
        uninstall.gem_list = [@gem_path]
        uninstall.execute
      end
    end

    desc "Install the gem locally"
    task :install => [@gem_path] do |t|
      when_writing("Installing #{@gem_path}") do
        install = get_command Gem::Commands::InstallCommand
        install.get_list = [@gem_path]
        install.execute
      end
    end

    desc "Force a reinstall of the gem"
    task :reinstall => [:uninstall, :install]

    task :dependencies_available do
      checker = Gem::SpecFetcher.new
      @gem_spec.runtime_dependencies.each do |dep|
        fulfilling = checker.fetch(dep,false,false,false)
        if fulfilling.empty?
          fail "Dependency #{dep} is unfulfilled remotely"
        else
          puts "Remotely fulfilled: #{dep}"
        end
      end
    end

    desc 'Push a gem up to Gemcutter'
    task :push => [:dependencies_available] do
      push = get_command(Gem::Commands::PushCommand)
      push.gem_list = [@gem_path]
      push.execute
    end
  end
end
finalize_fields() click to toggle source
# File lib/rake/rubygems.rb, line 27
def finalize_fields
  if @gem_name.nil?
    @gem_name = @gem_spec.full_name
  end

  if @gem_path.nil? and not @package_dir.nil?
    @gem_path = File::join(@package_dir, @gem_spec.file_name)
  end
end
get_command(klass, args=nil) click to toggle source
# File lib/rake/rubygems.rb, line 58
def get_command(klass, args=nil)
  cmd = klass.new
  cmd.extend(CommandTweaks)
  cmd.setup_args(args)
  cmd
end
setup_fields() click to toggle source
# File lib/rake/rubygems.rb, line 21
def setup_fields
  @gem_path = nil
  @package_dir = "pkg"
end