Class: AwsEc2::Script::Compile

Inherits:
Base
  • Object
show all
Includes:
Template
Defined in:
lib/aws_ec2/script/compile.rb

Constant Summary

Constants inherited from Base

Base::BUILD_ROOT, Base::SCRIPTS_INFO_PATH

Instance Method Summary collapse

Methods included from Template

#context

Methods inherited from Base

#derandomize, #initialize, #randomize

Constructor Details

This class inherits a constructor from AwsEc2::Base

Instance Method Details

#cleanObject



36
37
38
# File 'lib/aws_ec2/script/compile.rb', line 36

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

#compile_allObject

use in compile cli command



15
16
17
18
19
20
# File 'lib/aws_ec2/script/compile.rb', line 15

def compile_all
  clean
  compile_folder("scripts")
  layout_path = context.layout_path(@options[:layout])
  compile_folder("user-data", layout_path)
end

#compile_folder(folder, layout_path = false) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/aws_ec2/script/compile.rb', line 22

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

#compile_scriptsObject

used in upload



9
10
11
12
# File 'lib/aws_ec2/script/compile.rb', line 9

def compile_scripts
  clean
  compile_folder("scripts")
end