1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/tool/update-bundled_gems.rb
2021-12-02 21:13:02 +09:00

20 lines
597 B
Ruby
Executable file

#!ruby -pla
BEGIN {
require 'rubygems'
}
unless /^[^#]/ !~ (gem = $F[0])
(gem, src), = Gem::SpecFetcher.fetcher.detect(:latest) {|s|
s.platform == "ruby" && s.name == gem
}
gem = src.fetch_spec(gem)
uri = gem.metadata["source_code_uri"] || gem.homepage
uri = uri.sub(%r[\Ahttps://github\.com/[^/]+/[^/]+\K/tree/.*], "").chomp(".git")
if $F[3]
if $F[3].include?($F[1])
$F[3][$F[1]] = gem.version.to_s
elsif Gem::Version.new($F[1]) != gem.version and /\A\h+\z/ =~ $F[3]
$F[3..-1] = []
end
end
$_ = [gem.name, gem.version, uri, *$F[3..-1]].join(" ")
end