Sha256: 8b9a0a00b86089cdd59d9f17296ee4ba5b2f7e3cf739ca54554e76cf12e09ecb

Contents?: true

Size: 1.07 KB

Versions: 17

Compression:

Stored size: 1.07 KB

Contents

require 'fileutils'

# Class for aws-ec2 compile command
class AwsEc2::Script
  class Compile < AwsEc2::Base
    include AwsEc2::Template

    # used in upload
    def compile_scripts
      clean
      compile_folder("scripts")
    end

    # use in compile cli command
    def compile_all
      clean
      compile_folder("scripts")
      layout_path = context.layout_path(@options[:layout])
      compile_folder("user-data", layout_path)
    end

    def compile_folder(folder, layout_path=false)
      puts "Compiling app/#{folder} to tmp/app/#{folder}.".colorize(:green)
      Dir.glob("#{AwsEc2.root}/app/#{folder}/**/*").each do |path|
        next if File.directory?(path)
        next if path.include?("layouts")

        result = RenderMePretty.result(path, layout: layout_path, context: context)
        tmp_path = path.sub(%r{.*/app/}, "#{BUILD_ROOT}/app/")
        puts "  #{tmp_path}" if @options[:verbose]
        FileUtils.mkdir_p(File.dirname(tmp_path))
        IO.write(tmp_path, result)
      end
    end

    def clean
      FileUtils.rm_rf("#{BUILD_ROOT}/app")
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
aws-ec2-1.4.9 lib/aws_ec2/script/compile.rb
aws-ec2-1.4.8 lib/aws_ec2/script/compile.rb
aws-ec2-1.4.7 lib/aws_ec2/script/compile.rb
aws-ec2-1.4.6 lib/aws_ec2/script/compile.rb
aws-ec2-1.4.5 lib/aws_ec2/script/compile.rb
aws-ec2-1.4.4 lib/aws_ec2/script/compile.rb
aws-ec2-1.4.3 lib/aws_ec2/script/compile.rb
aws-ec2-1.4.2 lib/aws_ec2/script/compile.rb
aws-ec2-1.4.1 lib/aws_ec2/script/compile.rb
aws-ec2-1.4.0 lib/aws_ec2/script/compile.rb
aws-ec2-1.3.2 lib/aws_ec2/script/compile.rb
aws-ec2-1.3.1 lib/aws_ec2/script/compile.rb
aws-ec2-1.3.0 lib/aws_ec2/script/compile.rb
aws-ec2-1.2.2 lib/aws_ec2/script/compile.rb
aws-ec2-1.2.1 lib/aws_ec2/script/compile.rb
aws-ec2-1.2.0 lib/aws_ec2/script/compile.rb
aws-ec2-1.1.0 lib/aws_ec2/script/compile.rb