In Files

  • rubygems/available_set.rb

Class/Module Index [+]

Quicksearch

Gem::AvailableSet

Constants

Tuple

Attributes

set[R]

Public Class Methods

new() click to toggle source
 
               # File rubygems/available_set.rb, line 7
def initialize
  @set = []
  @sorted = nil
end
            

Public Instance Methods

<<(o) click to toggle source
 
               # File rubygems/available_set.rb, line 20
def <<(o)
  case o
  when Gem::AvailableSet
    s = o.set
  when Array
    s = o.map do |sp,so|
      if !sp.kind_of?(Gem::Specification) or !so.kind_of?(Gem::Source)
        raise TypeError, "Array must be in [[spec, source], ...] form"
      end

      Tuple.new(sp,so)
    end
  else
    raise TypeError, "must be a Gem::AvailableSet"
  end

  @set += s
  @sorted = nil

  self
end
            
add(spec, source) click to toggle source
 
               # File rubygems/available_set.rb, line 14
def add(spec, source)
  @set << Tuple.new(spec, source)
  @sorted = nil
  self
end
            
all_specs() click to toggle source
 
               # File rubygems/available_set.rb, line 68
def all_specs
  @set.map { |t| t.spec }
end
            
each() click to toggle source

Yields each Tuple in this AvailableSet

 
               # File rubygems/available_set.rb, line 45
def each
  return enum_for __method__ unless block_given?

  @set.each do |tuple|
    yield tuple
  end
end
            
each_spec() click to toggle source

Yields the Gem::Specification for each Tuple in this AvailableSet

 
               # File rubygems/available_set.rb, line 56
def each_spec
  return enum_for __method__ unless block_given?

  each do |tuple|
    yield tuple.spec
  end
end
            
empty?() click to toggle source
 
               # File rubygems/available_set.rb, line 64
def empty?
  @set.empty?
end
            
find_all(req) click to toggle source

Used by the Resolver, the protocol to use a AvailableSet as a search Set.

 
               # File rubygems/available_set.rb, line 122
def find_all(req)
  dep = req.dependency

  match = @set.find_all do |t|
    dep.matches_spec? t.spec
  end

  match.map do |t|
    Gem::Resolver::LocalSpecification.new(self, t.spec, t.source)
  end
end
            
inject_into_list(dep_list) click to toggle source
 
               # File rubygems/available_set.rb, line 158
def inject_into_list(dep_list)
  @set.each { |t| dep_list.add t.spec }
end
            
match_platform!() click to toggle source
 
               # File rubygems/available_set.rb, line 72
def match_platform!
  @set.reject! { |t| !Gem::Platform.match(t.spec.platform) }
  @sorted = nil
  self
end
            
pick_best!() click to toggle source
 
               # File rubygems/available_set.rb, line 137
def pick_best!
  return self if empty?

  @set = [sorted.first]
  @sorted = nil
  self
end
            
prefetch(reqs) click to toggle source
 
               # File rubygems/available_set.rb, line 134
def prefetch(reqs)
end
            
remove_installed!(dep) click to toggle source
 
               # File rubygems/available_set.rb, line 145
def remove_installed!(dep)
  @set.reject! do |t|
    # already locally installed
    Gem::Specification.any? do |installed_spec|
      dep.name == installed_spec.name and
        dep.requirement.satisfied_by? installed_spec.version
    end
  end

  @sorted = nil
  self
end
            
size() click to toggle source
 
               # File rubygems/available_set.rb, line 85
def size
  @set.size
end
            
sorted() click to toggle source
 
               # File rubygems/available_set.rb, line 78
def sorted
  @sorted ||= @set.sort do |a,b|
    i = b.spec <=> a.spec
    i != 0 ? i : (a.source <=> b.source)
  end
end
            
source_for(spec) click to toggle source
 
               # File rubygems/available_set.rb, line 89
def source_for(spec)
  f = @set.find { |t| t.spec == spec }
  f.source
end
            
to_request_set(development = :none) click to toggle source

Converts this AvailableSet into a RequestSet that can be used to install gems.

If development is :none then no development dependencies are installed. Other options are :shallow for only direct development dependencies of the gems in this set or :all for all development dependencies.

 
               # File rubygems/available_set.rb, line 102
def to_request_set development = :none
  request_set = Gem::RequestSet.new
  request_set.development = :all == development

  each_spec do |spec|
    request_set.always_install << spec

    request_set.gem spec.name, spec.version
    request_set.import spec.development_dependencies if
      :shallow == development
  end

  request_set
end
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.

blog comments powered by Disqus