123456789_123456789_123456789_123456789_123456789_

Class: Gem::Source::SpecificFile

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

Overview

A source representing a single .gem file. This is used for installation of local gems.

Class Method Summary

::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.

Constructor Details

.new(file) ⇒ SpecificFile

Creates a new SpecificFile for the gem in file

[ GitHub ]

  
# File 'lib/rubygems/source/specific_file.rb', line 16

def initialize(file)
  @uri = nil
  @path = ::File.expand_path(file)

  @package = Gem::Package.new @path
  @spec = @package.spec
  @name = @spec.name_tuple
end

Instance Attribute Details

#path (readonly)

The path to the gem for this specific file.

[ GitHub ]

  
# File 'lib/rubygems/source/specific_file.rb', line 11

attr_reader :path

#spec (readonly)

The ::Gem::Specification extracted from this .gem.

[ GitHub ]

  
# File 'lib/rubygems/source/specific_file.rb', line 28

attr_reader :spec

Instance Method Details

#<=>(other)

Orders this source against other.

If other is a SpecificFile from a different gem name nil is returned.

If other is a SpecificFile from the same gem name the versions are compared using Version#<=>

Otherwise Gem::Source#<=> is used.

[ GitHub ]

  
# File 'lib/rubygems/source/specific_file.rb', line 62

def <=> other
  case other
  when Gem::Source::SpecificFile then
    return nil if @spec.name != other.spec.name

    @spec.version <=> other.spec.version
  else
    super
  end
end