### Home Classes Methods

### In Files

- lib/bundler/fetcher.rb
- lib/bundler/fetcher/base.rb
- lib/bundler/fetcher/compact_index.rb
- lib/bundler/fetcher/dependency.rb
- lib/bundler/fetcher/downloader.rb
- lib/bundler/fetcher/index.rb

### Parent

Object

### Namespace

- CLASS Bundler::Fetcher::AuthenticationRequiredError
- CLASS Bundler::Fetcher::BadAuthenticationError
- CLASS Bundler::Fetcher::Base
- CLASS Bundler::Fetcher::CertificateFailureError
- CLASS Bundler::Fetcher::CompactIndex
- CLASS Bundler::Fetcher::Dependency
- CLASS Bundler::Fetcher::Downloader
- CLASS Bundler::Fetcher::FallbackError
- CLASS Bundler::Fetcher::Index
- CLASS Bundler::Fetcher::NetworkDownError
- CLASS Bundler::Fetcher::SSLError

### Methods

- ::new
- #fetch_spec
- #fetchers
- #http_proxy
- #inspect
- #specs
- #specs_with_retry
- #uri
- #use_api
- #user_agent

### Class/Module Index

Quicksearch

- Bundler
- Bundler::APIResponseMismatchError
- Bundler::BuildMetadata
- Bundler::BundlerError
- Bundler::CLI
- Bundler::CLI::Add
- Bundler::CLI::Binstubs
- Bundler::CLI::Cache
- Bundler::CLI::Check
- Bundler::CLI::Clean
- Bundler::CLI::Common
- Bundler::CLI::Config
- Bundler::CLI::Console
- Bundler::CLI::Doctor
- Bundler::CLI::Exec
- Bundler::CLI::Gem
- Bundler::CLI::Info
- Bundler::CLI::Init
- Bundler::CLI::Inject
- Bundler::CLI::Install
- Bundler::CLI::Issue
- Bundler::CLI::List
- Bundler::CLI::Lock
- Bundler::CLI::Open
- Bundler::CLI::Outdated
- Bundler::CLI::Package
- Bundler::CLI::Platform
- Bundler::CLI::Plugin
- Bundler::CLI::Pristine
- Bundler::CLI::Remove
- Bundler::CLI::Show
- Bundler::CLI::Update
- Bundler::CLI::Viz
- Bundler::CompactIndexClient
- Bundler::CompactIndexClient::Cache
- Bundler::CompactIndexClient::Error
- Bundler::CompactIndexClient::Updater
- Bundler::CompactIndexClient::Updater::MisMatchedChecksumError
- Bundler::CurrentRuby
- Bundler::CyclicDependencyError
- Bundler::Definition
- Bundler::DepProxy
- Bundler::Dependency
- Bundler::Deployment
- Bundler::Deprecate
- Bundler::DeprecatedError
- Bundler::Dsl
- Bundler::Dsl::DSLError
- Bundler::EndpointSpecification
- Bundler::Env
- Bundler::EnvironmentPreserver
- Bundler::FeatureFlag
- Bundler::Fetcher
- Bundler::Fetcher::AuthenticationRequiredError
- Bundler::Fetcher::BadAuthenticationError
- Bundler::Fetcher::Base
- Bundler::Fetcher::CertificateFailureError
- Bundler::Fetcher::CompactIndex
- Bundler::Fetcher::Dependency
- Bundler::Fetcher::Downloader
- Bundler::Fetcher::FallbackError
- Bundler::Fetcher::Index
- Bundler::Fetcher::NetworkDownError
- Bundler::Fetcher::SSLError
- Bundler::FileUtils
- Bundler::FileUtils::DryRun
- Bundler::FileUtils::LowMethods
- Bundler::FileUtils::NoWrite
- Bundler::FileUtils::StreamUtils_
- Bundler::FileUtils::Verbose
- Bundler::FriendlyErrors
- Bundler::GemHelper
- Bundler::GemHelpers
- Bundler::GemHelpers::PlatformMatch
- Bundler::GemInstaller
- Bundler::GemNotFound
- Bundler::GemRemoteFetcher
- Bundler::GemRequireError
- Bundler::GemVersionPromoter
- Bundler::Gemdeps
- Bundler::GemfileError
- Bundler::GemfileEvalError
- Bundler::GemfileLockNotFound
- Bundler::GemfileNotFound
- Bundler::GemspecError
- Bundler::GenericSystemCallError
- Bundler::GitError
- Bundler::Graph
- Bundler::Graph::GraphVizClient
- Bundler::HTTPError
- Bundler::Index
- Bundler::Injector
- Bundler::InstallError
- Bundler::InstallHookError
- Bundler::Installer
- Bundler::InvalidOption
- Bundler::LazySpecification
- Bundler::LazySpecification::Identifier
- Bundler::LockfileError
- Bundler::LockfileGenerator
- Bundler::LockfileParser
- Bundler::MarshalError
- Bundler::MatchPlatform
- Bundler::MirrorSockets
- Bundler::Molinillo
- Bundler::Molinillo::CircularDependencyError
- Bundler::Molinillo::Compatibility
- Bundler::Molinillo::Delegates
- Bundler::Molinillo::Delegates::ResolutionState
- Bundler::Molinillo::Delegates::SpecificationProvider
- Bundler::Molinillo::DependencyGraph
- Bundler::Molinillo::DependencyGraph::Action
- Bundler::Molinillo::DependencyGraph::AddEdgeNoCircular
- Bundler::Molinillo::DependencyGraph::DeleteEdge
- Bundler::Molinillo::DependencyGraph::DetachVertexNamed
- Bundler::Molinillo::DependencyGraph::Log
- Bundler::Molinillo::DependencyGraph::Tag
- Bundler::Molinillo::DependencyGraph::Vertex
- Bundler::Molinillo::DependencyState
- Bundler::Molinillo::NoSuchDependencyError
- Bundler::Molinillo::PossibilityState
- Bundler::Molinillo::ResolutionState
- Bundler::Molinillo::Resolver
- Bundler::Molinillo::Resolver::Resolution
- Bundler::Molinillo::Resolver::Resolution::Conflict
- Bundler::Molinillo::Resolver::Resolution::PossibilitySet
- Bundler::Molinillo::Resolver::Resolution::UnwindDetails
- Bundler::Molinillo::ResolverError
- Bundler::Molinillo::SpecificationProvider
- Bundler::Molinillo::UI
- Bundler::Molinillo::VersionConflict
- Bundler::NoSpaceOnDeviceError
- Bundler::OperationNotSupportedError
- Bundler::ParallelInstaller
- Bundler::ParallelInstaller::SpecInstallation
- Bundler::PathError
- Bundler::PermissionError
- Bundler::Persistent
- Bundler::Persistent::Net
- Bundler::Persistent::Net::HTTP
- Bundler::Persistent::Net::HTTP::Persistent
- Bundler::Persistent::Net::HTTP::Persistent::Error
- Bundler::Persistent::Net::HTTP::Persistent::SSLReuse
- Bundler::PersistentHTTP
- Bundler::Plugin
- Bundler::Plugin::API
- Bundler::Plugin::API::Source
- Bundler::Plugin::DSL
- Bundler::Plugin::DSL::PluginGemfileError
- Bundler::Plugin::Events
- Bundler::Plugin::Index
- Bundler::Plugin::Index::CommandConflict
- Bundler::Plugin::Index::SourceConflict
- Bundler::Plugin::Installer
- Bundler::Plugin::Installer::Git
- Bundler::Plugin::Installer::Rubygems
- Bundler::Plugin::MalformattedPlugin
- Bundler::Plugin::SourceList
- Bundler::Plugin::UndefinedCommandError
- Bundler::Plugin::UnknownSourceError
- Bundler::PluginError
- Bundler::ProcessLock
- Bundler::ProductionError
- Bundler::RemoteSpecification
- Bundler::Resolver
- Bundler::Resolver::SpecGroup
- Bundler::Retry
- Bundler::RubyDsl
- Bundler::RubyGemsGemInstaller
- Bundler::RubyVersion
- Bundler::RubyVersionMismatch
- Bundler::RubygemsIntegration
- Bundler::RubygemsIntegration::::Kernel
- Bundler::RubygemsIntegration::AlmostModern
- Bundler::RubygemsIntegration::Ancient
- Bundler::RubygemsIntegration::Future
- Bundler::RubygemsIntegration::Future::Gem
- Bundler::RubygemsIntegration::Gem
- Bundler::RubygemsIntegration::Legacy
- Bundler::RubygemsIntegration::Legacy::Gem::SourceIndex
- Bundler::RubygemsIntegration::Modern
- Bundler::RubygemsIntegration::MoreFuture
- Bundler::RubygemsIntegration::MoreModern
- Bundler::RubygemsIntegration::Transitional
- Bundler::Runtime
- Bundler::SecurityError
- Bundler::Settings
- Bundler::Settings::Mirror
- Bundler::Settings::MirrorConfig
- Bundler::Settings::Mirrors
- Bundler::Settings::TCPSocketProbe
- Bundler::Settings::Validator
- Bundler::Settings::Validator::Rule
- Bundler::SharedHelpers
- Bundler::SimilarityDetector
- Bundler::SocketAddress
- Bundler::Source
- Bundler::Source::Gemspec
- Bundler::Source::Git
- Bundler::Source::Git::GitCommandError
- Bundler::Source::Git::GitNotAllowedError
- Bundler::Source::Git::GitNotInstalledError
- Bundler::Source::Git::GitProxy
- Bundler::Source::Git::MissingGitRevisionError
- Bundler::Source::Metadata
- Bundler::Source::Path
- Bundler::Source::Path::Installer
- Bundler::Source::Rubygems
- Bundler::Source::Rubygems::Remote
- Bundler::SourceList
- Bundler::SpecSet
- Bundler::Standalone
- Bundler::StubSpecification
- Bundler::SudoNotPermittedError
- Bundler::TemporaryResourceError
- Bundler::Thor
- Bundler::Thor::Actions
- Bundler::Thor::Actions::CapturableERB
- Bundler::Thor::Actions::ClassMethods
- Bundler::Thor::AmbiguousCommandError
- Bundler::Thor::AmbiguousTaskError
- Bundler::Thor::Base
- Bundler::Thor::Base::ClassMethods
- Bundler::Thor::Command
- Bundler::Thor::CoreExt
- Bundler::Thor::CoreExt::OrderedHash
- Bundler::Thor::DynamicCommand
- Bundler::Thor::DynamicTask
- Bundler::Thor::Error
- Bundler::Thor::Group
- Bundler::Thor::HiddenCommand
- Bundler::Thor::HiddenTask
- Bundler::Thor::Invocation
- Bundler::Thor::Invocation::ClassMethods
- Bundler::Thor::InvocationError
- Bundler::Thor::LineEditor
- Bundler::Thor::LineEditor::Basic
- Bundler::Thor::LineEditor::Readline
- Bundler::Thor::LineEditor::Readline::PathCompletion
- Bundler::Thor::MalformattedArgumentError
- Bundler::Thor::RakeCompat
- Bundler::Thor::RequiredArgumentMissingError
- Bundler::Thor::Shell
- Bundler::Thor::Shell::Basic
- Bundler::Thor::Shell::Color
- Bundler::Thor::Shell::HTML
- Bundler::Thor::Task
- Bundler::Thor::UndefinedCommandError
- Bundler::Thor::UndefinedTaskError
- Bundler::Thor::UnknownArgumentError
- Bundler::Thor::Util
- Bundler::ThreadCreationError
- Bundler::UI
- Bundler::UI::RGProxy
- Bundler::UI::Shell
- Bundler::UI::Silent
- Bundler::URICredentialsFilter
- Bundler::VersionConflict
- Bundler::VersionRanges
- Bundler::VersionRanges::ReqR
- Bundler::VirtualProtocolError
- Bundler::Worker
- Bundler::Worker::WrappedException
- Bundler::YAMLSerializer
- Bundler::YamlSyntaxError
- Gem
- Gem::Dependency
- Gem::Platform
- Gem::Requirement
- Gem::Specification
- Net
- Object

