summaryrefslogtreecommitdiff
path: root/lib/rubygems/source/specific_file.rb
blob: d296e617cc9648c5b3eb02d3ffba8e9ef1f3d945 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class Gem::Source::SpecificFile < Gem::Source
  def initialize(file)
    @uri = nil
    @path = ::File.expand_path(file)

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

  attr_reader :spec

  def load_specs(*a)
    [@name]
  end

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

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

end