Sha256: c82cfdf554ee9c62c53500d7ac33273e236039ce432965589ae89be3c91cd184

Contents?: true

Size: 1.16 KB

Versions: 4

Compression:

Stored size: 1.16 KB

Contents

module EY
  class Account
    class Environment < ApiStruct.new(:id, :name, :instances_count, :apps, :app_master, :username, :account)
      def self.from_hash(hash)
        super.tap do |env|
          env.username = hash['ssh_username']
          env.apps = App.from_array(env.apps, env.account)
          env.app_master = AppMaster.from_hash(env.app_master)
        end
      end

      def logs
        account.logs_for(self)
      end

      def instances
        account.instances_for(self)
      end

      def rebuild
        account.rebuild(self)
      end

      def recipe_file
        require 'tempfile'
        unless File.exist?("cookbooks")
          raise EY::Error, "Could not find chef recipes. Please run from the root of your recipes repo."
        end

        tmp = Tempfile.new("recipes")
        cmd = "git archive --format=tar HEAD cookbooks | gzip > #{tmp.path}"

        unless system(cmd)
          raise EY::Error, "Could not archive recipes.\nCommand `#{cmd}` exited with an error."
        end

        tmp
      end

      def configuration
        EY.config.environments[self.name]
      end
      alias_method :config, :configuration
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
engineyard-0.3.1 lib/engineyard/account/environment.rb
engineyard-0.3.0 lib/engineyard/account/environment.rb
engineyard-0.2.13 lib/engineyard/account/environment.rb
engineyard-0.2.12 lib/engineyard/account/environment.rb