Sha256: 2514fc54c54b6b0e465696ccf33e092f82a708ce1b023ff2005b1f07d00c6d6c

Contents?: true

Size: 599 Bytes

Versions: 2

Compression:

Stored size: 599 Bytes

Contents

require 'erb'

class Indocker::Images::TemplateCompiler
  def compile(path, context, image)
    if !image.compile?(file)
      Indocker.logger.debug("skipping ERB compilation for #{path}".grey)
      return
    end

    Indocker.logger.debug("compiling template file #{path}".grey)
    template = File.read(path)
    content = ERB.new(template).result(context.helper.get_binding)
    File.write(path, content)
  rescue Errno::EACCES => e
    # do nothing for read only files
  rescue => e
    Indocker.logger.error("compilation failed for template file #{path}. #{e.inspect}")
    raise e
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
indocker-0.3.3 lib/indocker/images/template_compiler.rb
indocker-0.3.2 lib/indocker/images/template_compiler.rb