Class: Build::ChainNode
- Inherits:
-
Graph::Node
- Object
- Graph::Node
- Build::ChainNode
- Defined in:
- lib/build/chain_node.rb
Instance Method Summary collapse
- #apply!(scope) ⇒ Object
- #apply_dependency(scope, dependency) ⇒ Object
-
#initialize(chain, arguments, environment) ⇒ ChainNode
constructor
A new instance of ChainNode.
- #name ⇒ Object
- #task_class ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(chain, arguments, environment) ⇒ ChainNode
Returns a new instance of ChainNode.
28 29 30 31 32 33 34 35 |
# File 'lib/build/chain_node.rb', line 28 def initialize(chain, arguments, environment) @chain = chain @arguments = arguments @environment = environment # Wait here, for all dependent targets, to be done: super(Files::List::NONE, :inherit, chain) end |
Instance Method Details
#apply!(scope) ⇒ Object
102 103 104 105 106 |
# File 'lib/build/chain_node.rb', line 102 def apply!(scope) @chain.dependencies.each do |dependency| apply_dependency(scope, dependency) end end |
#apply_dependency(scope, dependency) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/build/chain_node.rb', line 45 def apply_dependency(scope, dependency) logger = scope.logger # logger.debug {"Traversing: #{dependency}..."} environments = [@environment] public_environments = [] provisions = @chain.resolved[dependency] public_alias = dependency.alias? provisions.each do |provision| provision.each_dependency do |nested_dependency| if environment = apply_dependency(scope, nested_dependency) # logger.debug("Evaluating #{nested_dependency} -> #{provision} generated: #{environment}") environments << environment if public_alias || nested_dependency.public? public_environments << environment # else # logger.debug("Skipping #{nested_dependency} in public environment.") end end end end unless dependency.alias? logger.debug {"Building: #{dependency}"} # environments.each do |environment| # logger.debug {"Using #{environment}"} # end local_environment = Build::Environment.combine(*environments)&.evaluate || Build::Environment.new # logger.debug("Local Environment: #{local_environment}") task_class = Rulebook.for(local_environment).with(Task, environment: local_environment) task = task_class.new(scope.walker, self, scope.group, logger: scope.logger) output_environment = nil task.visit do output_environment = Build::Environment.new(local_environment, name: dependency.name) provisions.each do |provision| # When executing the environment build steps, we create new build nodes. But those build nodes are not capturing the right task class. output_environment.construct!(task, *@arguments, &provision.value) end public_environments << output_environment.dup(parent: nil, name: dependency.name) end end return Build::Environment.combine(*public_environments) end |
#name ⇒ Object
37 38 39 |
# File 'lib/build/chain_node.rb', line 37 def name @environment.name end |
#task_class ⇒ Object
41 42 43 |
# File 'lib/build/chain_node.rb', line 41 def task_class Task end |
#to_s ⇒ Object
108 109 110 |
# File 'lib/build/chain_node.rb', line 108 def to_s "#<#{self.class}>" end |