Class: Rake::Gemcutter::Tasks

Inherits:
TaskLib
  • Object
show all
Defined in:
lib/rake/gemcutter.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:



11
12
13
14
15
16
17
# File 'lib/rake/gemcutter.rb', line 11

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.



23
24
25
# File 'lib/rake/gemcutter.rb', line 23

def gem_path
  @gem_path
end

#package_dirObject

Returns the value of attribute package_dir.



23
24
25
# File 'lib/rake/gemcutter.rb', line 23

def package_dir
  @package_dir
end

Instance Method Details

#defineObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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
# File 'lib/rake/gemcutter.rb', line 49

def define
  namespace :gem do
    desc "Uninstall the gem" 
    task :uninstall do |t|
      when_writing("Uninstalling #{@gem_name}") do
        begin
          puts "Uninstalling #{@gem_name}"
          Gem::Uninstaller.new(@gem_name, {:executables => true, :ignore => true}).uninstall
        rescue Exception
        end
      end
    end

    desc "Install the gem locally"
    task :install => [@gem_path] do |t|
      when_writing("Installing #{@gem_path}") do
        puts "Installing #{@gem_path}"
        system(*%w{sudo gem install} + [@gem_path] ) #Wish I could do this without 
        #resorting to the command line
      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.options[:args] = [@gem_path]
      push.execute
    end
  end
end

#finalize_fieldsObject



25
26
27
28
29
30
31
32
33
# File 'lib/rake/gemcutter.rb', line 25

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



42
43
44
45
46
47
# File 'lib/rake/gemcutter.rb', line 42

def get_command(klass, args=nil)
  cmd = klass.new
  cmd.extend(CommandTweaks)
  cmd.setup_args(args)
  cmd
end

#setup_fieldsObject



19
20
21
22
# File 'lib/rake/gemcutter.rb', line 19

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