Parent

WhiskeyDisk::Config

Public Instance Methods

base_path() click to toggle source
# File lib/whiskey_disk/config.rb, line 73
def base_path
  path || find_rakefile_from_current_path
end
check_staleness?() click to toggle source
# File lib/whiskey_disk/config.rb, line 21
def check_staleness?
  env_flag_is_true?('check')
end
configuration_data() click to toggle source

called only by load_data

# File lib/whiskey_disk/config.rb, line 89
def configuration_data
  open(configuration_file) {|f| f.read }
end
configuration_file() click to toggle source
# File lib/whiskey_disk/config.rb, line 25
def configuration_file
  return path if valid_path?(path)
  
  files = []

  files += [
    File.join(base_path, 'deploy', specified_project_name, "#{environment_name}.yml"),  # /deploy/foo/staging.yml
    File.join(base_path, 'deploy', "#{specified_project_name}.yml") # /deploy/foo.yml
  ] if specified_project_name

  files += [
    File.join(base_path, 'deploy', "#{environment_name}.yml"),  # /deploy/staging.yml
    File.join(base_path, "#{environment_name}.yml"), # /staging.yml
    File.join(base_path, 'deploy.yml') # /deploy.yml
  ]

  files.each { |file|  return file if File.exists?(file) }

  raise "Could not locate configuration file in path [#{base_path}]"
end
contains_rakefile?(path) click to toggle source
# File lib/whiskey_disk/config.rb, line 58
def contains_rakefile?(path)
  File.exists?(File.expand_path(File.join(path, 'Rakefile')))
end
debug?() click to toggle source
# File lib/whiskey_disk/config.rb, line 13
def debug?
  env_flag_is_true?('debug')
end
domain_limit() click to toggle source
# File lib/whiskey_disk/config.rb, line 17
def domain_limit
  env_key_or_false?('only')
end
environment_name() click to toggle source
# File lib/whiskey_disk/config.rb, line 46
def environment_name
  return false unless env_has_key?('to')
  return ENV['to'] unless ENV['to'] =~ /:/
  ENV['to'].split(/:/)[1]
end
fetch() click to toggle source
# File lib/whiskey_disk/config.rb, line 8
def fetch
  raise "Cannot determine current environment -- try rake ... to=staging, for example." unless environment_name
  filter_data(load_data)
end
filter() click to toggle source
# File lib/whiskey_disk/config.rb, line 100
def filter
  @filter ||= WhiskeyDisk::Config::Filter.new(self)
end
filter_data(data) click to toggle source

called only by fetch

# File lib/whiskey_disk/config.rb, line 105
def filter_data(data)
  filter.filter_data(data)
end
find_rakefile_from_current_path() click to toggle source
# File lib/whiskey_disk/config.rb, line 62
def find_rakefile_from_current_path
  original_path = Dir.pwd
  while (!contains_rakefile?(Dir.pwd))
    return File.join(original_path, 'config') if Dir.pwd == '/'
    Dir.chdir('..')
  end
  File.join(Dir.pwd, 'config')
ensure
  Dir.chdir(original_path)
end
load_data() click to toggle source

called only by fetch

# File lib/whiskey_disk/config.rb, line 94
def load_data
  YAML.load(configuration_data)
rescue Exception => e
  raise %{Error reading configuration file [#{configuration_file}]: "#{e}"}
end
project_name() click to toggle source
# File lib/whiskey_disk/config.rb, line 84
def project_name
  specified_project_name || 'unnamed_project'
end
specified_project_name() click to toggle source
# File lib/whiskey_disk/config.rb, line 52
def specified_project_name
  return false unless env_has_key?('to')
  return false unless ENV['to'] =~ /:/
  ENV['to'].split(/:/).first
end
valid_path?(path) click to toggle source
# File lib/whiskey_disk/config.rb, line 77
def valid_path?(path)
  return false unless path
  uri = URI.parse(path)
  return path if uri.scheme
  return path if File.file?(path)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.