Class: Build::BuildNode

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

Overview

Represents a build graph node that applies a single provision to produce an output environment.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(environment, provision, arguments) ⇒ BuildNode

Initialize the build node with an environment, provision, and arguments.



19
20
21
22
23
24
25
# File 'lib/build/build_node.rb', line 19

def initialize(environment, provision, arguments)
	@environment = environment
	@provision = provision
	@arguments = arguments
	
	super(Files::List::NONE, :inherit)
end

Instance Attribute Details

#argumentsObject (readonly)

Returns the value of attribute arguments.



29
30
31
# File 'lib/build/build_node.rb', line 29

def arguments
  @arguments
end

#environmentObject (readonly)

Returns the value of attribute environment.



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

def environment
  @environment
end

#provisionObject (readonly)

Returns the value of attribute provision.



28
29
30
# File 'lib/build/build_node.rb', line 28

def provision
  @provision
end

Instance Method Details

#==(other) ⇒ Object



32
33
34
35
36
37
# File 'lib/build/build_node.rb', line 32

def == other
	super and
		@environment == other.environment and
		@provision == other.provision and
		@arguments == other.arguments
end

#apply!(task) ⇒ Object

Apply this node to the given task, constructing the output environment.



61
62
63
64
65
66
67
# File 'lib/build/build_node.rb', line 61

def apply!(task)
	output_environment = self.initial_environment
	
	output_environment.construct!(task, *@arguments, &@provision.value)
	
	task.output_environment = output_environment
end

#hashObject



40
41
42
# File 'lib/build/build_node.rb', line 40

def hash
	super ^ @environment.hash ^ @provision.hash ^ @arguments.hash
end

#initial_environmentObject



50
51
52
# File 'lib/build/build_node.rb', line 50

def initial_environment
	Build::Environment.new(@environment)
end

#nameObject



55
56
57
# File 'lib/build/build_node.rb', line 55

def name
	@environment.name
end

#task_class(parent_task) ⇒ Object



45
46
47
# File 'lib/build/build_node.rb', line 45

def task_class(parent_task)
	task_class = Rulebook.for(@environment).with(BuildTask, environment: @environment)
end