No matching classes.

# Bundler::Fetcher

Handles all the fetching with the rubygems server

### Constants

FAIL_ERRORS
FETCHERS
HTTP_ERRORS
NET_ERRORS

  Exceptions classes that should bypass retry attempts. If your password didn’t work the first time, it’s not going to the third time.

### Attributes

api_timeout[RW]
disable_endpoint[RW]
max_retries[RW]
redirect_limit[RW]

### Public Class Methods

new(remote) click to toggle source

    # File lib/bundler/fetcher.rb, line 81
    def initialize(remote)
      @remote = remote

      Socket.do_not_reverse_lookup = true
      connection # create persistent connection
    end

### Public Instance Methods

fetch_spec(spec) click to toggle source

fetch a gem specification

    # File lib/bundler/fetcher.rb, line 93
    def fetch_spec(spec)
      spec -= [nil, "ruby", ""]
      spec_file_name = "#{spec.join "-"}.gemspec"

      uri = URI.parse("#{remote_uri}#{Gem::MARSHAL_SPEC_DIR}#{spec_file_name}.rz")
      if uri.scheme == "file"
        Bundler.load_marshal Bundler.rubygems.inflate(Gem.read_binary(uri.path))
      elsif cached_spec_path = gemspec_cached_path(spec_file_name)
        Bundler.load_gemspec(cached_spec_path)
      else
        Bundler.load_marshal Bundler.rubygems.inflate(downloader.fetch(uri).body)
      end
    rescue MarshalError
      raise HTTPError, "Gemspec #{spec} contained invalid data.\n"          "Your network or your gem server is probably having issues right now."
    end

