123456789_123456789_123456789_123456789_123456789_

Class: Gem::TestCase::StaticSet

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: Gem::Resolver::Set
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.

Class Method Summary

Instance Attribute Summary

  • #remote rw

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

::Gem::Resolver::Set - Inherited

#errors

Errors encountered when resolving gems.

#prerelease

When true, allows matching of requests to prerelease gems.

#remote

Set to true to disable network access for this set.

Instance Method Summary

::Gem::Resolver::Set - Inherited

#find_all

The find_all method must be implemented.

#prefetch

The #prefetch method may be overridden, but this is not necessary.

Constructor Details

.new(specs) ⇒ StaticSet

Creates a new StaticSet for the given specs

[ GitHub ]

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

def initialize(specs)
  super()

  @specs = specs

  @remote = true
end

Instance Attribute Details

#remote (rw)

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

[ GitHub ]

  
# File 'lib/rubygems/test_case.rb', line 1353

attr_accessor :remote

Instance Method Details

#add(spec)

Adds Gem::TestCase#spec to this set.

[ GitHub ]

  
# File 'lib/rubygems/test_case.rb', line 1369

def add spec
  @specs << spec
end

#find_all(dep)

Finds all gems matching Gem::TestCase#dep in this set.

[ GitHub ]

  
# File 'lib/rubygems/test_case.rb', line 1385

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

#find_spec(dep)

Finds Gem::TestCase#dep in this set.

[ GitHub ]

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

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

#load_spec(name, ver, platform, source)

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

[ GitHub ]

  
# File 'lib/rubygems/test_case.rb', line 1393

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