Module: Capichef::Environment

Defined in:
lib/capichef/environment.rb

Constant Summary collapse

@@environments =
nil

Class Method Summary collapse

Class Method Details

.has?(environment) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/capichef/environment.rb', line 16

def self.has?(environment)
  return self.list.include?(environment)
end

.listObject



8
9
10
11
12
13
14
# File 'lib/capichef/environment.rb', line 8

def self.list
  if (!@@environments)
    @@environments = Chef::Environment.list.keys
  end
  
  return @@environments
end

.load_into(configuration) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/capichef/environment.rb', line 20

def self.load_into(configuration)
  @@configuration = configuration
  
  configuration.load do            
    _cset :chef_environments, Capichef::Environment.list
    _cset :chef_environment, "_default"
      
    def prompt_chef_environnment(default = "_default", &block)
      begin
        set(:chef_environment) do
          Capistrano::CLI.ui.ask("Chef environment (one of #{Capichef::Environment.list.join(', ')}) [#{default}] : ", &block)
        end
        set :chef_environment, default if chef_environment.to_s.empty?
      end while !Capichef::Environment.has?(chef_environment)
    end
  end
end