mirror of
https://github.com/ruby/ruby.git
synced 2025-08-26 22:45:03 +02:00

rubygems 2.7.x depends bundler-1.15.x. This is preparation for rubygems and bundler migration. * lib/bundler.rb, lib/bundler/*: files of bundler-1.15.4 * spec/bundler/*: rspec examples of bundler-1.15.4. I applied patches. * https://github.com/bundler/bundler/pull/6007 * Exclude not working examples on ruby repository. * Fake ruby interpriter instead of installed ruby. * Makefile.in: Added test task named `test-bundler`. This task is only working macOS/linux yet. I'm going to support Windows environment later. * tool/sync_default_gems.rb: Added sync task for bundler. [Feature #12733][ruby-core:77172] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59779 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
63 lines
1.6 KiB
Ruby
63 lines
1.6 KiB
Ruby
# frozen_string_literal: true
|
|
module Bundler
|
|
class Source
|
|
class Rubygems
|
|
class Remote
|
|
attr_reader :uri, :anonymized_uri, :original_uri
|
|
|
|
def initialize(uri)
|
|
orig_uri = uri
|
|
uri = Bundler.settings.mirror_for(uri)
|
|
@original_uri = orig_uri if orig_uri != uri
|
|
fallback_auth = Bundler.settings.credentials_for(uri)
|
|
|
|
@uri = apply_auth(uri, fallback_auth).freeze
|
|
@anonymized_uri = remove_auth(@uri).freeze
|
|
end
|
|
|
|
# @return [String] A slug suitable for use as a cache key for this
|
|
# remote.
|
|
#
|
|
def cache_slug
|
|
@cache_slug ||= begin
|
|
cache_uri = original_uri || uri
|
|
|
|
uri_parts = [cache_uri.host, cache_uri.user, cache_uri.port, cache_uri.path]
|
|
uri_digest = Digest::MD5.hexdigest(uri_parts.compact.join("."))
|
|
|
|
uri_parts[-1] = uri_digest
|
|
uri_parts.compact.join(".")
|
|
end
|
|
end
|
|
|
|
def to_s
|
|
"rubygems remote at #{anonymized_uri}"
|
|
end
|
|
|
|
private
|
|
|
|
def apply_auth(uri, auth)
|
|
if auth && uri.userinfo.nil?
|
|
uri = uri.dup
|
|
uri.userinfo = auth
|
|
end
|
|
|
|
uri
|
|
rescue URI::InvalidComponentError
|
|
error_message = "Please CGI escape your usernames and passwords before " \
|
|
"setting them for authentication."
|
|
raise HTTPError.new(error_message)
|
|
end
|
|
|
|
def remove_auth(uri)
|
|
if uri.userinfo
|
|
uri = uri.dup
|
|
uri.user = uri.password = nil
|
|
end
|
|
|
|
uri
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|