2020-12-06 09:56:44 +03:00
|
|
|
#!ruby -pla
|
|
|
|
BEGIN {
|
|
|
|
require 'rubygems'
|
2023-10-23 11:36:05 +03:00
|
|
|
date = nil
|
2023-10-27 10:57:21 +03:00
|
|
|
# STDOUT is not usable in inplace edit mode
|
|
|
|
output = $-i ? STDOUT : STDERR
|
2023-10-28 08:12:10 +03:00
|
|
|
}
|
|
|
|
output = STDERR if ARGF.file == STDIN
|
|
|
|
END {
|
2023-10-25 07:09:49 +03:00
|
|
|
output.print date.strftime("latest_date=%F") if date
|
2020-12-06 09:56:44 +03:00
|
|
|
}
|
|
|
|
unless /^[^#]/ !~ (gem = $F[0])
|
2023-11-04 05:29:42 +03:00
|
|
|
ver = Gem::Version.new($F[1])
|
2020-12-06 09:56:44 +03:00
|
|
|
(gem, src), = Gem::SpecFetcher.fetcher.detect(:latest) {|s|
|
|
|
|
s.platform == "ruby" && s.name == gem
|
|
|
|
}
|
2023-11-04 05:29:42 +03:00
|
|
|
if gem.version > ver
|
|
|
|
gem = src.fetch_spec(gem)
|
|
|
|
if ENV["UPDATE_BUNDLED_GEMS_ALL"]
|
|
|
|
uri = gem.metadata["source_code_uri"] || gem.homepage
|
|
|
|
uri = uri.sub(%r[\Ahttps://github\.com/[^/]+/[^/]+\K/tree/.*], "").chomp(".git")
|
|
|
|
else
|
|
|
|
uri = $F[2]
|
|
|
|
end
|
|
|
|
date = gem.date if !date or gem.date && gem.date > date
|
|
|
|
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
|
2021-07-21 14:44:13 +03:00
|
|
|
end
|
2023-11-04 05:29:42 +03:00
|
|
|
f = [gem.name, gem.version.to_s, uri, *$F[3..-1]]
|
|
|
|
$_.gsub!(/\S+\s*(?=\s|$)/) {|s| (f.shift || "").ljust(s.size)}
|
|
|
|
$_ = [$_, *f].join(" ") unless f.empty?
|
|
|
|
$_.rstrip!
|
2021-07-21 14:44:13 +03:00
|
|
|
end
|
2020-12-06 09:56:44 +03:00
|
|
|
end
|