Module: Chef::Sugar::Kernel

Defined in:
lib/chef/sugar/kernel.rb

Defined Under Namespace

Classes: ChefGemLoadError

Instance Method Summary collapse

Instance Method Details

#require_chef_gem(name) ⇒ Boolean

Require a gem that should have been installed by Chef, such as in a recipes as a chef_gem. This method will gracefully degrade if the gem cannot be loaded.

Parameters:

  • name (String)

    the name of the gem to install

Returns:

  • (Boolean)

    true if the require is successful and false if the gem is already loaded


42
43
44
45
46
# File 'lib/chef/sugar/kernel.rb', line 42

def require_chef_gem(name)
  require(name)
rescue LoadError
  raise ChefGemLoadError.new(name)
end