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



1347
1348
1349
1350
1351
1352
1353
# File 'lib/rubygems/test_case.rb', line 1347

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.



1342
1343
1344
# File 'lib/rubygems/test_case.rb', line 1342

def remote
  @remote
end

Instance Method Details

#add(spec) ⇒ Object

Adds spec to this set.



1358
1359
1360
# File 'lib/rubygems/test_case.rb', line 1358

def add spec
  @specs << spec
end

#find_all(dep) ⇒ Object

Finds all gems matching dep in this set.



1374
1375
1376
# File 'lib/rubygems/test_case.rb', line 1374

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

#find_spec(dep) ⇒ Object

Finds dep in this set.



1365
1366
1367
1368
1369
# File 'lib/rubygems/test_case.rb', line 1365

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.



1382
1383
1384
1385
1386
1387
1388
1389
# File 'lib/rubygems/test_case.rb', line 1382

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:



1391
1392
# File 'lib/rubygems/test_case.rb', line 1391

def prefetch reqs # :nodoc:
end