diff --git a/lib/comfpile/engines/filesource_engine.rb b/lib/comfpile/engines/filesource_engine.rb index d040256..81d8482 100644 --- a/lib/comfpile/engines/filesource_engine.rb +++ b/lib/comfpile/engines/filesource_engine.rb @@ -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 \ No newline at end of file diff --git a/lib/comfpile/engines/parser_engine.rb b/lib/comfpile/engines/parser_engine.rb index 1ceee95..0f6c1c6 100644 --- a/lib/comfpile/engines/parser_engine.rb +++ b/lib/comfpile/engines/parser_engine.rb @@ -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?