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
-
#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
#==, #api_uri, #cache_dir, #dependency_resolver_set, #hash, #update_cache?
Constructor Details
#initialize(file) ⇒ SpecificFile
Creates a new SpecificFile for the gem in file
10 11 12 13 14 15 16 17 |
# File 'lib/rubygems/source/specific_file.rb', line 10 def initialize(file) @uri = nil @path = ::File.(file) @package = Gem::Package.new @path @spec = @package.spec @name = @spec.name_tuple end |
Instance Attribute Details
#spec ⇒ Object (readonly)
The Gem::Specification extracted from this .gem.
22 23 24 |
# File 'lib/rubygems/source/specific_file.rb', line 22 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.
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/rubygems/source/specific_file.rb', line 56 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:
34 35 36 37 |
# File 'lib/rubygems/source/specific_file.rb', line 34 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:
28 29 30 31 32 |
# File 'lib/rubygems/source/specific_file.rb', line 28 def fetch_spec name # :nodoc: return @spec if name == @name raise Gem::Exception, "Unable to find '#{name}'" @spec end |
#load_specs(*a) ⇒ Object
:nodoc:
24 25 26 |
# File 'lib/rubygems/source/specific_file.rb', line 24 def load_specs *a # :nodoc: [@name] end |
#pretty_print(q) ⇒ Object
:nodoc:
39 40 41 42 43 44 |
# File 'lib/rubygems/source/specific_file.rb', line 39 def pretty_print q # :nodoc: q.group 2, '[Local:', ']' do q.breakable q.text @path end end |