feat: port artefact context to other functions

This commit is contained in:
David Bailey 2023-04-20 09:49:54 +02:00
parent 1878186c4f
commit fe23382dcc
5 changed files with 29 additions and 28 deletions

View file

@ -47,7 +47,7 @@ module Comfpile
# Meta-States exist:
# - in_progress/completed: Anything but/Only succeeded, skipped, failed
def initialize(core, engine, stage, target, **opts)
def initialize(core, engine, stage, target, context, **opts)
raise ArgumentError, "Unknown options supplied!" unless opts.empty?
@core = core
@ -55,8 +55,7 @@ module Comfpile
@stage = stage
@target = target
@age = Time.at(0)
@context = @core.sanitize_context context
@parent_artefact = nil
@ -136,26 +135,26 @@ module Comfpile
})
end
def parent_artefact(stage, target)
@parent_artefact = require_artefact(stage, target)
def parent_artefact(stage, target, context = @context)
@parent_artefact = require_artefact(stage, target, context)
end
def include_artefact(stage, target, **opts)
artefact = require_artefact(stage, target, **opts)
def include_artefact(stage, target, context = @context, **opts)
artefact = require_artefact(stage, target, context, **opts)
@included_artefacts << artefact
artefact
end
def require_artefact(stage, target, **opts)
artefact = reference_artefact(stage, target, required: true, **opts)
def require_artefact(stage, target, context = @context, **opts)
artefact = reference_artefact(stage, target, context, required: true, **opts)
@required_artefacts << artefact
artefact
end
def reference_artefact(stage, target, required: false)
artefact = craft_artefact(stage, target)
def reference_artefact(stage, target, context = @context, required: false)
artefact = craft_artefact(stage, target, context)
wait_on(artefact) if required
@ -207,12 +206,12 @@ module Comfpile
# found that can craft this, else returns the
# created or looked-up artefact.
#
def craft_artefact(stage, target)
@core.craft_artefact(stage, target)
def craft_artefact(stage, target, context = @context)
@core.craft_artefact(stage, target, context)
end
def find_artefact(stage, target)
@core.find_artefact(stage, target)
def find_artefact(stage, target, context = @context)
@core.find_artefact(stage, target, context)
end
def waitlist_empty?