Class: Rake::InvocationChain

Inherits:
LinkedList show all
Defined in:
lib/rake/invocation_chain.rb

Overview

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

Defined Under Namespace

Classes: EmptyInvocationChain

Instance Attribute Summary

Attributes inherited from LinkedList

#head, #tail

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from LinkedList

#==, #conj, cons, #each, empty, #empty?, #initialize, #inspect, make

Constructor Details

This class inherits a constructor from Rake::LinkedList

Class Method Details

.append(invocation, chain) ⇒ Object

Class level append.



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

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

Instance Method Details

#append(invocation) ⇒ Object

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



14
15
16
17
18
19
# 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?

Returns:

  • (Boolean)


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

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

#to_sObject

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



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

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