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?, #inspect, make

Class Method Details

.append(invocation, chain) ⇒ Object

Class level append.



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

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.



15
16
17
18
19
20
# File 'lib/rake/invocation_chain.rb', line 15

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)


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

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

#to_sObject

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



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

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