Sha256: cbe557198c3ad1cf580c45eb2c96f52fb85bf7d7850f6cf095a5e505e92a4a23

Contents?: true

Size: 784 Bytes

Versions: 4

Compression:

Stored size: 784 Bytes

Contents

require 'erb'
require 'fileutils'

module Dock0
  ##
  # A Config is a system-specific customization layer
  class Config < Base
    def default_config
      {
        paths: {
          templates: './templates',
          scripts: './scripts',
          build: './build/config',
          output: './build.tar.gz'
        }
      }
    end

    def finalize
      puts "Packing config into #{@paths[:output]}"
      tar = Dir.chdir(File.dirname(@paths[:build])) do
        run 'tar -cz --owner=root --group=root *'
      end
      File.open(@paths[:output], 'w') { |fh| fh << tar }
    end

    def easy_mode
      cleanup @paths.values_at(:build, :output)
      render_templates('templates')
      run_scripts
      finalize
      cleanup @paths.values_at(:build)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dock0-0.4.4 lib/dock0/config.rb
dock0-0.4.2 lib/dock0/config.rb
dock0-0.4.1 lib/dock0/config.rb
dock0-0.4.0 lib/dock0/config.rb