Class: Stickler::Client::Yank

Inherits:
Stickler::Client show all
Defined in:
lib/stickler/client/yank.rb

Instance Attribute Summary

Attributes inherited from Stickler::Client

#argv, #sources

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Stickler::Client

config, #initialize, #remote_repo_for

Constructor Details

This class inherits a constructor from Stickler::Client

Class Method Details



4
5
6
7
8
9
10
11
12
13
# File 'lib/stickler/client/yank.rb', line 4

def self.banner
<<-_
Remove a gem from the gemserver's index.  
It will still be available for direct download.

Usage: stickler yank [options] --gem-version x.y.z gem

  Options:
_
end

Instance Method Details

#parse(argv) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/stickler/client/yank.rb', line 24

def parse( argv )
  gem_name = nil
  opts = super( argv ) do |p,o|
    raise Trollop::CommandlineError, "At least one gem is required to yank" if p.leftovers.empty?
    gem_name = p.leftovers.shift
  end
  opts[:gem_name] = gem_name
  return opts
end

#parserObject



15
16
17
18
19
20
21
22
# File 'lib/stickler/client/yank.rb', line 15

def parser
  unless @parser then
    @parser = super
    @parser.opt( :gem_version,  "The version of the gem to yank (required)",  :type => :string, :required => true )
    @parser.opt( :platform, "The platform of the gem to yank", :type => :string, :default => ::Gem::Platform::RUBY )
  end
  return @parser
end

#runObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/stickler/client/yank.rb', line 34

def run
   opts = parse( self.argv )
   repo = remote_repo_for( opts )
   spec = Stickler::SpecLite.new( opts[:gem_name], opts[:gem_version], opts[:platform] )

   $stdout.write "Yanking gem #{spec.full_name} from #{repo.uri} : "
   $stdout.flush
   if spec = repo.yank( spec ) then
     $stdout.puts "OK"
   else
     $stdout.puts "FAILURE"
   end
rescue Stickler::Repository::Error => e
   $stdout.puts "ERROR: #{e.message}"
end