Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #29 from macwadu/master

added functionality to permit get the latest version of a gem
  • Loading branch information...
commit fee2a5388a254f64fcca7d781d5a5afaa3e0428d 2 parents 5b329f2 + 018e460
@copiousfreetime authored
View
2  bin/stickler
@@ -56,5 +56,7 @@ when "config"
::Stickler::Client::Config.new( ARGV ).run
when "list"
::Stickler::Client::List.new( ARGV ).run
+when "last-version"
+ ::Stickler::Client::Version.new(ARGV).run
end
View
1  lib/stickler/client.rb
@@ -49,3 +49,4 @@ def remote_repo_for( opts )
require 'stickler/client/push'
require 'stickler/client/unyank'
require 'stickler/client/yank'
+require 'stickler/client/last-version'
View
33 lib/stickler/client/last-version.rb
@@ -0,0 +1,33 @@
+module Stickler
+ class Client
+ class Version < Stickler::Client
+ def self.banner
+ <<-_
+List the gems in the stickler server with repository information.
+
+Usage: stickler list
+
+ Options:
+ _
+ end
+
+ def run
+ begin
+ raise Stickler::Repository::Error, 'last-version option needs an argument (gem name)' if self.argv.first.nil?
+ opts = parse(self.argv)
+ repo = remote_repo_for(opts)
+ hashversions = {}
+ repo.specs_list.each do |name, version|
+ hashversions.store(name, "#{version}")
+ end
+ lastversion = hashversions[self.argv.first]
+ raise Stickler::Repository::Error, 'Gem doesn\'t exist in the server.' if lastversion.nil?
+ puts lastversion
+ return lastversion
+ rescue Stickler::Repository::Error => e
+ $stdout.puts "ERROR: #{e.message}"
+ end
+ end
+ end
+ end
+end
View
3  man/stickler.1.ronn
@@ -45,6 +45,9 @@ COMMANDS
Put a gem that was _yanked_ back into the gemserver index. This reverses a
`yank`.
+*last-version*:
+ Prints the latest version of a gem
+
OPTIONS
-------
These are the options for all commands. Not all options apply to all commands.
Please sign in to comment.
Something went wrong with that request. Please try again.