Class/Module Index [+]

Quicksearch

Bundler::Source::Rubygems

Constants

API_REQUEST_LIMIT

Attributes

caches[R]
remotes[R]

Public Class Methods

from_lock(options) click to toggle source
# File lib/bundler/source/rubygems.rb, line 49
def self.from_lock(options)
  new(options)
end
new(options = {}) click to toggle source
# File lib/bundler/source/rubygems.rb, line 12
def initialize(options = {})
  @options = options
  @remotes = []
  @dependency_names = []
  @allow_remote = false
  @allow_cached = false
  @caches = [Bundler.app_cache, *Bundler.rubygems.gem_cache]

  Array(options["remotes"] || []).reverse_each{|r| add_remote(r) }
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 167
def add_remote(source)
  uri = normalize_uri(source)
  @remotes.unshift(uri) unless @remotes.include?(uri)
end
cache(spec, custom_path = nil) click to toggle source
# File lib/bundler/source/rubygems.rb, line 146
def cache(spec, custom_path = nil)
  if builtin_gem?(spec)
    cached_path = cached_built_in_gem(spec)
  else
    cached_path = cached_gem(spec)
  end
  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(custom_path))
end
cached!() click to toggle source
# File lib/bundler/source/rubygems.rb, line 27
def cached!
  @allow_cached = true
end
cached_built_in_gem(spec) click to toggle source
# File lib/bundler/source/rubygems.rb, line 158
def cached_built_in_gem(spec)
  cached_path = cached_path(spec)
  if cached_path.nil?
    remote_spec = remote_specs.search(spec).first
    cached_path = fetch_gem(remote_spec)
  end
  cached_path
end
can_lock?(spec) click to toggle source
# File lib/bundler/source/rubygems.rb, line 41
def can_lock?(spec)
  spec.source.is_a?(Rubygems)
end
eql?(o) click to toggle source
# File lib/bundler/source/rubygems.rb, line 35
def eql?(o)
  o.is_a?(Rubygems) && remotes_equal?(o.remotes)
end
Also aliased as: ==
hash() click to toggle source
# File lib/bundler/source/rubygems.rb, line 31
def hash
  @remotes.hash
end
install(spec) click to toggle source
# File lib/bundler/source/rubygems.rb, line 79
def install(spec)
  return ["Using #{version_message(spec)}", nil] if installed_specs[spec].any?

  # Download the gem to get the spec, because some specs that are returned
  # by rubygems.org are broken and wrong.
  if spec.source_uri
    # Check for this spec from other sources
    uris = [spec.source_uri]
    uris += source_uris_for_spec(spec)
    uris.compact!
    uris.uniq!
    Installer.ambiguous_gems << [spec.name, *uris] if uris.length > 1

    s = Bundler.rubygems.spec_from_gem(fetch_gem(spec), Bundler.settings["trust-policy"])
    spec.__swap__(s)
  end

  path = cached_gem(spec)
  if Bundler.requires_sudo?
    install_path = Bundler.tmp(spec.full_name)
    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.rubygems.repository_subdirectories.each do |name|
      src = File.join(install_path, name, "*")
      dst = File.join(Bundler.rubygems.gem_dir, name)
      if name == "extensions" && Dir.glob(src).any?
        src = File.join(src, "*/*")
        ext_src = Dir.glob(src).first
        ext_src.gsub!(src[0..-6], '')
        dst = File.dirname(File.join(dst, ext_src))
      end
      Bundler.mkdir_p dst
      Bundler.sudo "cp -R #{src} #{dst}" if Dir[src].any?
    end

    spec.executables.each do |exe|
      Bundler.mkdir_p Bundler.system_bindir
      Bundler.sudo "cp -R #{install_path}/bin/#{exe} #{Bundler.system_bindir}/"
    end
  end

  spec.loaded_from = "#{Bundler.rubygems.gem_dir}/specifications/#{spec.full_name}.gemspec"
  installed_spec.loaded_from = spec.loaded_from
  ["Installing #{version_message(spec)}", spec.post_install_message]
ensure
  if install_path && Bundler.requires_sudo?
    FileUtils.remove_entry_secure(install_path)
  end
end
name() click to toggle source
Alias for: to_s
options() click to toggle source
# File lib/bundler/source/rubygems.rb, line 45
def options
  { "remotes" => @remotes.map { |r| r.to_s } }
end
remote!() click to toggle source
# File lib/bundler/source/rubygems.rb, line 23
def remote!
  @allow_remote = true
end
replace_remotes(other_remotes) click to toggle source
# File lib/bundler/source/rubygems.rb, line 172
def replace_remotes(other_remotes)
  return false if other_remotes == @remotes

  @remotes = []
  other_remotes.reverse_each do |r|
    add_remote r.to_s
  end
end
specs() click to toggle source
# File lib/bundler/source/rubygems.rb, line 67
def specs
  @specs ||= begin
    # remote_specs usually generates a way larger Index than the other
    # sources, and large_idx.use small_idx is way faster than
    # small_idx.use large_idx.
    idx = @allow_remote ? remote_specs.dup : Index.new
    idx.use(cached_specs, :override_dupes) if @allow_cached || @allow_remote
    idx.use(installed_specs, :override_dupes)
    idx
  end
end
to_lock() click to toggle source
# File lib/bundler/source/rubygems.rb, line 53
def to_lock
  out = "GEM\n"
  out << remotes.map { |remote|
    "  remote: #{suppress_configured_credentials remote}\n"
  }.join
  out << "  specs:\n"
end
to_s() click to toggle source
# File lib/bundler/source/rubygems.rb, line 61
def to_s
  remote_names = self.remotes.map { |r| r.to_s }.join(', ')
  "rubygems repository #{remote_names}"
end
Also aliased as: name
unmet_deps() click to toggle source
# File lib/bundler/source/rubygems.rb, line 181
def unmet_deps
  if @allow_remote && api_fetchers.any?
    remote_specs.unmet_dependency_names
  else
    []
  end
end

Protected Instance Methods

source_uris_for_spec(spec) click to toggle source
# File lib/bundler/source/rubygems.rb, line 191
def source_uris_for_spec(spec)
  specs.search_all(spec.name).map{|s| s.source_uri }
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.