class EY::Config
Constants
- CONFIG_FILES
This order is important.
- TEMPLATE_PATHNAME
Attributes
path[R]
Public Class Methods
load_config(path = pathname)
click to toggle source
# File lib/engineyard/config.rb, line 24 def self.load_config(path = pathname) config = YAML.load_file(path.to_s) if path && path.exist? config ||= {} # load_file returns `false' when the file is empty unless Hash === config raise "ey.yml load error: Expected a Hash but a #{config.class.name} was returned." end config end
new(file = nil)
click to toggle source
# File lib/engineyard/config.rb, line 36 def initialize(file = nil) @path = file ? Pathname.new(file) : self.class.pathname @config = self.class.load_config(@path) @config["environments"] ||= {} end
pathname()
click to toggle source
# File lib/engineyard/config.rb, line 16 def self.pathname CONFIG_FILES.find{|pathname| pathname.exist? } end
pathname_for_write()
click to toggle source
# File lib/engineyard/config.rb, line 12 def self.pathname_for_write pathname || CONFIG_FILES.find{|pathname| pathname.dirname.exist? } end
template_pathname()
click to toggle source
# File lib/engineyard/config.rb, line 20 def self.template_pathname TEMPLATE_PATHNAME end
Public Instance Methods
[](key)
click to toggle source
# File lib/engineyard/config.rb, line 64 def [](key) @config[key.to_s.downcase] end
default_endpoint()
click to toggle source
# File lib/engineyard/config.rb, line 76 def default_endpoint "https://cloud.engineyard.com/" end
default_endpoint?()
click to toggle source
# File lib/engineyard/config.rb, line 80 def default_endpoint? default_endpoint == endpoint end
default_environment()
click to toggle source
# File lib/engineyard/config.rb, line 84 def default_environment d = environments.find do |name, env| env && env["default"] end d && d.first end
defaults()
click to toggle source
# File lib/engineyard/config.rb, line 91 def defaults @config['defaults'] ||= {} end
endpoint()
click to toggle source
# File lib/engineyard/config.rb, line 68 def endpoint env_var_endpoint || default_endpoint end
env_var_endpoint()
click to toggle source
# File lib/engineyard/config.rb, line 72 def env_var_endpoint ENV["CLOUD_URL"] end
environment_config(environment_name)
click to toggle source
# File lib/engineyard/config.rb, line 95 def environment_config(environment_name) environments[environment_name] ||= {} EnvironmentConfig.new(environments[environment_name], environment_name, self) end
fetch(key, default = nil, &block)
click to toggle source
# File lib/engineyard/config.rb, line 56 def fetch(key, default = nil, &block) block ? @config.fetch(key.to_s, &block) : @config.fetch(key.to_s, default) end
fetch_from_defaults(key, default=nil, &block)
click to toggle source
# File lib/engineyard/config.rb, line 60 def fetch_from_defaults(key, default=nil, &block) block ? defaults.fetch(key.to_s, &block) : defaults.fetch(key.to_s, default) end
method_missing(meth, *args, &blk)
click to toggle source
Calls superclass method
# File lib/engineyard/config.rb, line 42 def method_missing(meth, *args, &blk) key = meth.to_s.downcase if @config.key?(key) @config[key] else super end end
respond_to?(meth)
click to toggle source
Calls superclass method
# File lib/engineyard/config.rb, line 51 def respond_to?(meth) key = meth.to_s.downcase @config.key?(key) || super end