123456789_123456789_123456789_123456789_123456789_

Class: Gem::Source::Lock

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
self, ::Gem::Source, ::Gem::Text, Comparable
Inherits: Gem::Source
Defined in: lib/rubygems/source/lock.rb

Overview

A Lock source wraps an installed gem’s source and sorts before other sources during dependency resolution. This allows RubyGems to prefer gems from dependency lock files.

Constant Summary

::Gem::Source - Inherited

FILES

Class Method Summary

  • .new(source) ⇒ Lock constructor

    Creates a new Lock source that wraps source and moves it earlier in the sort list.

::Gem::Source - Inherited

.new

Creates a new ::Gem::Source which will use the index located at #uri.

Instance Attribute Summary

::Gem::Source - Inherited

#update_cache?

Returns true when it is possible and safe to update the cache directory.

#uri

The URI this source will fetch gems from.

Instance Method Summary

::Gem::Source - Inherited

#<=>

Sources are ordered by installation preference.

#cache_dir

Returns the local directory to write #uri to.

#download

Downloads spec and writes it to Gem.dir.

#fetch_spec

Fetches a specification for the given name_tuple.

#load_specs

Loads type kind of specs fetching from @uri if the on-disk cache is out of date.

#typo_squatting?, #enforce_trailing_slash, #==,
#dependency_resolver_set

Returns a Set that can fetch specifications from this source.

#eql?

Alias for #==.

#hash, #pretty_print

::Gem::Text - Included

#clean_text

Remove any non-printable characters and make the text suitable for printing.

#format_text

Wraps text to wrap characters and optionally indents by indent characters.

#levenshtein_distance

Returns a value representing the “cost” of transforming str1 into str2 Vendored version of DidYouMean::Levenshtein.distance from the ruby/did_you_mean gem @ 1.4.0 github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651807c/lib/did_you_mean/levenshtein.rb#L7-L37.

#truncate_text, #min3

Constructor Details

.new(source) ⇒ Lock

Creates a new Lock source that wraps source and moves it earlier in the sort list.

[ GitHub ]

  
# File 'lib/rubygems/source/lock.rb', line 18

def initialize(source)
  @wrapped = source
end

Instance Attribute Details

#wrapped (readonly)

The wrapped ::Gem::Source

[ GitHub ]

  
# File 'lib/rubygems/source/lock.rb', line 12

attr_reader :wrapped

Instance Method Details

#<=>(other)

This method is for internal use only.
[ GitHub ]

  
# File 'lib/rubygems/source/lock.rb', line 22

def <=>(other) # :nodoc:
  case other
  when Gem::Source::Lock then
    @wrapped <=> other.wrapped
  when Gem::Source then
    1
  end
end

#==(other)

This method is for internal use only.
[ GitHub ]

  
# File 'lib/rubygems/source/lock.rb', line 31

def ==(other) # :nodoc:
  (self <=> other) == 0
end

#fetch_spec(name_tuple)

Delegates to the wrapped source’s fetch_spec method.

[ GitHub ]

  
# File 'lib/rubygems/source/lock.rb', line 42

def fetch_spec(name_tuple)
  @wrapped.fetch_spec name_tuple
end

#hash

This method is for internal use only.
[ GitHub ]

  
# File 'lib/rubygems/source/lock.rb', line 35

def hash # :nodoc:
  @wrapped.hash ^ 3
end

#uri

This method is for internal use only.
[ GitHub ]

  
# File 'lib/rubygems/source/lock.rb', line 46

def uri # :nodoc:
  @wrapped.uri
end