BuildSourceBuildRuleNode

class RuleNode

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

Definitions

def initialize(rule, arguments, &block)

Initialize the rule node.

Signature

parameter rule Build::Rule

The rule to apply.

parameter arguments Hash

The normalised arguments for the rule.

Implementation

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

def ==(other)

Signature

returns Boolean

Whether this node is equal to another.

Implementation

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

def hash

Signature

returns Integer

A hash value for this node.

Implementation

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

def task_class(parent_task)

Signature

returns Class

The task class inherited from the parent task.

Implementation

def task_class(parent_task)
	parent_task.class
end

def name

Signature

returns String

The name of the rule.

Implementation

def name
	@rule.name
end

def apply!(scope)

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

Signature

parameter scope Object

The task scope.

Implementation

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

def inspect

Signature

returns String

A human-readable representation of the rule node.

Implementation

def inspect
	@rule.name.inspect
end