class CookbookBumper::Config

Attributes

cookbook_path[W]
environment_path[W]
exclude_environments[RW]
knife_path[RW]
repo_root[RW]

Public Class Methods

new() { |self| ... } click to toggle source
# File lib/cookbook_bumper/config.rb, line 7
def initialize
  @exclude_environments = %w[development]
  @knife_path = File.expand_path('.chef/knife.rb')
  @repo_root = File.expand_path('.')
  yield(self) if block_given?
end

Public Instance Methods

config_already_read?() click to toggle source
# File lib/cookbook_bumper/config.rb, line 27
def config_already_read?
  @knife_path == @knife_path_read
end
cookbook_path() click to toggle source
# File lib/cookbook_bumper/config.rb, line 14
def cookbook_path
  @cookbook_path || Array(fetch_chef_config(:cookbook_path)).map { |p| File.expand_path(p) }
end
environment_path() click to toggle source
# File lib/cookbook_bumper/config.rb, line 18
def environment_path
  @environment_path || Array(fetch_chef_config(:environment_path)).map { |p| File.expand_path(p) }
end
fetch_chef_config(config_name) click to toggle source
# File lib/cookbook_bumper/config.rb, line 22
def fetch_chef_config(config_name)
  read_chef_config unless config_already_read?
  Chef::Config.send(config_name)
end
read_chef_config() click to toggle source
# File lib/cookbook_bumper/config.rb, line 31
def read_chef_config
  Chef::Config.from_file(@knife_path)
  @knife_path_read = @knife_path
end