Parent

Included Modules

Class Index [+]

Quicksearch

Bundler::Index

Attributes

specs[R]

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 14
14:     def initialize
15:       @cache = {}
16:       @specs = Hash.new { |h,k| h[k] = [] }
17:     end

Public Instance Methods

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

Private Instance Methods

same_version?(a, b) click to toggle source
     # File lib/bundler/index.rb, line 104
104:     def same_version?(a, b)
105:       regex = /^(.*?)(?:\.0)*$/
106: 
107:       ret = a.to_s[regex, 1] == b.to_s[regex, 1]
108:     end
search_by_dependency(dependency) click to toggle source
     # File lib/bundler/index.rb, line 115
115:     def search_by_dependency(dependency)
116:       @cache[dependency.hash] ||= begin
117:         specs = @specs[dependency.name]
118: 
119:         wants_prerelease = dependency.requirement.prerelease?
120:         only_prerelease  = specs.all? {|spec| spec.version.prerelease? }
121:         found = specs.select { |spec| dependency.matches_spec?(spec) && Gem::Platform.match(spec.platform) }
122: 
123:         unless wants_prerelease || only_prerelease
124:           found.reject! { |spec| spec.version.prerelease? }
125:         end
126: 
127:         found.sort_by {|s| [s.version, s.platform.to_s == 'ruby' ? "\00"" : s.platform.to_s] }
128:       end
129:     end
search_by_spec(spec) click to toggle source
     # File lib/bundler/index.rb, line 98
 98:     def search_by_spec(spec)
 99:       @specs[spec.name].select do |s|
100:         same_version?(s.version, spec.version) && Gem::Platform.new(s.platform) == Gem::Platform.new(spec.platform)
101:       end
102:     end
spec_satisfies_dependency?(spec, dep) click to toggle source
     # File lib/bundler/index.rb, line 110
110:     def spec_satisfies_dependency?(spec, dep)
111:       return false unless dep.name === spec.name
112:       dep.requirement.satisfied_by?(spec.version)
113:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.