class Build::Graph::Node
This is essentialy a immutable key:
Attributes
inputs[R]
outputs[R]
Public Class Methods
new(inputs, outputs)
click to toggle source
@param process [Object] Represents an abstract process, e.g. a name or a function.
# File lib/build/graph/node.rb, line 29 def initialize(inputs, outputs) @inputs = inputs @outputs = outputs end
top(inputs = Files::Paths::NONE, outputs = :inherit, **options, &block)
click to toggle source
# File lib/build/graph/node.rb, line 96 def self.top(inputs = Files::Paths::NONE, outputs = :inherit, **options, &block) self.new(inputs, outputs, block, **options) end
Public Instance Methods
==(other)
click to toggle source
# File lib/build/graph/node.rb, line 77 def == other self.equal?(other) or self.class == other.class and @inputs == other.inputs and @outputs == other.outputs end
dirty?()
click to toggle source
This is a canonical dirty function. All outputs must exist and must be newer than all inputs. This function is not efficient, in the sense that it must query all files on disk for last modified time.
# File lib/build/graph/node.rb, line 52 def dirty? if inherit_outputs? return true elsif @inputs.count == 0 or @outputs.count == 0 # If there are no inputs or no outputs we are always dirty: return true # I'm not entirely sure this is the correct approach. If input is a glob that matched zero items, but might match items that are older than outputs, what is the correct output from this function? else # Dirty if any inputs or outputs missing: return true if missing? # Dirty if input modified after any output: if input_modified_time = self.modified_time # Outputs should always be more recent than their inputs: return true if @outputs.any?{|output_path| output_path.modified_time < input_modified_time} else # None of the inputs exist: true end end return false end
eql?(other)
click to toggle source
# File lib/build/graph/node.rb, line 84 def eql?(other) self.equal?(other) or self == other end
hash()
click to toggle source
# File lib/build/graph/node.rb, line 88 def hash @inputs.hash ^ @outputs.hash end
inherit_outputs?()
click to toggle source
Nodes that inherit outputs are special in the sense that outputs are not available until all child nodes have been evaluated.
# File lib/build/graph/node.rb, line 38 def inherit_outputs? @outputs == :inherit end
inspect()
click to toggle source
# File lib/build/graph/node.rb, line 92 def inspect "#<#{self.class} #{@inputs.inspect} => #{@outputs.inspect}>" end
missing?()
click to toggle source
# File lib/build/graph/node.rb, line 47 def missing? @outputs.any?{|path| !path.exist?} || @inputs.any?{|path| !path.exist?} end
modified_time()
click to toggle source
This computes the most recent modified time for all inputs.
# File lib/build/graph/node.rb, line 43 def modified_time @inputs.map{|path| path.modified_time}.max end