Class: Rake::Gemcutter::Tasks

Inherits:
TaskLib
  • Object
show all
Defined in:
lib/rake/rubygems.rb

Defined Under Namespace

Modules: CommandTweaks

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gem_spec) {|_self| ... } ⇒ Tasks

Returns a new instance of Tasks.

Yields:

  • (_self)

Yield Parameters:



13
14
15
16
17
18
19
# 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

Instance Attribute Details

#gem_pathObject

Returns the value of attribute gem_path.



25
26
27
# File 'lib/rake/rubygems.rb', line 25

def gem_path
  @gem_path
end

#package_dirObject

Returns the value of attribute package_dir.



25
26
27
# File 'lib/rake/rubygems.rb', line 25

def package_dir
  @package_dir
end

Instance Method Details

#defineObject



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# 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_fieldsObject



27
28
29
30
31
32
33
34
35
# 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) ⇒ Object



58
59
60
61
62
63
# 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_fieldsObject



21
22
23
24
# File 'lib/rake/rubygems.rb', line 21

def setup_fields
  @gem_path = nil
  @package_dir = "pkg"
end