Sha256: ed5e782171fa357272164faf6dd2844710251b19b0dcbcec91c3b5f31ac51dcc

Contents?: true

Size: 1.15 KB

Versions: 4

Compression:

Stored size: 1.15 KB

Contents

require "yaml"

module Jack
  class Create
    include Util

    def initialize(options={})
      @options = options
      @root = options[:root] || '.'
      @env_name = options[:env_name]
      @app_name = options[:app] || app_name_convention(@env_name)
    end

    def run
      create_app
      EbConfig::Create.new(@options).sync unless @options[:noop]
      create_env
    end

    def create_app
      eb.create_application(
        application_name: @app_name
      ) unless app_exist?
    end

    def app_exist?
      return true if @options[:noop]
      r = eb.describe_applications
      r.applications.collect(&:application_name).include?(@app_name)
    end

    def create_env
      command = build_command
      do_cmd(command, @options)
    end

    def build_command
      @cfg = upload_cfg
      flags = settings.create_flags
      "eb create --sample --nohang #{flags} #{@cfg}#{cname}#{@env_name}"
    end

    def upload_cfg
      @upload = Config::Upload.new(@options)
      if @upload.local_cfg_exist?
        @upload.upload 
        cfg = "--cfg #{@upload.upload_name} "
      end
    end

    def cname
      "--cname #{@env_name} "
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jack-eb-1.0.1 lib/jack/create.rb
jack-eb-1.0.0 lib/jack/create.rb
jack-eb-0.3.0 lib/jack/create.rb
jack-eb-0.2.0 lib/jack/create.rb