Class: Gem::Source::Lock

Inherits:
Gem::Source show all
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

Constants inherited from Gem::Source

FILES

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Gem::Source

#cache_dir, #dependency_resolver_set, #download, #load_specs, #pretty_print, #typo_squatting?, #update_cache?

Methods included from Text

#clean_text, #format_text, #levenshtein_distance, #min3, #truncate_text

Constructor Details

#initialize(source) ⇒ Lock

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



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

def initialize(source)
  @wrapped = source
end

Instance Attribute Details

#wrappedObject (readonly)

The wrapped Gem::Source



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

def wrapped
  @wrapped
end

Instance Method Details

#<=>(other) ⇒ Object

:nodoc:



21
22
23
24
25
26
27
28
29
30
# File 'lib/rubygems/source/lock.rb', line 21

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

#==(other) ⇒ Object

:nodoc:



32
33
34
# File 'lib/rubygems/source/lock.rb', line 32

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

#fetch_spec(name_tuple) ⇒ Object

Delegates to the wrapped source’s fetch_spec method.



43
44
45
# File 'lib/rubygems/source/lock.rb', line 43

def fetch_spec(name_tuple)
  @wrapped.fetch_spec name_tuple
end

#hashObject

:nodoc:



36
37
38
# File 'lib/rubygems/source/lock.rb', line 36

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

#uriObject

:nodoc:



47
48
49
# File 'lib/rubygems/source/lock.rb', line 47

def uri # :nodoc:
  @wrapped.uri
end