Class: Bundler::GemSource

Inherits:
Source
  • Object
show all
Defined in:
lib/bundler/source.rb

Defined Under Namespace

Classes: RubygemsRetardation

Instance Attribute Summary collapse

Attributes inherited from Source

#local, #repository

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ GemSource

Returns a new instance of GemSource.

Raises:

  • (ArgumentError)


26
27
28
29
30
# File 'lib/bundler/source.rb', line 26

def initialize(options)
  @uri = options[:uri]
  @uri = URI.parse(@uri) unless @uri.is_a?(URI)
  raise ArgumentError, "The source must be an absolute URI" unless @uri.absolute?
end

Instance Attribute Details

#uriObject (readonly)

Returns the value of attribute uri.



24
25
26
# File 'lib/bundler/source.rb', line 24

def uri
  @uri
end

Instance Method Details

#==(other) ⇒ Object



40
41
42
# File 'lib/bundler/source.rb', line 40

def ==(other)
  uri == other.uri
end

#can_be_local?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/bundler/source.rb', line 32

def can_be_local?
  false
end

#download(spec) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/bundler/source.rb', line 50

def download(spec)
  Bundler.logger.info "Downloading #{spec.full_name}.gem"

  destination = repository.path

  unless destination.writable?
    raise RubygemsRetardation, "destination: #{destination} is not writable"
  end

  # Download the gem
  Gem::RemoteFetcher.fetcher.download(spec, uri, destination)

  # Re-read the gemspec from the downloaded gem to correct
  # any errors that were present in the Rubyforge specification.
  new_spec = Gem::Format.from_file_by_path(destination.join('cache', "#{spec.full_name}.gem")).spec
  spec.__swap__(new_spec)
end

#gemsObject



36
37
38
# File 'lib/bundler/source.rb', line 36

def gems
  @specs ||= fetch_specs
end

#to_sObject



44
45
46
# File 'lib/bundler/source.rb', line 44

def to_s
  @uri.to_s
end