Sha256: 9e317cc9084d930d014d555b5ffca09f9bc49c9d6701384e4f097b44b1b929c5
Contents?: true
Size: 1.26 KB
Versions: 5
Compression:
Stored size: 1.26 KB
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 templates Dir.chdir(@paths['templates']) do Dir.glob('**/*').select { |x| File.file? x } end end def render_templates templates.each do |path| puts "Templating #{path}" template = File.read "#{@paths['templates']}/#{path}" parsed = ERB.new(template, nil, '<>').result(binding) target_path = "#{@paths['build']}/templates/#{path}" FileUtils.mkdir_p File.dirname(target_path) File.open(target_path, 'w') { |fh| fh.write parsed } end end def finalize puts "Packing config into #{@paths['output']}" tar = Dir.chdir(File.dirname(@paths['build'])) { run 'tar cz .' } File.open(@paths['output'], 'w') { |fh| fh << tar } end def easy_mode cleanup @paths.values_at('build', 'output') render_templates run_scripts finalize cleanup @paths.values_at('build') end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
dock0-0.2.5 | lib/dock0/config.rb |
dock0-0.2.4 | lib/dock0/config.rb |
dock0-0.2.3 | lib/dock0/config.rb |
dock0-0.2.2 | lib/dock0/config.rb |
dock0-0.2.1 | lib/dock0/config.rb |