Class: Itamae::Recipe
- Inherits:
-
Object
- Object
- Itamae::Recipe
- Defined in:
- lib/itamae/recipe.rb
Defined Under Namespace
Classes: EvalContext
Constant Summary collapse
- NotFoundError =
Class.new(StandardError)
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#delayed_notifications ⇒ Object
readonly
Returns the value of attribute delayed_notifications.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#runner ⇒ Object
readonly
Returns the value of attribute runner.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(runner, path) ⇒ Recipe
constructor
A new instance of Recipe.
- #run(options = {}) ⇒ Object
Constructor Details
#initialize(runner, path) ⇒ Recipe
Returns a new instance of Recipe.
28 29 30 31 32 33 34 35 |
# File 'lib/itamae/recipe.rb', line 28 def initialize(runner, path) @runner = runner @path = path @delayed_notifications = [] context = EvalContext.new(self) @children = context.children end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
9 10 11 |
# File 'lib/itamae/recipe.rb', line 9 def children @children end |
#delayed_notifications ⇒ Object (readonly)
Returns the value of attribute delayed_notifications.
10 11 12 |
# File 'lib/itamae/recipe.rb', line 10 def delayed_notifications @delayed_notifications end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
7 8 9 |
# File 'lib/itamae/recipe.rb', line 7 def path @path end |
#runner ⇒ Object (readonly)
Returns the value of attribute runner.
8 9 10 |
# File 'lib/itamae/recipe.rb', line 8 def runner @runner end |
Class Method Details
.find_recipe_in_gem(recipe) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/itamae/recipe.rb', line 13 def find_recipe_in_gem(recipe) target = recipe.gsub('::', '/') target += '.rb' if target !~ /\.rb$/ plugin_name = recipe.split('::')[0] spec = Gem.loaded_specs.values.find do |spec| spec.name == "itamae-plugin-recipe-#{plugin_name}" end return nil unless spec File.join(spec.lib_dirs_glob, 'itamae', 'plugin', 'recipe', target) end |
Instance Method Details
#run(options = {}) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/itamae/recipe.rb', line 37 def run( = {}) Logger.info "Recipe: #{@path}" Logger.formatter.indent do @children.run() @delayed_notifications.uniq do |notification| [notification.action, notification.action_resource] end.each do |notification| notification.run() end end end |