Parent

Included Modules

Class/Module Index [+]

Quicksearch

Bundler::Index

Attributes

all_specs[R]
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] = [] }
  @all_specs = Hash.new { |h,k| h[k] = [] }
end

Public Instance Methods

<<(spec) click to toggle source
# File lib/bundler/index.rb, line 90
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 135
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 142
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 101
def each(&blk)
  specs.values.each do |specs|
    specs.each(&blk)
  end
end
empty?() click to toggle source
# File lib/bundler/index.rb, line 42
def empty?
  each { return false }
  true
end
initialize_copy(o) click to toggle source
# File lib/bundler/index.rb, line 23
def initialize_copy(o)
  super
  @sources = @sources.dup
  @cache = {}
  @specs = Hash.new { |h,k| h[k] = [] }
  @all_specs = Hash.new { |h,k| h[k] = [] }

  o.specs.each do |name, array|
    @specs[name] = array.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 38
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 74
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 57
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|
      lookup = [spec.name, spec.version, spec.platform]
      unless seen.include?(lookup)
        results << spec
        seen << lookup
      end
    end
  end

  results.sort_by {|s| [s.version, s.platform.to_s == 'ruby' ? "\00"" : s.platform.to_s] }
end
Also aliased as: []
search_all(name) click to toggle source
# File lib/bundler/index.rb, line 47
def search_all(name)
  all_matches = @all_specs[name] + local_search(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 129
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 84
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 108
def unmet_dependency_names
  names = []
  each{|s| names.push *s.dependencies.map{|d| d.name } }
  names.uniq!
  names.delete_if{|n| n == "bundler" }
  names.select{|n| search(n).empty? }
end
use(other, override_dupes = false) click to toggle source
# File lib/bundler/index.rb, line 116
def use(other, override_dupes = false)
  return unless other
  other.each do |s|
    if (dupes = search_by_spec(s)) && dupes.any?
      @all_specs[s.name] = [s] + dupes
      next unless override_dupes
      @specs[s.name] -= dupes
    end
    @specs[s.name] << s
  end
  self
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.