Class: Bundler::Source::Rubygems

### Home Classes Methods

### In Files

- lib/bundler/source/rubygems.rb

### Parent

Object

### Methods

- ::from_lock
- ::new
- #==
- #add_remote
- #cache
- #cached!
- #eql?
- #hash
- #install
- #name
- #options
- #remote!
- #replace_remotes
- #specs
- #to_lock
- #to_s

### Files

- bundle
- bundle-config
- bundle-config.txt
- bundle-exec
- bundle-exec.txt
- bundle-install
- bundle-install.txt
- bundle-package
- bundle-package.txt
- bundle-platform
- bundle-platform.txt
- bundle-update
- bundle-update.txt
- bundle.txt
- gemfile.5.txt
- Executable
- Gemfile

### Class/Module Index

Quicksearch

- Bundler
- Bundler::BundlerError
- Bundler::CLI
- Bundler::Definition
- Bundler::DepProxy
- Bundler::Dependency
- Bundler::Deployment
- Bundler::Deprecate
- Bundler::DeprecatedError
- Bundler::Dsl
- Bundler::EndpointSpecification
- Bundler::Env
- Bundler::Environment
- Bundler::Fetcher
- Bundler::Fetcher::CertificateFailureError
- Bundler::Fetcher::FallbackError
- Bundler::Fetcher::SSLError
- Bundler::GemHelper
- Bundler::GemHelpers
- Bundler::GemInstaller
- Bundler::GemNotFound
- Bundler::GemfileError
- Bundler::GemfileNotFound
- Bundler::GemspecError
- Bundler::GitError
- Bundler::Graph
- Bundler::Graph::GraphVizClient
- Bundler::HTTPError
- Bundler::Index
- Bundler::Injector
- Bundler::InstallError
- Bundler::InstallHookError
- Bundler::Installer
- Bundler::InvalidOption
- Bundler::InvalidSpecSet
- Bundler::LazySpecification
- Bundler::LockfileError
- Bundler::LockfileParser
- Bundler::MarshalError
- Bundler::MatchPlatform
- Bundler::PathError
- Bundler::ProductionError
- Bundler::RemoteSpecification
- Bundler::Resolver
- Bundler::Resolver::SpecGroup
- Bundler::RubyDsl
- Bundler::RubyVersion
- Bundler::RubyVersionMismatch
- Bundler::RubygemsIntegration
- Bundler::RubygemsIntegration::AlmostModern
- Bundler::RubygemsIntegration::Ancient
- Bundler::RubygemsIntegration::Future
- Bundler::RubygemsIntegration::Gem
- Bundler::RubygemsIntegration::Gem::SourceIndex
- Bundler::RubygemsIntegration::Legacy
- Bundler::RubygemsIntegration::Modern
- Bundler::RubygemsIntegration::Transitional
- Bundler::Runtime
- Bundler::SecurityError
- Bundler::Settings
- Bundler::SharedHelpers
- Bundler::SimilarityDetector
- Bundler::Source
- Bundler::Source::Git
- Bundler::Source::Git::GitProxy
- Bundler::Source::Path
- Bundler::Source::Path::Installer
- Bundler::Source::Rubygems
- Bundler::SpecSet
- Bundler::SystemRubyVersion
- Bundler::UI
- Bundler::UI::RGProxy
- Bundler::UI::Shell
- Bundler::VersionConflict
- Gem
- Gem::Dependency
- Gem::Platform
- Gem::Requirement
- Gem::Specification
- Object

No matching classes.

# Bundler::Source::Rubygems

TODO: Refactor this class

### 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 48
    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 14
    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 124
    def add_remote(source)
      @remotes << normalize_uri(source)
    end

cache(spec) click to toggle source

    # File lib/bundler/source/rubygems.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/rubygems.rb, line 30
    def cached!
      @allow_cached = true
    end

eql?(o) click to toggle source

    # File lib/bundler/source/rubygems.rb, line 38
    def eql?(o)
      Rubygems === o
    end

Also aliased as: ==
hash() click to toggle source

    # File lib/bundler/source/rubygems.rb, line 34
    def hash
      Rubygems.hash
    end

install(spec) click to toggle source

    # File lib/bundler/source/rubygems.rb, line 70
    def install(spec)
      if installed_specs[spec].any?
        Bundler.ui.info "Using #{spec.name} (#{spec.version}) "
        return
      end

      Bundler.ui.info "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

      if spec.post_install_message
        Installer.post_install_messages[spec.name] = spec.post_install_message
      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"
    end

name() click to toggle source
Alias for: to_s
options() click to toggle source

    # File lib/bundler/source/rubygems.rb, line 44
    def options
      { "remotes" => @remotes.map { |r| r.to_s } }
    end

remote!() click to toggle source

    # File lib/bundler/source/rubygems.rb, line 26
    def remote!
      @allow_remote = true
    end

replace_remotes(source) click to toggle source

    # File lib/bundler/source/rubygems.rb, line 128
    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 66
    def specs
      @specs ||= fetch_specs
    end

to_lock() click to toggle source

    # File lib/bundler/source/rubygems.rb, line 54
    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 60
    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.