Class: Unsub::Service::Chef::Config

Inherits:
Buff::Config::Ruby
  • Object
show all
Defined in:
lib/unsub/service/chef/config.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, options = {}) ⇒ Config

Returns a new instance of Config.



33
34
35
# File 'lib/unsub/service/chef/config.rb', line 33

def initialize(path, options = {})
  super(path || self.class.location, options)
end

Class Method Details

.locationObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/unsub/service/chef/config.rb', line 11

def location
  possibles = []
  possibles << ENV['CHEF_CONFIG'] if ENV['CHEF_CONFIG']
  possibles << File.join(ENV['KNIFE_HOME'], 'knife.rb') if ENV['KNIFE_HOME']
  possibles << File.join(Dir.pwd, 'knife.rb')
  possibles << File.join(ENV['HOME'], '.chef', 'knife.rb') if ENV['HOME']
  possibles.compact!

  location = possibles.find { |loc| File.exists?(File.expand_path(loc)) }
  File.expand_path(location) unless location.nil?
end