Class: Gem::TestCase::StaticSet

Inherits:
Resolver::Set show all
Defined in:
lib/rubygems/test_case.rb

Overview

The StaticSet is a static set of gem specifications used for testing only. It is available by requiring Gem::TestCase.

Instance Attribute Summary collapse

Attributes inherited from Resolver::Set

#errors, #prerelease

Instance Method Summary collapse

Methods inherited from Resolver::Set

#remote?

Constructor Details

#initialize(specs) ⇒ StaticSet

Creates a new StaticSet for the given specs



1407
1408
1409
1410
1411
1412
1413
# File 'lib/rubygems/test_case.rb', line 1407

def initialize(specs)
  super()

  @specs = specs

  @remote = true
end

Instance Attribute Details

#remoteObject

A StaticSet ignores remote because it has a fixed set of gems.



1402
1403
1404
# File 'lib/rubygems/test_case.rb', line 1402

def remote
  @remote
end

Instance Method Details

#add(spec) ⇒ Object

Adds spec to this set.



1418
1419
1420
# File 'lib/rubygems/test_case.rb', line 1418

def add(spec)
  @specs << spec
end

#find_all(dep) ⇒ Object

Finds all gems matching dep in this set.



1434
1435
1436
# File 'lib/rubygems/test_case.rb', line 1434

def find_all(dep)
  @specs.find_all {|s| dep.match? s, @prerelease }
end

#find_spec(dep) ⇒ Object

Finds dep in this set.



1425
1426
1427
1428
1429
# File 'lib/rubygems/test_case.rb', line 1425

def find_spec(dep)
  @specs.reverse_each do |s|
    return s if dep.matches_spec? s
  end
end

#load_spec(name, ver, platform, source) ⇒ Object

Loads a Gem::Specification from this set which has the given name, version ver, platform. The source is ignored.



1442
1443
1444
1445
1446
1447
1448
1449
# File 'lib/rubygems/test_case.rb', line 1442

def load_spec(name, ver, platform, source)
  dep = Gem::Dependency.new name, ver
  spec = find_spec dep

  Gem::Specification.new spec.name, spec.version do |s|
    s.platform = spec.platform
  end
end

#prefetch(reqs) ⇒ Object

:nodoc:



1451
1452
# File 'lib/rubygems/test_case.rb', line 1451

def prefetch(reqs) # :nodoc:
end