Sha256: 05a95ee552c9461a52d2c4b3fb7ef9d52b6cb93fdbfb80dcb83f7d3776cb6cc7

Contents?: true

Size: 1 KB

Versions: 3

Compression:

Stored size: 1 KB

Contents

module Forger
  class Script
    def initialize(options={})
      @options = options
    end

    def add_to_user_data!(user_data)
      user_data
    end

    def auto_terminate_after_timeout
      load_template("auto_terminate_after_timeout.sh")
    end

    def auto_terminate
      # set variables for the template
      @ami_name = @options[:ami_name]
      load_template("auto_terminate.sh")
    end

    def cloudwatch
      load_template("cloudwatch.sh")
    end

    def create_ami
      # set variables for the template
      @ami_name = @options[:ami_name]
      @region = 'us-east-1' if ENV['TEST']
      @region ||= `aws configure get region`.strip rescue 'us-east-1'
      load_template("ami_creation.sh")
    end

    def extract_forger_scripts
      load_template("extract_forger_scripts.sh")
    end

  private
    def load_template(name)
      template = IO.read(File.expand_path("script/templates/#{name}", File.dirname(__FILE__)))
      ERB.new(template, nil, "-").result(binding) # text
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
forger-3.0.2 lib/forger/script.rb
forger-3.0.1 lib/forger/script.rb
forger-3.0.0 lib/forger/script.rb