### Home Classes Methods

### In Files

- lib/bundler/index.rb

### Parent

Object

### Methods

- ::build
- ::new
- ::sort_specs
- #<<
- #==
- #[]
- #add_source
- #dependencies_eql?
- #dependency_names
- #each
- #empty?
- #initialize_copy
- #inspect
- #local_search
- #search
- #search_all
- #size
- #sort_specs
- #spec_names
- #unmet_dependency_names
- #unsorted_search
- #use

### Included Modules

- Enumerable

### 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
- Net::HTTP
- Net::HTTP::Persistent
- Object

No matching classes.

# Bundler::Index

### Constants

EMPTY_SEARCH
NULL
RUBY

### Attributes

all_specs[R]
sources[R]
specs[R]

### Public Class Methods

build() click to toggle source

    # File lib/bundler/index.rb, line 9
    def self.build
      i = new
      yield i
      i
    end

new() click to toggle source

    # File lib/bundler/index.rb, line 21
    def initialize
      @sources = []
      @cache = {}
      @specs = Hash.new {|h, k| h[k] = {} }
      @all_specs = Hash.new {|h, k| h[k] = EMPTY_SEARCH }
    end

sort_specs(specs) click to toggle source

    # File lib/bundler/index.rb, line 80
    def self.sort_specs(specs)
      specs.sort_by do |s|
        platform_string = s.platform.to_s
        [s.version, platform_string == RUBY ? NULL : platform_string]
      end
    end

### Public Instance Methods

<<(spec) click to toggle source

    # File lib/bundler/index.rb, line 104
    def <<(spec)
      @specs[spec.name][spec.full_name] = spec
      spec
    end

==(other) click to toggle source

Whether all the specs in self are in other TODO: rename to include?

    # File lib/bundler/index.rb, line 163
    def ==(other)
      all? do |spec|
        other_spec = other[spec].first
        other_spec && dependencies_eql?(spec, other_spec) && spec.source == other_spec.source
      end
    end

[](query, base = nil) click to toggle source
Alias for: search
add_source(index) click to toggle source

    # File lib/bundler/index.rb, line 176
    def add_source(index)
      raise ArgumentError, "Source must be an index, not #{index.class}" unless index.is_a?(Index)
      @sources << index
      @sources.uniq! # need to use uniq! here instead of checking for the item before adding
    end

dependencies_eql?(spec, other_spec) click to toggle source

    # File lib/bundler/index.rb, line 170
    def dependencies_eql?(spec, other_spec)
      deps       = spec.dependencies.select {|d| d.type != :development }
      other_deps = other_spec.dependencies.select {|d| d.type != :development }
      Set.new(deps) == Set.new(other_deps)
    end

dependency_names() click to toggle source

    # File lib/bundler/index.rb, line 131
    def dependency_names
      names = []
      each do |spec|
        spec.dependencies.each do |dep|
          next if dep.type == :development
          names << dep.name
        end
      end
      names.uniq
    end

each(&blk) click to toggle source

    # File lib/bundler/index.rb, line 109
    def each(&blk)
      return enum_for(:each) unless blk
      specs.values.each do |spec_sets|
        spec_sets.values.each(&blk)
      end
      sources.each {|s| s.each(&blk) }
      self
    end

empty?() click to toggle source

    # File lib/bundler/index.rb, line 46
    def empty?
      each { return false }
      true
    end

initialize_copy(o) click to toggle source

    # File lib/bundler/index.rb, line 28
    def initialize_copy(o)
      @sources = o.sources.dup
      @cache = {}
      @specs = Hash.new {|h, k| h[k] = {} }
      @all_specs = Hash.new {|h, k| h[k] = EMPTY_SEARCH }

      o.specs.each do |name, hash|
        @specs[name] = hash.dup
      end
      o.all_specs.each do |name, array|
        @all_specs[name] = array.dup
      end
    end

inspect() click to toggle source

    # File lib/bundler/index.rb, line 42
    def inspect
      "#<#{self.class}:0x#{object_id} sources=#{sources.map(&:inspect)} specs.size=#{specs.size}>"
    end

local_search(query, base = nil) click to toggle source

    # File lib/bundler/index.rb, line 91
    def local_search(query, base = nil)
      case query
      when Gem::Specification, RemoteSpecification, LazySpecification, EndpointSpecification then search_by_spec(query)
      when String then specs_by_name(query)
      when Gem::Dependency then search_by_dependency(query, base)
      when DepProxy then search_by_dependency(query.dep, base)
      else
        raise "You can't search for a #{query.inspect}."
      end
    end

search(query, base = nil) click to toggle source

Search this index’s specs, and any source indexes that this index knows about, returning all of the results.

    # File lib/bundler/index.rb, line 61
    def search(query, base = nil)
      sort_specs(unsorted_search(query, base))
    end

Also aliased as: []
search_all(name) click to toggle source

    # File lib/bundler/index.rb, line 51
    def search_all(name)
      all_matches = local_search(name) + @all_specs[name]
      @sources.each do |source|
        all_matches.concat(source.search_all(name))
      end
      all_matches
    end

size() click to toggle source

    # File lib/bundler/index.rb, line 155
    def size
      @sources.inject(@specs.size) do |size, source|
        size += source.size
      end
    end

sort_specs(specs) click to toggle source

    # File lib/bundler/index.rb, line 87
    def sort_specs(specs)
      self.class.sort_specs(specs)
    end

spec_names() click to toggle source

    # File lib/bundler/index.rb, line 118
    def spec_names
      names = specs.keys + sources.map(&:spec_names)
      names.uniq!
      names
    end

unmet_dependency_names() click to toggle source

returns a list of the dependencies

    # File lib/bundler/index.rb, line 125
    def unmet_dependency_names
      dependency_names.select do |name|
        name != "bundler" && search(name).empty?
      end
    end

use(other, override_dupes = false) click to toggle source

    # File lib/bundler/index.rb, line 142
    def use(other, override_dupes = false)
      return unless other
      other.each do |s|
        if (dupes = search_by_spec(s)) && !dupes.empty?
          # safe to << since it's a new array when it has contents
          @all_specs[s.name] = dupes << s
          next unless override_dupes
        end
        self << s
      end
      self
    end

### Protected Instance Methods

unsorted_search(query, base) click to toggle source

    # File lib/bundler/index.rb, line 65
    def unsorted_search(query, base)
      results = local_search(query, base)

      seen = results.map(&:full_name).to_set unless @sources.empty?

      @sources.each do |source|
        source.unsorted_search(query, base).each do |spec|
          results << spec if seen.add?(spec.full_name)
        end
      end

      results
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.