Class: Build::RuleNode

Inherits:
Graph::Node
  • Object
show all
Defined in:
lib/build/rule_node.rb

Overview

Represents a build graph node that applies a specific rule with given arguments.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rule, arguments, &block) ⇒ RuleNode

Initialize the rule node.



14
15
16
17
18
19
20
21
22
23
# File 'lib/build/rule_node.rb', line 14

def initialize(rule, arguments, &block)
	@arguments = arguments
	@rule = rule
	
	@callback = block
	
	inputs, outputs = @rule.files(@arguments)
	
	super(inputs, outputs)
end

Instance Attribute Details

#argumentsObject (readonly)

Returns the value of attribute arguments.



25
26
27
# File 'lib/build/rule_node.rb', line 25

def arguments
  @arguments
end

#callbackObject (readonly)

Returns the value of attribute callback.



27
28
29
# File 'lib/build/rule_node.rb', line 27

def callback
  @callback
end

#ruleObject (readonly)

Returns the value of attribute rule.



26
27
28
# File 'lib/build/rule_node.rb', line 26

def rule
  @rule
end

Instance Method Details

#==(other) ⇒ Object



30
31
32
33
34
35
# File 'lib/build/rule_node.rb', line 30

def == other
	super and
		@arguments == other.arguments and
		@rule == other.rule and
		@callback == other.callback
end

#apply!(scope) ⇒ Object

Apply the rule in the given scope, then invoke the callback if present.



54
55
56
57
58
59
60
# File 'lib/build/rule_node.rb', line 54

def apply!(scope)
	@rule.apply!(scope, @arguments)
	
	if @callback
		scope.instance_exec(@arguments, &@callback)
	end
end

#hashObject



38
39
40
# File 'lib/build/rule_node.rb', line 38

def hash
	super ^ @arguments.hash ^ @rule.hash ^ @callback.hash
end

#inspectObject



63
64
65
# File 'lib/build/rule_node.rb', line 63

def inspect
	@rule.name.inspect
end

#nameObject



48
49
50
# File 'lib/build/rule_node.rb', line 48

def name
	@rule.name
end

#task_class(parent_task) ⇒ Object



43
44
45
# File 'lib/build/rule_node.rb', line 43

def task_class(parent_task)
	parent_task.class
end