2014-03-03 16:49:42 +00:00
|
|
|
#!/usr/bin/ruby
|
|
|
|
|
|
|
|
require 'rubygems/package'
|
|
|
|
|
|
|
|
module RubyGemsProv
|
|
|
|
module Helpers
|
|
|
|
# If there is some prelease version files, such as rc1 (i.e. non-numeric
|
|
|
|
# field), prepend this field by tilde instead of dot.
|
|
|
|
def self.normalize_prerelease(version)
|
|
|
|
if version.prerelease?
|
|
|
|
prerelease = version.version.sub /^#{version.release}\./, ''
|
2014-04-07 13:23:37 +00:00
|
|
|
"#{version.release}-0.1.#{prerelease}"
|
2014-03-03 16:49:42 +00:00
|
|
|
else
|
2014-04-07 13:23:37 +00:00
|
|
|
"#{version.release}-1"
|
2014-03-03 16:49:42 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# Reports all functionality gem provides.
|
|
|
|
def self.provides
|
|
|
|
while filename = gets
|
|
|
|
filename.strip!
|
|
|
|
begin
|
|
|
|
specification = Gem::Specification.load filename
|
|
|
|
|
|
|
|
puts "rubygem(#{specification.name}) = #{Helpers::normalize_prerelease(specification.version)}"
|
|
|
|
rescue => e
|
|
|
|
# Ignore all errors.
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if __FILE__ == $0
|
|
|
|
RubyGemsProv::provides
|
|
|
|
end
|