Class: Cheffish::BasicChefClient
- Inherits:
-
Object
- Object
- Cheffish::BasicChefClient
- Extended by:
- Forwardable
- Includes:
- Chef::DSL::Recipe
- Defined in:
- lib/cheffish/basic_chef_client.rb
Defined Under Namespace
Classes: BasicChefClientEvents, ProviderEventForwarder
Instance Attribute Summary collapse
-
#cookbook_name ⇒ Object
Returns the value of attribute cookbook_name.
-
#recipe_name ⇒ Object
Returns the value of attribute recipe_name.
-
#run_context ⇒ Object
readonly
Stuff recipes need.
Class Method Summary collapse
- .converge_block(node = nil, events = nil, &block) ⇒ Object
- .inline_resource(provider, provider_action, &block) ⇒ Object
Instance Method Summary collapse
- #converge ⇒ Object
-
#initialize(node = nil, events = nil) ⇒ BasicChefClient
constructor
A new instance of BasicChefClient.
- #load_block(&block) ⇒ Object
- #updated? ⇒ Boolean
- #updates ⇒ Object
Methods included from Chef::DSL::Recipe
#get_private_key, #with_chef_data_bag, #with_chef_data_bag_item_encryption, #with_chef_environment, #with_chef_local_server, #with_chef_server
Constructor Details
#initialize(node = nil, events = nil) ⇒ BasicChefClient
Returns a new instance of BasicChefClient.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/cheffish/basic_chef_client.rb', line 16 def initialize(node = nil, events = nil) if !node node = Chef::Node.new node.name 'basic_chef_client' node.automatic[:platform] = 'basic_chef_client' node.automatic[:platform_version] = Cheffish::VERSION end @event_catcher = BasicChefClientEvents.new dispatcher = Chef::EventDispatch::Dispatcher.new(@event_catcher) dispatcher.register(events) if events @run_context = Chef::RunContext.new(node, {}, dispatcher) @updated = [] @cookbook_name = 'basic_chef_client' end |
Instance Attribute Details
#cookbook_name ⇒ Object
Returns the value of attribute cookbook_name.
36 37 38 |
# File 'lib/cheffish/basic_chef_client.rb', line 36 def cookbook_name @cookbook_name end |
#recipe_name ⇒ Object
Returns the value of attribute recipe_name.
37 38 39 |
# File 'lib/cheffish/basic_chef_client.rb', line 37 def recipe_name @recipe_name end |
#run_context ⇒ Object (readonly)
Stuff recipes need
35 36 37 |
# File 'lib/cheffish/basic_chef_client.rb', line 35 def run_context @run_context end |
Class Method Details
.converge_block(node = nil, events = nil, &block) ⇒ Object
65 66 67 68 69 70 |
# File 'lib/cheffish/basic_chef_client.rb', line 65 def self.converge_block(node = nil, events = nil, &block) client = BasicChefClient.new(node, events) client.load_block(&block) client.converge client.updated? end |
.inline_resource(provider, provider_action, &block) ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/cheffish/basic_chef_client.rb', line 57 def self.inline_resource(provider, provider_action, &block) events = ProviderEventForwarder.new(provider, provider_action) client = BasicChefClient.new(provider.node, events) client.load_block(&block) client.converge client.updated? end |
Instance Method Details
#converge ⇒ Object
45 46 47 |
# File 'lib/cheffish/basic_chef_client.rb', line 45 def converge Chef::Runner.new(self).converge end |
#load_block(&block) ⇒ Object
40 41 42 43 |
# File 'lib/cheffish/basic_chef_client.rb', line 40 def load_block(&block) @recipe_name = 'block' instance_eval(&block) end |
#updated? ⇒ Boolean
53 54 55 |
# File 'lib/cheffish/basic_chef_client.rb', line 53 def updated? @event_catcher.updates.size > 0 end |
#updates ⇒ Object
49 50 51 |
# File 'lib/cheffish/basic_chef_client.rb', line 49 def updates @event_catcher.updates end |