fetchers() click to toggle source

    # File lib/bundler/fetcher.rb, line 202
    def fetchers
      @fetchers ||= FETCHERS.map {|f| f.new(downloader, @remote, uri) }
    end

http_proxy() click to toggle source

    # File lib/bundler/fetcher.rb, line 206
    def http_proxy
      return unless uri = connection.proxy_uri
      uri.to_s
    end

inspect() click to toggle source

    # File lib/bundler/fetcher.rb, line 211
    def inspect
      "#<#{self.class}:0x#{object_id} uri=#{uri}>"
    end

specs(gem_names, source) click to toggle source

return the specs in the bundler format as an index

    # File lib/bundler/fetcher.rb, line 118
    def specs(gem_names, source)
      old = Bundler.rubygems.sources
      index = Bundler::Index.new

      if Bundler::Fetcher.disable_endpoint
        @use_api = false
        specs = fetchers.last.specs(gem_names)
      else
        specs = []
        fetchers.shift until fetchers.first.available? || fetchers.empty?
        fetchers.dup.each do |f|
          break unless f.api_fetcher? && !gem_names || !specs = f.specs(gem_names)
          fetchers.delete(f)
        end
        @use_api = false if fetchers.none?(&:api_fetcher?)
      end

      specs.each do |name, version, platform, dependencies, metadata|
        next if name == "bundler"
        spec = if dependencies
          EndpointSpecification.new(name, version, platform, dependencies, metadata)
        else
          RemoteSpecification.new(name, version, platform, self)
        end
        spec.source = source
        spec.remote = @remote
        index << spec
      end

      index
    rescue CertificateFailureError
      Bundler.ui.info "" if gem_names && use_api # newline after dots
      raise
    ensure
      Bundler.rubygems.sources = old
    end

