Class: Bundler::GemSource

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

Defined Under Namespace

Classes: RubygemsRetardation

Instance Attribute Summary collapse

Attributes inherited from Source

#bundle

Instance Method Summary collapse

Constructor Details

#initialize(bundle, options) ⇒ GemSource

Returns a new instance of GemSource.

Raises:

  • (ArgumentError)


28
29
30
31
32
33
# File 'lib/bundler08/source.rb', line 28

def initialize(bundle, options)
  super
  @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.



26
27
28
# File 'lib/bundler08/source.rb', line 26

def uri
  @uri
end

Instance Method Details

#==(other) ⇒ Object



43
44
45
# File 'lib/bundler08/source.rb', line 43

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

#download(spec) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/bundler08/source.rb', line 53

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

  destination = bundle.gem_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



39
40
41
# File 'lib/bundler08/source.rb', line 39

def gems
  @specs ||= fetch_specs
end

#local?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/bundler08/source.rb', line 35

def local?
  false
end

#to_sObject



47
48
49
# File 'lib/bundler08/source.rb', line 47

def to_s
  @uri.to_s
end