Class: Gem::Source::SpecificFile

Inherits:
Gem::Source show all
Defined in:
lib/rubygems/source_specific_file.rb

Constant Summary

Constants inherited from Gem::Source

FILES

Instance Attribute Summary collapse

Attributes inherited from Gem::Source

#uri

Instance Method Summary collapse

Methods inherited from Gem::Source

#<=>, #==, #api_uri, #cache_dir, #hash, #update_cache?

Constructor Details

#initialize(file) ⇒ SpecificFile

Returns a new instance of SpecificFile.



2
3
4
5
6
7
8
9
# File 'lib/rubygems/source_specific_file.rb', line 2

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

#specObject (readonly)

Returns the value of attribute spec



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

def spec
  @spec
end

Instance Method Details

#download(spec, dir = nil) ⇒ Object

Raises:



23
24
25
26
# File 'lib/rubygems/source_specific_file.rb', line 23

def download(spec, dir=nil)
  return @path if spec == @spec
  raise Gem::Exception, "Unable to download '#{spec.full_name}'"
end

#fetch_spec(name) ⇒ Object

Raises:



17
18
19
20
21
# File 'lib/rubygems/source_specific_file.rb', line 17

def fetch_spec(name)
  return @spec if name == @name
  raise Gem::Exception, "Unable to find '#{name}'"
  @spec
end

#load_specs(*a) ⇒ Object



13
14
15
# File 'lib/rubygems/source_specific_file.rb', line 13

def load_specs(*a)
  [@name]
end