feat: ✨ break out filesource handling to a proper FilesourceArtefact
This commit is contained in:
parent
ca523478aa
commit
aa9514b500
2 changed files with 27 additions and 6 deletions
|
@ -1,6 +1,30 @@
|
||||||
|
|
||||||
|
|
||||||
module Comfpile
|
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
|
class FilesourceEngine < ArtefactEngine
|
||||||
def initialize(core, **options)
|
def initialize(core, **options)
|
||||||
super(core, **options)
|
super(core, **options)
|
||||||
|
@ -15,11 +39,8 @@ module Comfpile
|
||||||
|
|
||||||
return nil unless File.exists? full_path
|
return nil unless File.exists? full_path
|
||||||
|
|
||||||
a = Artefact.new(@core, self, stage, target);
|
FilesourceArtefact.new(@core, self, stage, target,
|
||||||
a[:file] = full_path
|
file: full_path);
|
||||||
a[:filepath] = full_path
|
|
||||||
|
|
||||||
a
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -86,7 +86,7 @@ module Comfpile
|
||||||
|
|
||||||
param_count = 0
|
param_count = 0
|
||||||
|
|
||||||
File.readlines(@parent_artefact[:file]).each do |line|
|
File.readlines(@parent_artefact.file).each do |line|
|
||||||
@search_regexes.each do |r|
|
@search_regexes.each do |r|
|
||||||
next if r[:regex].nil?
|
next if r[:regex].nil?
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue