Skip to content

Instantly share code, notes, and snippets.

@VictorLowther
Created December 19, 2012 17:07
Show Gist options
  • Save VictorLowther/4338375 to your computer and use it in GitHub Desktop.
Save VictorLowther/4338375 to your computer and use it in GitHub Desktop.
Rubygems wrapper that allows for multiple --version arguments.
#!/usr/bin/ruby
require 'rubygems'
require 'rubygems/gem_runner'
require 'rubygems/exceptions'
# Stupid hack to allow multiple --version options.
module Gem::VersionOption
def add_version_option(task = command, *wrap)
OptionParser.accept Gem::Requirement do |value|
Gem::Requirement.new value
end
add_option('-v', '--version VERSION', Gem::Requirement,
"Specify version of gem to #{task}", *wrap) do
|value, options|
options[:version] = Array.new unless options[:version].kind_of?(Array)
options[:version] << value
options[:prerelease] = true if value.prerelease?
end
end
end
args = ARGV.clone
begin
Gem::GemRunner.new.run args
rescue Exception => e
e.backtrace
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment