Class: Chef::Resource::ChefGem

Inherits:
Package::GemPackage
  • Object
show all
Defined in:
lib/chef/resource/chef_gem.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, run_context = nil) ⇒ ChefGem

Returns a new instance of ChefGem.


28
29
30
31
32
# File 'lib/chef/resource/chef_gem.rb', line 28

def initialize(name, run_context=nil)
  super
  @resource_name = :chef_gem
  @provider = Chef::Provider::Package::Rubygems
end

Instance Method Details

#after_createdObject


43
44
45
46
47
48
49
50
# File 'lib/chef/resource/chef_gem.rb', line 43

def after_created
  # Chef::Resource.run_action: Caveat: this skips Chef::Runner.run_action, where notifications are handled
  # Action could be an array of symbols, but probably won't (think install + enable for a package)
  Array(@action).each do |action|
    self.run_action(action)
  end
  Gem.clear_paths
end

#gem_binary(arg = nil) ⇒ Object

The chef_gem resources is for installing gems to the current gem environment only for use by Chef cookbooks.


35
36
37
38
39
40
41
# File 'lib/chef/resource/chef_gem.rb', line 35

def gem_binary(arg=nil)
  if arg
    raise ArgumentError, "The chef_gem resource is restricted to the current gem environment, use gem_package to install to other environments."
  end

  nil
end