class BuildNode
Represents a build graph node that applies a single provision to produce an output environment.
Definitions
def initialize(environment, provision, arguments)
Initialize the build node with an environment, provision, and arguments.
Signature
-
parameter
environmentBuild::Environment The environment to build within.
-
parameter
provisionBuild::Dependency::Provision The provision to apply.
-
parameter
argumentsArray Arguments passed to the provision constructor.
Implementation
def initialize(environment, provision, arguments)
@environment = environment
@provision = provision
@arguments = arguments
super(Files::List::NONE, :inherit)
end
def ==(other)
Signature
-
returns
Boolean Whether this node is equal to another.
Implementation
def == other
super and
@environment == other.environment and
@provision == other.provision and
@arguments == other.arguments
end
def hash
Signature
-
returns
Integer A hash value for this node.
Implementation
def hash
super ^ @environment.hash ^ @provision.hash ^ @arguments.hash
end
def task_class(parent_task)
Signature
-
returns
Class The task class to use for building this node.
Implementation
def task_class(parent_task)
task_class = Rulebook.for(@environment).with(BuildTask, environment: @environment)
end
def initial_environment
Signature
-
returns
Build::Environment A fresh copy of the environment for output.
Implementation
def initial_environment
Build::Environment.new(@environment)
end
def name
Signature
-
returns
String The name of the environment.
Implementation
def name
@environment.name
end
def apply!(task)
Apply this node to the given task, constructing the output environment.
Signature
-
parameter
taskBuild::Task The task context.
Implementation
def apply!(task)
output_environment = self.initial_environment
output_environment.construct!(task, *@arguments, &@provision.value)
task.output_environment = output_environment
end