Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

added functionality to permit get the latest version of a gem #29

Merged
merged 1 commit into from

2 participants

@macwadu

I had an issue when using stickler with puppet trying to get puppet to install the latest version of a gem, with this feature i can get the latest version of a gem a get it to be installed by puppet.

I think is a useful functionality to use with puppet.

@copiousfreetime

This sounds reasonable, and i'm trying to understand your use case. You are using stickler last-version <gemname> as test in puppet to see what the latest version is so you can see if puppet should install a new version of the gem? Could you get the same effect if you just used gem list -r <gemname> and parsed the output?

@macwadu

Yeah the gem list -r <gemname> gives the same result but not like the stickler last-version <gemname> it will need some parsing. The problem is that puppet doesn't know how to get the latest version if you don't specify it manually like 0.0.12, if you use ensure => latest in puppet it something get you versions like '0.0.60.0.7' .

@copiousfreetime

Alright, sounds reasonable, I'll merge this in soon.

@macwadu

Great, thanks :)

@copiousfreetime

this will go into the next version

@copiousfreetime copiousfreetime merged commit fee2a53 into copiousfreetime:master
@copiousfreetime

I did some mucking around with this to bring it in line the other commands and normalized it to 'latest-version'

@copiousfreetime

this is now included with the released 2.4 version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
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.
Something went wrong with that request. Please try again.