Class: Gem::AvailableSet
Relationships & Source Files | |
Namespace Children | |
Classes:
| |
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
self,
Enumerable
|
|
Inherits: | Object |
Defined in: | lib/rubygems/available_set.rb |
Class Method Summary
- .new ⇒ AvailableSet constructor
Instance Attribute Summary
- #empty? ⇒ Boolean readonly
- #set readonly
- #remote rw Internal use only
Instance Method Summary
- #<<(o)
- #add(spec, source)
- #all_specs
-
#each
Yields each
Tuple
in thisAvailableSet
. -
#each_spec
Yields the
Specification
for eachTuple
in thisAvailableSet
. -
#find_all(req)
Used by the
Resolver
, the protocol to use aAvailableSet
as a search Set. - #inject_into_list(dep_list)
- #match_platform!
- #pick_best!
- #prefetch(reqs)
- #remove_installed!(dep)
- #size
- #sorted
- #source_for(spec)
-
#to_request_set(development = :none)
Converts this
AvailableSet
into aRequestSet
that can be used to install gems.
Constructor Details
.new ⇒ AvailableSet
# File 'lib/rubygems/available_set.rb', line 10
def initialize @set = [] @sorted = nil @remote = true end
Instance Attribute Details
#empty? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/rubygems/available_set.rb', line 68
def empty? @set.empty? end
#remote (rw)
This method is for internal use only.
[ GitHub ]
# File 'lib/rubygems/available_set.rb', line 8
attr_accessor :remote # :nodoc:
#set (readonly)
[ GitHub ]# File 'lib/rubygems/available_set.rb', line 16
attr_reader :set
Instance Method Details
#<<(o)
[ GitHub ]# File 'lib/rubygems/available_set.rb', line 24
def <<(o) case o when Gem::AvailableSet s = o.set when Array s = o.map do |sp,so| if !sp.kind_of?(Gem::Specification) || !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)
[ GitHub ]#all_specs
[ GitHub ]# File 'lib/rubygems/available_set.rb', line 72
def all_specs @set.map {|t| t.spec } end
#each
Yields each AvailableSet::Tuple
in this AvailableSet
# File 'lib/rubygems/available_set.rb', line 49
def each return enum_for __method__ unless block_given? @set.each do |tuple| yield tuple end end
#each_spec
Yields the Specification
for each AvailableSet::Tuple
in this AvailableSet
# File 'lib/rubygems/available_set.rb', line 60
def each_spec return enum_for __method__ unless block_given? each do |tuple| yield tuple.spec end end
#find_all(req)
Used by the Resolver
, the protocol to use a AvailableSet
as a search Set.
# File 'lib/rubygems/available_set.rb', line 126
def find_all(req) dep = req.dependency match = @set.find_all do |t| dep.match? t.spec end match.map do |t| Gem::Resolver::LocalSpecification.new(self, t.spec, t.source) end end
#inject_into_list(dep_list)
[ GitHub ]#match_platform!
[ GitHub ]# File 'lib/rubygems/available_set.rb', line 76
def match_platform! @set.reject! {|t| !Gem::Platform.match_spec?(t.spec) } @sorted = nil self end
#pick_best!
[ GitHub ]#prefetch(reqs)
[ GitHub ]# File 'lib/rubygems/available_set.rb', line 138
def prefetch(reqs) end
#remove_installed!(dep)
[ GitHub ]# File 'lib/rubygems/available_set.rb', line 149
def remove_installed!(dep) @set.reject! do |t| # already locally installed Gem::Specification.any? do |installed_spec| dep.name == installed_spec.name && dep.requirement.satisfied_by?(installed_spec.version) end end @sorted = nil self end
#size
[ GitHub ]# File 'lib/rubygems/available_set.rb', line 89
def size @set.size end
#sorted
[ GitHub ]# File 'lib/rubygems/available_set.rb', line 82
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)
[ GitHub ]# File 'lib/rubygems/available_set.rb', line 93
def source_for(spec) f = @set.find {|t| t.spec == spec } f.source end
#to_request_set(development = :none)
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 'lib/rubygems/available_set.rb', line 106
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