specs_with_retry(gem_names, source) click to toggle source

return the specs in the bundler format as an index with retries

    # File lib/bundler/fetcher.rb, line 111
    def specs_with_retry(gem_names, source)
      Bundler::Retry.new("fetcher", FAIL_ERRORS).attempts do
        specs(gem_names, source)
      end
    end

uri() click to toggle source

    # File lib/bundler/fetcher.rb, line 88
    def uri
      @remote.anonymized_uri
    end

use_api() click to toggle source

    # File lib/bundler/fetcher.rb, line 155
    def use_api
      return @use_api if defined?(@use_api)

      fetchers.shift until fetchers.first.available?

      @use_api = if remote_uri.scheme == "file" || Bundler::Fetcher.disable_endpoint
        false
      else
        fetchers.first.api_fetcher?
      end
    end

user_agent() click to toggle source

    # File lib/bundler/fetcher.rb, line 167
    def user_agent
      @user_agent ||= begin
        ruby = Bundler::RubyVersion.system

        agent = String.new("bundler/#{Bundler::VERSION}")
        agent << " rubygems/#{Gem::VERSION}"
        agent << " ruby/#{ruby.versions_string(ruby.versions)}"
        agent << " (#{ruby.host})"
        agent << " command/#{ARGV.first}"

        if ruby.engine != "ruby"
          # engine_version raises on unknown engines
          engine_version = begin
                             ruby.engine_versions
                           rescue RuntimeError
                             "???"
                           end
          agent << " #{ruby.engine}/#{ruby.versions_string(engine_version)}"
        end

        agent << " options/#{Bundler.settings.all.join(",")}"

        agent << " ci/#{cis.join(",")}" if cis.any?

        # add a random ID so we can consolidate runs server-side
        agent << " " << SecureRandom.hex(8)

        # add any user agent strings set in the config
        extra_ua = Bundler.settings[:user_agent]
        agent << " " << extra_ua if extra_ua

        agent
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.