Skip to content

Instantly share code, notes, and snippets.

@snehaso
Last active December 5, 2019 11:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save snehaso/d53bb40df798ba9a677d46e2cb27f3a8 to your computer and use it in GitHub Desktop.
Save snehaso/d53bb40df798ba9a677d46e2cb27f3a8 to your computer and use it in GitHub Desktop.
#!/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