Module: ORS::Config::ModuleMethods

Included in:
ORS::Config
Defined in:
lib/ors/config.rb

Instance Method Summary collapse

Instance Method Details

#parse_config_fileObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/ors/config.rb', line 28

def parse_config_file
  if File.exists?(CONFIG_FILENAME)
    YAML.load(File.read(CONFIG_FILENAME)).each {|(name, value)| send "#{name}=", value }
  else
    self.gateway          = "deploy-gateway"
    self.deploy_user      = "deployer"
    self.repo             = "ors_git"
    self.base_path        = "/var/www"
    self.web_servers      = %w(koala)
    self.app_servers      = %w(eel jellyfish squid)
    self.migration_server = "tuna"
    self.console_server   = "tuna"
    self.cron_server      = "tuna"
  end
end

#parse_options(options) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/ors/config.rb', line 16

def parse_options options
  self.name = name_from_git
  self.environment = options.shift unless options.empty? or options.first.match(/^-/)

  options.each do |option|
    case option
      when "-p", "--pretend" then self.pretending = true
      when "-ng", "--no-gateway" then self.use_gateway = false
    end
  end
end

#valid_environmentsObject



48
49
50
# File 'lib/ors/config.rb', line 48

def valid_environments
  %w(production demo staging)
end

#valid_options?Boolean

Returns:



44
45
46
# File 'lib/ors/config.rb', line 44

def valid_options?
  name.to_s.size > 0 and valid_environments.include?(environment)
end