123456789_123456789_123456789_123456789_123456789_

Class: Rake::InvocationChain

Relationships & Source Files
Namespace Children
Classes:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, LinkedList
Instance Chain:
self, LinkedList, Enumerable
Inherits: Rake::LinkedList
Defined in: lib/rake/invocation_chain.rb

Overview

InvocationChain tracks the chain of task invocations to detect circular dependencies.

Constant Summary

LinkedList - Inherited

EMPTY

Class Method Summary

LinkedList - Inherited

.cons

Cons a new head onto the tail list.

.empty

The standard empty list class for the given LinkedList class.

.make

Make a list out of the given arguments.

.new

Instance Attribute Summary

LinkedList - Inherited

#empty?

Is the list empty?

#head, #tail

Instance Method Summary

LinkedList - Inherited

#==

Lists are structurally equivalent.

#conj

Polymorphically add a new element to the head of a list.

#each

For each item in the list.

#inspect

Same as #to_s, but with inspected items.

#to_s

Convert to string: LL(item, item…).

Constructor Details

This class inherits a constructor from Rake::LinkedList

Class Method Details

.append(invocation, chain)

Class level append.

[ GitHub ]

  
# File 'lib/rake/invocation_chain.rb', line 27

def self.append(invocation, chain)
  chain.append(invocation)
end

Instance Method Details

#append(invocation)

Append an invocation to the chain of invocations. It is an error if the invocation already listed.

[ GitHub ]

  
# File 'lib/rake/invocation_chain.rb', line 14

def append(invocation)
  if member?(invocation)
    fail RuntimeError, "Circular dependency detected: #{to_s} => #{invocation}"
  end
  conj(invocation)
end

#member?(invocation) ⇒ Boolean

Is the invocation already in the chain?

[ GitHub ]

  
# File 'lib/rake/invocation_chain.rb', line 8

def member?(invocation)
  head == invocation || tail.member?(invocation)
end

#prefix (private)

[ GitHub ]

  
# File 'lib/rake/invocation_chain.rb', line 33

def prefix
  "#{tail} => "
end

#to_s

Convert to string, ie: TOP => invocation => invocation

[ GitHub ]

  
# File 'lib/rake/invocation_chain.rb', line 22

def to_s
  "#{prefix}#{head}"
end