Parent

Class/Module Index [+]

Quicksearch

Bundler::Source::Rubygems

Constants

API_REQUEST_LIMIT

Attributes

caches[R]
dependency_names[RW]
remotes[R]

Public Class Methods

from_lock(options) click to toggle source
# File lib/bundler/source/rubygems.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/rubygems.rb, line 13
def initialize(options = {})
  @options = options
  @remotes = (options["remotes"] || []).map { |r| normalize_uri(r) }
  @fetchers = {}
  @dependency_names = []
  @allow_remote = false
  @allow_cached = false

  @caches = [ Bundler.app_cache ] +
    Bundler.rubygems.gem_path.map{|p| File.expand_path("#{p}/cache") }
end

Public Instance Methods

==(o) click to toggle source
Alias for: eql?
add_remote(source) click to toggle source
# File lib/bundler/source/rubygems.rb, line 127
def add_remote(source)
  @remotes << normalize_uri(source)
end
cache(spec) click to toggle source
# File lib/bundler/source/rubygems.rb, line 119
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/rubygems.rb, line 29
def cached!
  @allow_cached = true
end
eql?(o) click to toggle source
# File lib/bundler/source/rubygems.rb, line 37
def eql?(o)
  Rubygems === o
end
Also aliased as: ==
hash() click to toggle source
# File lib/bundler/source/rubygems.rb, line 33
def hash
  Rubygems.hash
end
install(spec) click to toggle source
# File lib/bundler/source/rubygems.rb, line 69
def install(spec)
  if installed_specs[spec].any?
    return ["Using #{spec.name} (#{spec.version})", nil]
  end

  # Download the gem to get the spec, because some specs that are returned
  # by rubygems.org are broken and wrong.
  if spec.source_uri
    path = Fetcher.download_gem_from_uri(spec, spec.source_uri)
    s = Bundler.rubygems.spec_from_gem(path, Bundler.settings["trust-policy"])
    spec.__swap__(s)
  end

  install_message = "Installing #{spec.name} (#{spec.version})"
  path = cached_gem(spec)
  if Bundler.requires_sudo?
    install_path = Bundler.tmp
    bin_path     = install_path.join("bin")
  else
    install_path = Bundler.rubygems.gem_dir
    bin_path     = Bundler.system_bindir
  end

  installed_spec = nil
  Bundler.rubygems.preserve_paths do
    installed_spec = Bundler::GemInstaller.new(path,
      :install_dir         => install_path.to_s,
      :bin_dir             => bin_path.to_s,
      :ignore_dependencies => true,
      :wrappers            => true,
      :env_shebang         => true
    ).install
  end

  # SUDO HAX
  if Bundler.requires_sudo?
    Bundler.mkdir_p "#{Bundler.rubygems.gem_dir}/gems"
    Bundler.mkdir_p "#{Bundler.rubygems.gem_dir}/specifications"
    Bundler.sudo "cp -R #{Bundler.tmp}/gems/#{spec.full_name} #{Bundler.rubygems.gem_dir}/gems/"
    Bundler.sudo "cp -R #{Bundler.tmp}/specifications/#{spec.full_name}.gemspec #{Bundler.rubygems.gem_dir}/specifications/"
    spec.executables.each do |exe|
      Bundler.mkdir_p Bundler.system_bindir
      Bundler.sudo "cp -R #{Bundler.tmp}/bin/#{exe} #{Bundler.system_bindir}"
    end
  end
  installed_spec.loaded_from = "#{Bundler.rubygems.gem_dir}/specifications/#{spec.full_name}.gemspec"
  spec.loaded_from = "#{Bundler.rubygems.gem_dir}/specifications/#{spec.full_name}.gemspec"
  [install_message, spec.post_install_message]
end
name() click to toggle source
Alias for: to_s
options() click to toggle source
# File lib/bundler/source/rubygems.rb, line 43
def options
  { "remotes" => @remotes.map { |r| r.to_s } }
end
remote!() click to toggle source
# File lib/bundler/source/rubygems.rb, line 25
def remote!
  @allow_remote = true
end
replace_remotes(source) click to toggle source
# File lib/bundler/source/rubygems.rb, line 131
def replace_remotes(source)
  return false if source.remotes == @remotes

  @remotes = []
  source.remotes.each do |r|
    add_remote r.to_s
  end

  true
end
specs() click to toggle source
# File lib/bundler/source/rubygems.rb, line 65
def specs
  @specs ||= fetch_specs
end
to_lock() click to toggle source
# File lib/bundler/source/rubygems.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/rubygems.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.