Class: Bundler::Source::Rubygems::Remote
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/bundler/source/rubygems/remote.rb |
Class Method Summary
- .new(uri) ⇒ Remote constructor
Instance Attribute Summary
- #anonymized_uri readonly
- #original_uri readonly
- #uri readonly
Instance Method Summary
- #cache_slug ⇒ String
- #to_s
- #apply_auth(uri, auth) private
- #remove_auth(uri) private
Constructor Details
.new(uri) ⇒ Remote
# File 'lib/bundler/source/rubygems/remote.rb', line 9
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
Instance Attribute Details
#anonymized_uri (readonly)
[ GitHub ]# File 'lib/bundler/source/rubygems/remote.rb', line 7
attr_reader :uri, :anonymized_uri, :original_uri
#original_uri (readonly)
[ GitHub ]# File 'lib/bundler/source/rubygems/remote.rb', line 7
attr_reader :uri, :anonymized_uri, :original_uri
#uri (readonly)
[ GitHub ]# File 'lib/bundler/source/rubygems/remote.rb', line 7
attr_reader :uri, :anonymized_uri, :original_uri
Instance Method Details
#apply_auth(uri, auth) (private)
[ GitHub ]# File 'lib/bundler/source/rubygems/remote.rb', line 44
def apply_auth(uri, auth) if auth && uri.userinfo.nil? uri = uri.dup uri.userinfo = auth end uri rescue Bundler::URI::InvalidComponentError = "Please CGI escape your usernames and passwords before " \ "setting them for authentication." raise HTTPError.new( ) end
#cache_slug ⇒ String
# File 'lib/bundler/source/rubygems/remote.rb', line 22
def cache_slug @cache_slug ||= begin return nil unless SharedHelpers.md5_available? cache_uri = original_uri || uri host = cache_uri.to_s.start_with?("file://") ? nil : cache_uri.host uri_parts = [host, cache_uri.user, cache_uri.port, cache_uri.path] uri_digest = SharedHelpers.digest(:MD5).hexdigest(uri_parts.compact.join(".")) uri_parts[-1] = uri_digest uri_parts.compact.join(".") end end
#remove_auth(uri) (private)
[ GitHub ]#to_s
[ GitHub ]# File 'lib/bundler/source/rubygems/remote.rb', line 38
def to_s "rubygems remote at #{anonymized_uri}" end