Class: Toys::SourceList

Inherits:
Object
  • Object
show all
Defined in:
core-docs/toys/source_list.rb

Overview

An ordered collection of root sources for the Loader, held as unresolved SourceSpec objects. Use this class to build a list of sources, and then pass it to the Loader constructor.

Each spec added to the list occupies its own priority level, and resolves to a single root source. This is an invariant the Loader relies on.

A source list resolves nothing. The specs it holds describe sources; the Loader turns them into SourceInfo objects when it first needs them.

Not thread-safe. Callers should ensure that access is single-threaded or synchronized.

Defined in the toys-core gem

Instance Method Summary collapse

Constructor Details

#initialize ⇒ SourceList

Create an empty source list.



23
24
25
# File 'core-docs/toys/source_list.rb', line 23

def initialize
  # Source available in the toys-core gem
end

Instance Method Details

#add(spec, high_priority: false) ⇒ self

Add a source spec to the list, assigning it the next priority.

Parameters:

  • spec (Toys::SourceSpec::Base) —

    The source spec to add.

  • high_priority (boolean) (defaults to: false) —

    If true, add this source at the top of the priority list. Defaults to false, indicating the new source should be at the bottom of the priority list.

Returns:

  • (self)

Raises:

  • (ArgumentError) —

    if the given object is not a source spec.



68
69
70
# File 'core-docs/toys/source_list.rb', line 68

def add(spec, high_priority: false)
  # Source available in the toys-core gem
end

#each_with_priority {|Toys::SourceSpec::Base, Integer| ... } ⇒ self, Enumerator

Iterate over the source specs and their assigned priorities, in the order in which they were added.

Yields:

Returns:

  • (self) —

    if a block is given.

  • (Enumerator) —

    if no block is given.



53
54
55
# File 'core-docs/toys/source_list.rb', line 53

def each_with_priority
  # Source available in the toys-core gem
end

#empty? ⇒ boolean

Determines whether the list is empty.

Returns:

  • (boolean)


32
33
34
# File 'core-docs/toys/source_list.rb', line 32

def empty?
  # Source available in the toys-core gem
end

#size ⇒ Integer

Returns the size of the list.

Returns:

  • (Integer)


41
42
43
# File 'core-docs/toys/source_list.rb', line 41

def size
  # Source available in the toys-core gem
end