def http_proxy_uri
      @http_proxy_uri ||= begin
        keys = %w( HTTP_PROXY HTTP_PROXY_USER HTTP_PROXY_PASS )
        env = Hash[ENV.
          map{|k, v| [k.upcase, v]}.
          select{|k, v| keys.include?(k)}.
          reject{|k, v| v.nil? || v.empty?}]

        uri = env["HTTP_PROXY"] or return
        uri = "http://#{uri}" unless uri =~ /^(https?|ftp|file):/
        uri = URI.parse(uri)
        uri.user ||= env["HTTP_PROXY_USER"]
        uri.password ||= env["HTTP_PROXY_PASS"]
        uri
      end
    end
def http_proxy_uri
      @http_proxy_uri ||= begin
        keys = %w( HTTP_PROXY HTTP_PROXY_USER HTTP_PROXY_PASS )
        env = Hash[ENV.
          map{|k, v| [k.upcase, v]}.
          select{|k, v| keys.include?(k)}.
          reject{|k, v| v.nil? || v.empty?}]

        uri = env["HTTP_PROXY"] or return
        uri = "http://#{uri}" unless uri =~ /^(https?|ftp|file):/
        uri = URI.parse(uri)
        uri.user ||= env["HTTP_PROXY_USER"]
        uri.password ||= env["HTTP_PROXY_PASS"]
        uri
      end
    end
The HTTP proxy specified in the environment variables:
 * HTTP_PROXY
 * HTTP_PROXY_USER
 * HTTP_PROXY_PASS
 Adapted from:
   https://github.com/rubygems/rubygems/blob/v1.8.24/lib/rubygems/remote_fetcher.rb#L276-293