Sha256: 17b4a34f5e8fdd9805feeb475862b44e2a7f14c1ff73e7bf7da8a9c8583c8481

Contents?: true

Size: 861 Bytes

Versions: 4

Compression:

Stored size: 861 Bytes

Contents

require 'engineyard/action/util'

module EY
  module Action
    class Rebuild
      extend Util

      def self.call(name)
        env = fetch_environment_by_name(name) || fetch_environment_from_app
        EY.ui.debug("Rebuilding #{env.name}")
        env.rebuild
      end

      private
      def self.fetch_environment_by_name(name)
        if name
          env = account.environment_named(name)
          return env if env
          raise NoEnvironmentError.new(name)
        end
      end

      def self.fetch_environment_from_app
        repo = Repo.new
        app = account.app_for_repo(repo) or raise NoAppError.new(repo)
        env = app.one_and_only_environment or raise EnvironmentError, "Unable to determine a single environment for the current application (found #{app.environments.size} environments)"
        env
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
engineyard-0.3.1 lib/engineyard/action/rebuild.rb
engineyard-0.3.0 lib/engineyard/action/rebuild.rb
engineyard-0.2.13 lib/engineyard/action/rebuild.rb
engineyard-0.2.12 lib/engineyard/action/rebuild.rb