Sha256: 20fde2ecbf5f5a8539e744ec4e5cfac82ee4f2fdf785948207b1897d278adb2d
Contents?: true
Size: 992 Bytes
Versions: 9
Compression:
Stored size: 992 Bytes
Contents
class KuberKit::Preprocessing::FilePreprocessor include KuberKit::Import[ "preprocessing.text_preprocessor" ] PreprocessingError = Class.new(KuberKit::Error) def compile(shell, source_path, destination_path: nil, context_helper: nil) destination_path ||= source_path prepare_destination_dir(destination_path) template = shell.read(source_path) content = text_preprocessor.compile(template, context_helper: context_helper) is_content_changed = template != content if !is_content_changed && source_path == destination_path return false end shell.write(destination_path, content) return true rescue Exception => e message = "#{e.message}\r\n" message += e.backtrace.select{|l| l.include?("(erb)") }.join("\r\n") raise PreprocessingError, "Error while processing template #{source_path}.\r\n#{message}" end def prepare_destination_dir(destination_path) FileUtils.mkdir_p(File.dirname(destination_path)) end end
Version data entries
9 entries across 9 versions & 1 rubygems