Parent

Included Modules

Bundler::Index

Public Class Methods

build() click to toggle source
   # File lib/bundler/index.rb, line 5
5:     def self.build
6:       i = new
7:       yield i
8:       i
9:     end
new() click to toggle source
    # File lib/bundler/index.rb, line 11
11:     def initialize
12:       @cache = {}
13:       @specs = Hash.new { |h,k| h[k] = [] }
14:     end

Public Instance Methods

<<(spec) click to toggle source
    # File lib/bundler/index.rb, line 58
58:     def <<(spec)
59:       arr = @specs[spec.name]
60: 
61:       arr.delete_if do |s|
62:         s.version == spec.version && s.platform == spec.platform
63:       end
64: 
65:       arr << spec
66:       spec
67:     end
==(o) click to toggle source
    # File lib/bundler/index.rb, line 84
84:     def ==(o)
85:       all? do |s|
86:         s2 = o[s].first and (s.dependencies & s2.dependencies).empty?
87:       end
88:     end
[](query) click to toggle source
Alias for: search
each(&blk) click to toggle source
    # File lib/bundler/index.rb, line 69
69:     def each(&blk)
70:       @specs.values.each do |specs|
71:         specs.each(&blk)
72:       end
73:     end
empty?() click to toggle source
    # File lib/bundler/index.rb, line 23
23:     def empty?
24:       each { return false }
25:       true
26:     end
initialize_copy(o) click to toggle source
    # File lib/bundler/index.rb, line 16
16:     def initialize_copy(o)
17:       super
18:       @cache = {}
19:       @specs = Hash.new { |h,k| h[k] = [] }
20:       merge!(o)
21:     end
search(query) click to toggle source
    # File lib/bundler/index.rb, line 28
28:     def search(query)
29:       case query
30:       when Gem::Specification, RemoteSpecification, LazySpecification then search_by_spec(query)
31:       when String then @specs[query]
32:       else search_by_dependency(query)
33:       end
34:     end
Also aliased as: []
search_for_all_platforms(dependency, base = []) click to toggle source
    # File lib/bundler/index.rb, line 36
36:     def search_for_all_platforms(dependency, base = [])
37:       specs = @specs[dependency.name] + base
38: 
39:       wants_prerelease = dependency.requirement.prerelease?
40:       only_prerelease  = specs.all? {|spec| spec.version.prerelease? }
41:       found = specs.select { |spec| dependency =~ spec }
42: 
43:       unless wants_prerelease || only_prerelease
44:         found.reject! { |spec| spec.version.prerelease? }
45:       end
46: 
47:       found.sort_by {|s| [s.version, s.platform.to_s == 'ruby' ? "\00"" : s.platform.to_s] }
48:     end
sources() click to toggle source
    # File lib/bundler/index.rb, line 50
50:     def sources
51:       @specs.values.map do |specs|
52:         specs.map{|s| s.source.class }
53:       end.flatten.uniq
54:     end
use(other) click to toggle source
    # File lib/bundler/index.rb, line 75
75:     def use(other)
76:       return unless other
77:       other.each do |s|
78:         next if search_by_spec(s).any?
79:         @specs[s.name] << s
80:       end
81:       self
82:     end

Private Instance Methods

search_by_dependency(dependency) click to toggle source
     # File lib/bundler/index.rb, line 98
 98:     def search_by_dependency(dependency)
 99:       @cache[dependency.hash] ||= begin
100:         specs = @specs[dependency.name]
101: 
102:         wants_prerelease = dependency.requirement.prerelease?
103:         only_prerelease  = specs.all? {|spec| spec.version.prerelease? }
104:         found = specs.select { |spec| dependency =~ spec && Gem::Platform.match(spec.platform) }
105: 
106:         unless wants_prerelease || only_prerelease
107:           found.reject! { |spec| spec.version.prerelease? }
108:         end
109: 
110:         found.sort_by {|s| [s.version, s.platform.to_s == 'ruby' ? "\00"" : s.platform.to_s] }
111:       end
112:     end
search_by_spec(spec) click to toggle source
    # File lib/bundler/index.rb, line 92
92:     def search_by_spec(spec)
93:       @specs[spec.name].select do |s|
94:         s.version == spec.version && Gem::Platform.new(s.platform) == Gem::Platform.new(spec.platform)
95:       end
96:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.