feat: break out filesource handling to a proper FilesourceArtefact

This commit is contained in:
David Bailey 2023-04-17 16:52:25 +02:00
parent ca523478aa
commit aa9514b500
2 changed files with 27 additions and 6 deletions

View file

@ -1,6 +1,30 @@
module Comfpile
class FilesourceArtefact < Artefact
attr_reader :filename
alias path filename
alias file filename
def initialize(*args, file: filename, **opts)
super(*args, **opts)
@filename = file
unless File.exist? @filename
fail! "File could not be loaded!"
return
end
# TODO add actual file reading/copying to build dir
end
def mtime
File.mtime(@filename)
end
end
class FilesourceEngine < ArtefactEngine
def initialize(core, **options)
super(core, **options)
@ -15,11 +39,8 @@ module Comfpile
return nil unless File.exists? full_path
a = Artefact.new(@core, self, stage, target);
a[:file] = full_path
a[:filepath] = full_path
a
FilesourceArtefact.new(@core, self, stage, target,
file: full_path);
end
end
end

View file

@ -86,7 +86,7 @@ module Comfpile
param_count = 0
File.readlines(@parent_artefact[:file]).each do |line|
File.readlines(@parent_artefact.file).each do |line|
@search_regexes.each do |r|
next if r[:regex].nil?