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

@ -61,10 +61,10 @@ module Comfpile
end
def craft(stage, target)
def craft(stage, target, context)
return unless stage == :config_file
ConfigArtefact.new(@core, self, stage, target)
ConfigArtefact.new(@core, self, stage, target, context)
end
end
end

View file

@ -32,14 +32,14 @@ module Comfpile
@root_path = options[:root_path]
end
def craft(stage, target)
def craft(stage, target, context)
return nil unless stage == :sourcefile
full_path = File.join(@root_path, target)
return nil unless File.exists? full_path
FilesourceArtefact.new(@core, self, stage, target,
FilesourceArtefact.new(@core, self, stage, target, context,
file: full_path);
end
end

View file

@ -205,28 +205,28 @@ module Comfpile
raise ArgumentError, "Missing regex parsing array!" unless @search_regexes.is_a? Array
end
def generate_parser_artefact(stage, target)
def generate_parser_artefact(stage, target, context)
match = @input_file_regex.match target
return nil if match.nil?
ParserArtefact.new(@core, self, stage, target,
ParserArtefact.new(@core, self, stage, target, context,
search_regexes: @search_regexes)
end
def generate_dependency_analysis_artefact(stage, target, **opts)
def generate_dependency_analysis_artefact(stage, target, context, **opts)
match = @input_file_regex.match target
return nil if match.nil?
DependencyAnalysisArtefact.new(@core, self, stage, target, **opts)
DependencyAnalysisArtefact.new(@core, self, stage, target, context, **opts)
end
def craft(stage, target)
def craft(stage, target, context)
case stage
when :parsed
generate_parser_artefact(stage, target)
generate_parser_artefact(stage, target, context)
when /^dependency_analysis(?:_(.+))?$/
traverse = $1&.split('_')
generate_dependency_analysis_artefact(stage, target, traverse: traverse)
generate_dependency_analysis_artefact(stage, target, context, traverse: traverse)
else
nil
end