Skip to content

Instantly share code, notes, and snippets.

@dsingleton
Forked from boffbowsh/Gemfile
Last active July 22, 2020 22:25
Show Gist options
  • Save dsingleton/28b89e145acb81dae534 to your computer and use it in GitHub Desktop.
Save dsingleton/28b89e145acb81dae534 to your computer and use it in GitHub Desktop.
source "https://rubygems.org"
require "bundler"
require "net/http"
require "openssl"
require "uri"
GEMS = %w{
rails
slimmer
govuk_frontend_toolkit
gds-sso
govuk_admin_template
}
repos = %w{
bouncer
manuals-frontend
specialist-publisher
hmrc-manuals-api
smart-answers
calculators
calendars
mapit
immenence
contacts-frontend
contacts-admin
business-support-api
business-support-finder
transition
trade-tariff-frontend
trade-tariff-admin
trade-tariff-api
asset-manager
content-store
static
whitehall
}
def lockfile_for(repo)
uri = URI.parse("https://raw.githubusercontent.com/alphagov/#{repo}/master/Gemfile.lock")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(uri.request_uri)
response = http.request(request)
response.body
end
def gem_statuses(repo)
lockfile = Bundler::LockfileParser.new(lockfile_for(repo))
Hash[lockfile.specs
.select { |d| GEMS.include? d.name }
.map { |s| [s.name, s.version.to_s] }]
end
puts "repo\t#{GEMS.join("\t")}"
repos.each do |repo|
repo_gems = gem_statuses(repo)
puts "#{repo}\t" + GEMS.map { |g| repo_gems[g] }.join("\t")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment