Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement unyank for local and remote repositories.
Fixes: #9
- Loading branch information
1 parent
ca4c88f
commit dcf69fb
Showing
5 changed files
with
133 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
module Stickler | ||
class Client | ||
class Unyank < Stickler::Client | ||
def self.banner | ||
<<-_ | ||
Restore a yanked gem to the gemserver's index. | ||
Usage: stickler unyank [options] --gem-version x.y.z gem | ||
Options: | ||
_ | ||
end | ||
|
||
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 | ||
|
||
def parse( argv ) | ||
gem_name = nil | ||
opts = super( argv ) do |p| | ||
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 | ||
|
||
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 | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters