Sha256: 433e44dbdb3b1d1ca00549ed77b2ad13418ea7069c6b1ea8322dbcd30ba6f9e9

Contents?: true

Size: 601 Bytes

Versions: 5

Compression:

Stored size: 601 Bytes

Contents

require 'erb'

class Indocker::Images::TemplateCompiler
  def compile(path, context, image)
    if !image.compile?(path)
      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

5 entries across 5 versions & 1 rubygems

Version Path
indocker-0.3.9 lib/indocker/images/template_compiler.rb
indocker-0.3.8 lib/indocker/images/template_compiler.rb
indocker-0.3.7 lib/indocker/images/template_compiler.rb
indocker-0.3.6 lib/indocker/images/template_compiler.rb
indocker-0.3.5 lib/indocker/images/template_compiler.rb