Parent

Bundler::Source::Rubygems

TODO: Refactor this class

Attributes

remotes[R]

Public Class Methods

from_lock(options) click to toggle source
# File lib/bundler/source.rb, line 47
def self.from_lock(options)
  s = new(options)
  Array(options["remote"]).each { |r| s.add_remote(r) }
  s
end
new(options = {}) click to toggle source
# File lib/bundler/source.rb, line 15
def initialize(options = {})
  @options = options
  @remotes = (options["remotes"] || []).map { |r| normalize_uri(r) }
  @allow_remote = false
  @allow_cached = false
  # Hardcode the paths for now
  @caches = [ Bundler.app_cache ] + Gem.path.map { |p| File.expand_path("#{p}/cache") }
  @spec_fetch_map = {}
end

Public Instance Methods

==(o) click to toggle source
Alias for: eql?
add_remote(source) click to toggle source
# File lib/bundler/source.rb, line 124
def add_remote(source)
  @remotes << normalize_uri(source)
end
cache(spec) click to toggle source
# File lib/bundler/source.rb, line 116
def cache(spec)
  cached_path = cached_gem(spec)
  raise GemNotFound, "Missing gem file '#{spec.full_name}.gem'." unless cached_path
  return if File.dirname(cached_path) == Bundler.app_cache.to_s
  Bundler.ui.info "  * #{File.basename(cached_path)}"
  FileUtils.cp(cached_path, Bundler.app_cache)
end
cached!() click to toggle source
# File lib/bundler/source.rb, line 29
def cached!
  @allow_cached = true
end
eql?(o) click to toggle source
# File lib/bundler/source.rb, line 37
def eql?(o)
  Rubygems === o
end
Also aliased as: ==
fetch(spec) click to toggle source
# File lib/bundler/source.rb, line 69
def fetch(spec)
  spec, uri = @spec_fetch_map[spec.full_name]
  if spec
    path = download_gem_from_uri(spec, uri)
    s = Gem::Format.from_file_by_path(path).spec
    spec.__swap__(s)
  end
end
hash() click to toggle source
# File lib/bundler/source.rb, line 33
def hash
  Rubygems.hash
end
install(spec) click to toggle source
# File lib/bundler/source.rb, line 78
def install(spec)
  path = cached_gem(spec)

  if installed_specs[spec].any?
    Bundler.ui.info "Using #{spec.name} (#{spec.version}) "
    return
  end

  Bundler.ui.info "Installing #{spec.name} (#{spec.version}) "

  install_path = Bundler.requires_sudo? ? Bundler.tmp : Gem.dir
  options = { :install_dir         => install_path,
              :ignore_dependencies => true,
              :wrappers            => true,
              :env_shebang         => true }
  options.merge!(:bin_dir => "#{install_path}/bin") unless spec.executables.nil? || spec.executables.empty?

  installer = Gem::Installer.new path, options
  installer.install

  # SUDO HAX
  if Bundler.requires_sudo?
    sudo "mkdir -p #{Gem.dir}/gems #{Gem.dir}/specifications"
    sudo "cp -R #{Bundler.tmp}/gems/#{spec.full_name} #{Gem.dir}/gems/"
    sudo "cp -R #{Bundler.tmp}/specifications/#{spec.full_name}.gemspec #{Gem.dir}/specifications/"
    spec.executables.each do |exe|
      sudo "mkdir -p #{Gem.bindir}"
      sudo "cp -R #{Bundler.tmp}/bin/#{exe} #{Gem.bindir}"
    end
  end

  spec.loaded_from = "#{Gem.dir}/specifications/#{spec.full_name}.gemspec"
end
merge_remotes(source) click to toggle source
# File lib/bundler/source.rb, line 128
def merge_remotes(source)
  @remotes = []
  source.remotes.each do |r|
    add_remote r.to_s
  end
end
name() click to toggle source
Alias for: to_s
options() click to toggle source
# File lib/bundler/source.rb, line 43
def options
  { "remotes" => @remotes.map { |r| r.to_s } }
end
remote!() click to toggle source
# File lib/bundler/source.rb, line 25
def remote!
  @allow_remote = true
end
specs() click to toggle source
# File lib/bundler/source.rb, line 65
def specs
  @specs ||= fetch_specs
end
sudo(str) click to toggle source
# File lib/bundler/source.rb, line 112
def sudo(str)
  Bundler.sudo(str)
end
to_lock() click to toggle source
# File lib/bundler/source.rb, line 53
def to_lock
  out = "GEM\n"
  out << remotes.map {|r| "  remote: #{r}\n" }.join
  out << "  specs:\n"
end
to_s() click to toggle source
# File lib/bundler/source.rb, line 59
def to_s
  remote_names = self.remotes.map { |r| r.to_s }.join(', ')
  "rubygems repository #{remote_names}"
end
Also aliased as: name

[Validate]

Generated with the Darkfish Rdoc Generator 2.