Last active
December 5, 2019 11:23
-
-
Save snehaso/d53bb40df798ba9a677d46e2cb27f3a8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
host = ARGV.shift || "user:token@freeagent.jfrog.io/freeagent/api/gems/gems/" | |
require 'uri' | |
require 'net/http' | |
begin | |
require 'openssl' | |
rescue LoadError | |
abort "Oh no! Your Ruby doesn't have OpenSSL, so it can't connect to #{host}. " \ | |
"You'll need to recompile or reinstall Ruby with OpenSSL support and try again." | |
end | |
begin | |
# Some versions of Ruby need this require to do HTTPS | |
require 'net/https' | |
# Try for RubyGems version | |
require 'rubygems' | |
# Try for Bundler version | |
require 'bundler' | |
rescue LoadError | |
end | |
uri = URI("https://#{host}") | |
begin | |
Bundler::Fetcher.new(Bundler::Source::Rubygems::Remote.new(uri)).send(:connection).request(uri) | |
bundler_status = "success ✅" | |
rescue => error | |
bundler_status = "failed ❌ (#{error})" | |
end | |
puts "Bundler connection to #{host}: #{bundler_status}" | |
begin | |
require 'rubygems/remote_fetcher' | |
Gem::RemoteFetcher.fetcher.fetch_path(uri) | |
rubygems_status = "success ✅" | |
rescue => error | |
rubygems_status = "failed ❌ (#{error})" | |
end | |
puts "RubyGems connection to #{host}: #{rubygems_status}" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment