Class: EnvironmentsController

Inherits:
Object
  • Object
show all
Defined in:
lib/dew/controllers/environments_controller.rb

Instance Method Summary collapse

Instance Method Details

#before_get_environment(name) ⇒ Object

a rough before filter



43
44
45
46
# File 'lib/dew/controllers/environments_controller.rb', line 43

def before_get_environment(name)
  @environment = Environment.get(name)
  raise "Environment named #{name} not found!" unless @environment
end

#create(name, profile_name, opts = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/dew/controllers/environments_controller.rb', line 5

def create(name, profile_name, opts={})
  profile = Profile.read(profile_name)
  if opts[:force] || (
    Inform.info("About to create environment %{name} using the following profile:\n%{profile}" , :name => name, :profile => profile.to_s)
    agree("<%= color('Do you wish to continue?', YELLOW, BOLD) %> ")
  )
    environment = Environment.create(name, profile)
    environment.show
    environment
  else
    Inform.info "Aborting environment creation"
  end
end

#destroy(name, opts = {}) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/dew/controllers/environments_controller.rb', line 29

def destroy name, opts={}
  before_get_environment name

  @environment.show
  Inform.info "Destroying environment %{name} ...", :name => name
  if opts[:force] || agree("<%= color('Are you sure?', YELLOW, BOLD) %> ")
    @environment.destroy
    Inform.info "Environment %{name} destroyed", :name => name
  else
    Inform.info "Aborting environment destruction"
  end
end

#indexObject



19
20
21
# File 'lib/dew/controllers/environments_controller.rb', line 19

def index
  Environment.index
end

#show(name, options = {}) ⇒ Object



23
24
25
26
27
# File 'lib/dew/controllers/environments_controller.rb', line 23

def show(name, options = {})
  before_get_environment name

  @environment.show(options)
end