Class: Build::BuildNode

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(environment, dependency, provisions, arguments) ⇒ BuildNode

Returns a new instance of BuildNode.



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

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

Instance Attribute Details

#argumentsObject (readonly)

Returns the value of attribute arguments.



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

def arguments
  @arguments
end

#dependencyObject (readonly)

Returns the value of attribute dependency.



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

def dependency
  @dependency
end

#environmentObject (readonly)

Returns the value of attribute environment.



37
38
39
# File 'lib/build/build_node.rb', line 37

def environment
  @environment
end

#provisionsObject (readonly)

Returns the value of attribute provisions.



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

def provisions
  @provisions
end

Instance Method Details

#==(other) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/build/build_node.rb', line 42

def == other
	super and
		@environment == other.environment and
		@dependency == other.dependency and
		@provisions == other.provisions and
		@arguments == other.arguments
end

#apply!(task) ⇒ Object



66
67
68
69
70
71
72
73
74
# File 'lib/build/build_node.rb', line 66

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

#hashObject



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

def hash
	super ^ @environment.hash ^ @dependency.hash ^ @provisions.hash ^ @arguments.hash
end

#initial_environmentObject



58
59
60
# File 'lib/build/build_node.rb', line 58

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

#nameObject



62
63
64
# File 'lib/build/build_node.rb', line 62

def name
	@dependency.name
end

#task_class(parent_task) ⇒ Object



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

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