Class: Stickler::Client::Unyank

Inherits:
Stickler::Client show all
Defined in:
lib/stickler/client/unyank.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
# File 'lib/stickler/client/unyank.rb', line 4

def self.banner
<<-_
Restore a yanked gem to the gemserver's index.

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

  Options:
_
end

Instance Method Details

#parse(argv) ⇒ Object



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

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

#parserObject



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

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

#runObject



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

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 "Unyanking gem #{spec.full_name} from #{repo.uri} : "
  $stdout.flush
  if spec = repo.unyank( spec ) then
    $stdout.puts "OK"
  else
    $stdout.puts "FAILURE"
  end
rescue Stickler::Repository::Error => e
  $stdout.puts "ERROR: #{e.message}"
end