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) @root_path = options[:root_path] end def craft(stage, target) 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, file: full_path); end end end