Sha256: e66889c9b1c2bf4649d2369863ac47b479c11dfcf01f6c17752533ed1baf9db5

Contents?: true

Size: 689 Bytes

Versions: 1

Compression:

Stored size: 689 Bytes

Contents

require 'fileutils'

module AwsEc2
  class CompileScripts < Base
    include TemplateHelper
    BUILD_ROOT = "tmp"

    def compile
      clean
      compile_folder("scripts")
      compile_folder("user-data")
    end

    def compile_folder(folder)
      puts "Compiling app/#{folder}:"
      Dir.glob("#{AwsEc2.root}/app/#{folder}/**/*").each do |path|
        next if File.directory?(path)
        result = erb_result(path)
        tmp_path = path.sub(%r{.*/app/}, "#{BUILD_ROOT}/app/")
        puts "  #{tmp_path}"
        FileUtils.mkdir_p(File.dirname(tmp_path))
        IO.write(tmp_path, result)
      end
    end

    def clean
      FileUtils.rm_rf(BUILD_ROOT)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aws-ec2-0.5.1 lib/aws_ec2/compile_scripts.rb