Class: EYCli::Model::Environment

Inherits:
Base
  • Object
show all
Defined in:
lib/ey_cli/models/environment.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

all, base_path, child_path, class_name, collection_path, #convert_value, create, find, find_by_name, resolve_child_path

Methods included from SmartyParser

#parse, #smarty

Class Method Details

.create_collection_path(hash) ⇒ Object

Raises:

  • (Faraday::Error::ClientError)


6
7
8
9
10
# File 'lib/ey_cli/models/environment.rb', line 6

def self.create_collection_path(hash)
  app = hash.delete(:app)
  raise Faraday::Error::ClientError, {:body => MultiJson.encode({:errors => {:app => 'Not found'}})} unless app
  base_path % app.id
end

Instance Method Details

#deploy(app, options = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ey_cli/models/environment.rb', line 12

def deploy(app, options = {})
  deployment_options = deployment_configurations[app.name]

  post_params = {
    'deployment[migrate]'         => options.key?(:migrate) ? options[:migrate] : deployment_options.migrate.perform,
    'deployment[migrate_command]' => options[:migrate_command] || deployment_options.migrate.command,
    'deployment[ref]'             => options[:ref] || deployment_options.ref || 'HEAD'
  }

  response = EYCli.api.post(deploy_path(app), nil, post_params)
  Hashie::Mash.new response['deployment']
rescue Faraday::Error::ClientError => e
  Hashie::Mash.new MultiJson.decode(e.response[:body])
end

#deploy_path(app) ⇒ Object



27
28
29
# File 'lib/ey_cli/models/environment.rb', line 27

def deploy_path(app)
  Deployment.deploy_path(app, self)
end

#last_deployment(app) ⇒ Object



31
32
33
# File 'lib/ey_cli/models/environment.rb', line 31

def last_deployment(app)
  Deployment.last_deployment(app, self)
end