Class: Bundler::Index

### Home Classes Methods

### In Files

- lib/bundler/index.rb

### Parent

Object

### Methods

- ::build
- ::new
- #<<
- #==
- #[]
- #add_source
- #each
- #empty?
- #initialize_copy
- #inspect
- #local_search
- #search
- #size
- #source_types
- #unmet_dependency_names
- #use

### Included Modules

- Enumerable

### 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::Index

### Attributes

sources[R]
specs[R]

### Public Class Methods

build() click to toggle source

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

new() click to toggle source

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

### Public Instance Methods

<<(spec) click to toggle source

    # File lib/bundler/index.rb, line 74
    def <<(spec)
      arr = specs_by_name(spec.name)

      arr.delete_if do |s|
        same_version?(s.version, spec.version) && s.platform == spec.platform
      end

      arr << spec
      spec
    end

==(o) click to toggle source

    # File lib/bundler/index.rb, line 119
    def ==(o)
      all? do |spec|
        other_spec = o[spec].first
        (spec.dependencies & other_spec.dependencies).empty? && 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 126
    def add_source(index)
      if index.is_a?(Index)
        @sources << index
        @sources.uniq! # need to use uniq! here instead of checking for the item before adding
      else
        raise ArgumentError, "Source must be an index, not #{index.class}"
      end
    end

each(&blk) click to toggle source

    # File lib/bundler/index.rb, line 85
    def each(&blk)
      specs.values.each do |specs|
        specs.each(&blk)
      end
    end

empty?() click to toggle source

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

initialize_copy(o) click to toggle source

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

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

inspect() click to toggle source

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

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

    # File lib/bundler/index.rb, line 58
    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)
      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 44
    def search(query, base = nil)
      results = local_search(query, base)
      seen = Set.new(results.map { |spec| [spec.name, spec.version, spec.platform] })

      @sources.each do |source|
        source.search(query, base).each do |spec|
          results << spec unless seen.include?([spec.name, spec.version, spec.platform])
          seen << [spec.name, spec.version, spec.platform]
        end
      end

      results
    end

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

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

source_types() click to toggle source

    # File lib/bundler/index.rb, line 68
    def source_types
      sources.map{|s| s.class }.uniq
    end

unmet_dependency_names() click to toggle source

returns a list of the dependencies

    # File lib/bundler/index.rb, line 92
    def unmet_dependency_names
      dependency_names = specs.values.map do |array_of_s|
        array_of_s.map do |s|
          s.dependencies.map{|d| d.name }
        end
      end.flatten.uniq
      dependency_names.select{|name| name != 'bundler' && specs_by_name(name).empty? }
    end

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

    # File lib/bundler/index.rb, line 101
    def use(other, override_dupes = false)
      return unless other
      other.each do |s|
        if (dupes = search_by_spec(s)) && dupes.any?
          next unless override_dupes
          @specs[s.name] -= dupes
        end
        @specs[s.name] << s
      end
      self
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.