Sha256: 73241c19c083dd9bb9da18a3c0b549b2e6b17d686d3e8c8dc00b89c9abb92a81

Contents?: true

Size: 791 Bytes

Versions: 1

Compression:

Stored size: 791 Bytes

Contents

require 'fileutils'

# Class for aws-ec2 upload_scripts command
class AwsEc2::Script
  class Upload < AwsEc2::Base
    def initialize(options={})
      @options = options
      @compile = @options[:compile] ? @options[:compile] : true
    end

    def upload
      compiler.compile if @compile
      sync_scripts_to_s3
      compiler.clean if @compile and !ENV['AWS_EC2_KEEP']
    end

    def sync_scripts_to_s3
      puts "Uploading tmp/app to s3..."
      s3_bucket = AwsEc2.config["scripts_s3_bucket"]
      s3_path = AwsEc2.config["scripts_s3_path"] || "ec2/app"
      sh "aws s3 sync tmp/app s3://#{s3_bucket}/#{s3_path}"
    end

    def sh(command)
      puts "=> #{command}"
      system command
    end

    def compiler
      @compiler ||= Compile.new(@options)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aws-ec2-0.8.1 lib/aws_ec2/script/upload.rb