Class: Gem::Source::SpecificFile
- Inherits:
-
Gem::Source
- Object
- Gem::Source
- Gem::Source::SpecificFile
- Defined in:
- lib/rubygems/source/specific_file.rb
Overview
A source representing a single .gem file. This is used for installation of local gems.
Constant Summary
Constants inherited from Gem::Source
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
The path to the gem for this specific file.
-
#spec ⇒ Object
readonly
The Gem::Specification extracted from this .gem.
Attributes inherited from Gem::Source
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Orders this source against
other
. -
#download(spec, dir = nil) ⇒ Object
:nodoc:.
-
#fetch_spec(name) ⇒ Object
:nodoc:.
-
#initialize(file) ⇒ SpecificFile
constructor
Creates a new SpecificFile for the gem in
file
. -
#load_specs(*a) ⇒ Object
:nodoc:.
-
#pretty_print(q) ⇒ Object
:nodoc:.
Methods inherited from Gem::Source
#==, #cache_dir, #dependency_resolver_set, #hash, #typo_squatting?, #update_cache?
Methods included from Text
#clean_text, #format_text, #levenshtein_distance, #min3, #truncate_text
Constructor Details
#initialize(file) ⇒ SpecificFile
Creates a new SpecificFile for the gem in file
16 17 18 19 20 21 22 23 |
# File 'lib/rubygems/source/specific_file.rb', line 16 def initialize(file) @uri = nil @path = ::File.(file) @package = Gem::Package.new @path @spec = @package.spec @name = @spec.name_tuple end |
Instance Attribute Details
#path ⇒ Object (readonly)
The path to the gem for this specific file.
11 12 13 |
# File 'lib/rubygems/source/specific_file.rb', line 11 def path @path end |
#spec ⇒ Object (readonly)
The Gem::Specification extracted from this .gem.
28 29 30 |
# File 'lib/rubygems/source/specific_file.rb', line 28 def spec @spec end |
Instance Method Details
#<=>(other) ⇒ Object
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 Gem::Version#<=>
Otherwise Gem::Source#<=> is used.
62 63 64 65 66 67 68 69 70 71 |
# 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 |
#download(spec, dir = nil) ⇒ Object
:nodoc:
40 41 42 43 |
# File 'lib/rubygems/source/specific_file.rb', line 40 def download(spec, dir = nil) # :nodoc: return @path if spec == @spec raise Gem::Exception, "Unable to download '#{spec.full_name}'" end |
#fetch_spec(name) ⇒ Object
:nodoc:
34 35 36 37 38 |
# File 'lib/rubygems/source/specific_file.rb', line 34 def fetch_spec(name) # :nodoc: return @spec if name == @name raise Gem::Exception, "Unable to find '#{name}'" @spec end |
#load_specs(*a) ⇒ Object
:nodoc:
30 31 32 |
# File 'lib/rubygems/source/specific_file.rb', line 30 def load_specs(*a) # :nodoc: [@name] end |
#pretty_print(q) ⇒ Object
:nodoc:
45 46 47 48 49 50 |
# File 'lib/rubygems/source/specific_file.rb', line 45 def pretty_print(q) # :nodoc: q.group 2, '[SpecificFile:', ']' do q.breakable q.text @path end end |