Module: PoiseProfiler::CoreExt::RunContext Private

Defined in:
lib/poise_profiler/core_ext/run_context.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Monkeypatch extensions for Chef::RunContext to add support for the recipe_file_loaded event on older Chef.

Since:

  • 1.1.0

Constant Summary collapse

PRE_MAGIC_EVENTS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 1.1.0

Gem::Version.create(Chef::VERSION) < Gem::Version.create('12.5.1')

Instance Method Summary collapse

Instance Method Details

#load_recipe(recipe_name, current_cookbook: nil) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 1.1.0



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/poise_profiler/core_ext/run_context.rb', line 31

def load_recipe(recipe_name, current_cookbook: nil)
  super.tap do |ret|
    cookbook_name, recipe_short_name = Chef::Recipe.parse_recipe_name(recipe_name, current_cookbook: current_cookbook)
    cookbook = cookbook_collection[cookbook_name]
    recipe_path = cookbook.recipe_filenames_by_name[recipe_short_name]
    if PRE_MAGIC_EVENTS
      events.recipe_file_loaded(recipe_path)
    else
      events.recipe_file_loaded(recipe_path, recipe_name)
    end
  end
end