Module: ORS::Config::ModuleMethods

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

Instance Method Summary collapse

Instance Method Details

#gitObject



54
55
56
# File 'lib/ors/config.rb', line 54

def git
  @git ||= Git.open(Dir.pwd)
end

#parse_config_fileObject



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

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



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

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

  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



50
51
52
# File 'lib/ors/config.rb', line 50

def valid_environments
  %w(production demo staging)
end

#valid_options?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/ors/config.rb', line 46

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