class MotherBrain::Chef::Config
Handles loading configuration values from a Chef
config file
Constants
- DEFAULT_PATHS
Public Class Methods
new(path = nil)
click to toggle source
@param [String] path
# File lib/mb/chef/config.rb, line 13 def initialize(path = nil) @path = path end
Public Instance Methods
parse()
click to toggle source
Parse the file for the path and store symbolicated keys for knife configuration options.
@return [Knife] self
# File lib/mb/chef/config.rb, line 21 def parse parse_file self end
Private Instance Methods
current_dir()
click to toggle source
Because it’s common to set the local variable current_dir
in a knife.rb and then interpolate that into strings, set it here because that’s hard to parse.
# File lib/mb/chef/config.rb, line 64 def current_dir File.dirname(file_path) end
file_contents()
click to toggle source
# File lib/mb/chef/config.rb, line 45 def file_contents File.read(file_path) rescue String.new end
file_path()
click to toggle source
# File lib/mb/chef/config.rb, line 51 def file_path File.expand_path(path) end
lines()
click to toggle source
# File lib/mb/chef/config.rb, line 41 def lines file_contents.lines.to_a end
method_missing(key, value = nil)
click to toggle source
# File lib/mb/chef/config.rb, line 37 def method_missing(key, value = nil) store key.to_sym, value end
parse_file()
click to toggle source
# File lib/mb/chef/config.rb, line 28 def parse_file lines.each { |line| parse_line line } end
parse_line(line)
click to toggle source
# File lib/mb/chef/config.rb, line 32 def parse_line(line) eval line, binding rescue end
path()
click to toggle source
# File lib/mb/chef/config.rb, line 55 def path @path ||= DEFAULT_PATHS.find { |path| File.exist?(File.expand_path(path)) } end