Parent

Included Modules

Class Index [+]

Quicksearch

Bundler::Index

Attributes

specs[R]
sources[R]

Public Class Methods

build() click to toggle source
    # File lib/bundler/index.rb, line 7
 7:     def self.build
 8:       i = new
 9:       yield i
10:       i
11:     end
new() click to toggle source
    # File lib/bundler/index.rb, line 16
16:     def initialize
17:       @sources = []
18:       @cache = {}
19:       @specs = Hash.new { |h,k| h[k] = [] }
20:     end

Public Instance Methods

<<(spec) click to toggle source
    # File lib/bundler/index.rb, line 74
74:     def <<(spec)
75:       arr = specs_by_name(spec.name)
76: 
77:       arr.delete_if do |s|
78:         same_version?(s.version, spec.version) && s.platform == spec.platform
79:       end
80: 
81:       arr << spec
82:       spec
83:     end
==(o) click to toggle source
     # File lib/bundler/index.rb, line 119
119:     def ==(o)
120:       all? do |spec|
121:         other_spec = o[spec].first
122:         (spec.dependencies & other_spec.dependencies).empty? && spec.source == other_spec.source
123:       end
124:     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
126:     def add_source(index)
127:       if index.is_a?(Index)
128:         @sources << index
129:         @sources.uniq! # need to use uniq! here instead of checking for the item before adding
130:       else
131:         raise ArgumentError, "Source must be an index, not #{index.class}"
132:       end
133:     end
each(&blk) click to toggle source
    # File lib/bundler/index.rb, line 85
85:     def each(&blk)
86:       specs.values.each do |specs|
87:         specs.each(&blk)
88:       end
89:     end
empty?() click to toggle source
    # File lib/bundler/index.rb, line 37
37:     def empty?
38:       each { return false }
39:       true
40:     end
initialize_copy(o) click to toggle source
    # File lib/bundler/index.rb, line 22
22:     def initialize_copy(o)
23:       super
24:       @sources = @sources.dup
25:       @cache = {}
26:       @specs = Hash.new { |h,k| h[k] = [] }
27: 
28:       o.specs.each do |name, array|
29:         @specs[name] = array.dup
30:       end
31:     end
inspect() click to toggle source
    # File lib/bundler/index.rb, line 33
33:     def inspect
34:       "<Index sources=#{sources.map{|s| s.inspect}} specs.size=#{specs.size}>"
35:     end
local_search(query, base = nil) click to toggle source
    # File lib/bundler/index.rb, line 58
58:     def local_search(query, base = nil)
59:       case query
60:       when Gem::Specification, RemoteSpecification, LazySpecification, EndpointSpecification then search_by_spec(query)
61:       when String then specs_by_name(query)
62:       when Gem::Dependency then search_by_dependency(query, base)
63:       else
64:         raise "You can't search for a #{query.inspect}."
65:       end
66:     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
44:     def search(query, base = nil)
45:       results = local_search(query, base)
46:       seen = Set.new(results.map { |spec| [spec.name, spec.version, spec.platform] })
47: 
48:       @sources.each do |source|
49:         source.search(query, base).each do |spec|
50:           results << spec unless seen.include?([spec.name, spec.version, spec.platform])
51:           seen << [spec.name, spec.version, spec.platform]
52:         end
53:       end
54: 
55:       results
56:     end
Also aliased as: []
size() click to toggle source
     # File lib/bundler/index.rb, line 113
113:     def size
114:       @sources.inject(@specs.size) do |size, source|
115:         size += source.size
116:       end
117:     end
source_types() click to toggle source
    # File lib/bundler/index.rb, line 68
68:     def source_types
69:       sources.map{|s| s.class }.uniq
70:     end
unmet_dependency_names() click to toggle source

returns a list of the dependencies

    # File lib/bundler/index.rb, line 92
92:     def unmet_dependency_names
93:       dependency_names = specs.values.map do |array_of_s|
94:         array_of_s.map do |s|
95:           s.dependencies.map{|d| d.name }
96:         end
97:       end.flatten.uniq
98:       dependency_names.select{|name| specs_by_name(name).empty? }
99:     end
use(other, override_dupes = false) click to toggle source
     # File lib/bundler/index.rb, line 101
101:     def use(other, override_dupes = false)
102:       return unless other
103:       other.each do |s|
104:         if (dupes = search_by_spec(s)) && dupes.any?
105:           next unless override_dupes
106:           @specs[s.name] -= dupes
107:         end
108:         @specs[s.name] << s
109:       end
110:       self
111:     end

Private Instance Methods

same_version?(a, b) click to toggle source
     # File lib/bundler/index.rb, line 171
171:       def same_version?(a, b)
172:         regex = /^(.*?)(?:\.0)*$/
173:         a.to_s[regex, 1] == b.to_s[regex, 1]
174:       end
same_version?(a, b) click to toggle source
     # File lib/bundler/index.rb, line 176
176:       def same_version?(a, b)
177:         a == b
178:       end
search_by_dependency(dependency, base = nil) click to toggle source
     # File lib/bundler/index.rb, line 141
141:     def search_by_dependency(dependency, base = nil)
142:       @cache[base || false] ||= {}
143:       @cache[base || false][dependency] ||= begin
144:         specs = specs_by_name(dependency.name) + (base || [])
145:         found = specs.select do |spec|
146:           if base # allow all platforms when searching from a lockfile
147:             dependency.matches_spec?(spec)
148:           else
149:             dependency.matches_spec?(spec) && Gem::Platform.match(spec.platform)
150:           end
151:         end
152: 
153:         wants_prerelease = dependency.requirement.prerelease?
154:         only_prerelease  = specs.all? {|spec| spec.version.prerelease? }
155: 
156:         unless wants_prerelease || only_prerelease
157:           found.reject! { |spec| spec.version.prerelease? }
158:         end
159: 
160:         found.sort_by {|s| [s.version, s.platform.to_s == 'ruby' ? "\00"" : s.platform.to_s] }
161:       end
162:     end
search_by_spec(spec) click to toggle source
     # File lib/bundler/index.rb, line 164
164:     def search_by_spec(spec)
165:       specs_by_name(spec.name).select do |s|
166:         same_version?(s.version, spec.version) && Gem::Platform.new(s.platform) == Gem::Platform.new(spec.platform)
167:       end
168:     end
spec_satisfies_dependency?(spec, dep) click to toggle source
     # File lib/bundler/index.rb, line 181
181:     def spec_satisfies_dependency?(spec, dep)
182:       return false unless dep.name === spec.name
183:       dep.requirement.satisfied_by?(spec.version)
184:     end
specs_by_name(name) click to toggle source
     # File lib/bundler/index.rb, line 137
137:     def specs_by_name(name)
138:       @specs[name]
139:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.