Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add ruby_block function

  • Loading branch information...
commit cb4f4fdfcb4090720e46487094788e77677e85c6 1 parent 930fe36
@drnic drnic authored
Showing with 52 additions and 0 deletions.
  1. +2 −0  README.md
  2. +50 −0 libraries/ruby_block.rb
View
2  README.md
@@ -2,6 +2,8 @@
DESCRIPTION HERE
+`ruby_block` is provided for recipes wanting to run on Chef 0.6 as well as modern Chef.
+
## Installation
INSTALLATION HERE
View
50 libraries/ruby_block.rb
@@ -0,0 +1,50 @@
+# RubyBlock (ruby_block) implementation that supports chef 0.6 + chef 0.10
+class Chef
+ class Resource
+ class RubyBlock < Chef::Resource
+ if Chef::VERSION == '0.6.0.2'
+ def initialize(name, collection=nil, node = nil)
+ super(name, collection, node)
+ init
+ end
+ else
+ def initialize(name, run_context=nil)
+ super(name, run_context)
+ init
+ end
+ end
+
+ def init
+ @resource_name = :ruby_block
+ @action = :create
+ @allowed_actions.push(:create)
+ end
+
+ def block(&block)
+ if block
+ @block = block
+ else
+ @block
+ end
+ end
+ end
+ end
+end
+
+
+class Chef
+ class Provider
+ class RubyBlock < Chef::Provider
+ def load_current_resource
+ true
+ end
+
+ def action_create
+ @new_resource.block.call
+ end
+ end
+ end
+end
+
+Chef::Platform.platforms[:default].merge! :ruby_block => Chef::Provider::RubyBlock
+
Please sign in to comment.
Something went wrong with that request. Please try again.