Sha256: 0a84dba705819dc85aebbfbb86ebdef91af0dfb984c0d76519669ebd324bb8c0

Contents?: true

Size: 1.15 KB

Versions: 4

Compression:

Stored size: 1.15 KB

Contents

module EbDeployer
  class Application
    def initialize(name, eb_driver, s3_driver, bucket = nil)
      @name = name
      @eb_driver = eb_driver
      @s3_driver = s3_driver
      @bucket = bucket
      raise "application name can only contain any combination of uppercase letters, lowercase letters, numbers, dashes (-)" unless @name =~ /^[a-zA-Z0-9.-]+$/
    end

    def create_version(version_label, package)
      create_application_if_not_exists

      package = Package.new(package, @bucket + ".packages", @s3_driver)
      package.upload

      unless @eb_driver.application_version_labels.include?(version_label)
        @eb_driver.create_application_version(@name, version_label, package.source_bundle)
      end
    end

    def delete
      if @eb_driver.application_exists?(@name)
        @eb_driver.environment_names_for_application(@name).each do |env|
          @eb_driver.delete_environment(@name, env)
        end

        @eb_driver.delete_application(@name)
      end
    end

    private

    def create_application_if_not_exists
      unless @eb_driver.application_exists?(@name)
        @eb_driver.create_application(@name)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
eb_deployer-0.2.9 lib/eb_deployer/application.rb
eb_deployer-0.2.8 lib/eb_deployer/application.rb
eb_deployer-0.2.7 lib/eb_deployer/application.rb
eb_deployer-0.2.6 lib/eb_deployer/application.rb