module Dockerb
Constants
- GENERATED
- SEARCH
- VERSION
Public Class Methods
compile(docker_file="Dockerfile") { || ... }
click to toggle source
# File lib/dockerb.rb, line 9 def compile(docker_file="Dockerfile", &block) return (yield if block) unless File.exist?("#{docker_file}.erb") ensure_not_older_than_last(docker_file) compile_dockerfile(docker_file, &block) end
Private Class Methods
compile_dockerfile(docker_file) { || ... }
click to toggle source
# File lib/dockerb.rb, line 24 def compile_dockerfile(docker_file, &block) File.write(docker_file, Context.compile(File.read("#{docker_file}.erb"))) yield if block ensure File.unlink(docker_file) if File.exist?(docker_file) && block end
ensure_not_older_than_last(docker_file)
click to toggle source
# File lib/dockerb.rb, line 17 def ensure_not_older_than_last(docker_file) return unless File.exist?(docker_file) return unless old = File.read(docker_file)[SEARCH, 1] return unless Gem::Version.new(old) > Gem::Version.new(VERSION) raise "Previous file was generated by dockerb #{old}, use it or a newer version." end