Method: Chef::Recipe.parse_recipe_name

Defined in:
lib/chef/recipe.rb

.parse_recipe_name(recipe_name, current_cookbook: nil) ⇒ Object

Parses a potentially fully-qualified recipe name into its cookbook name and recipe short name.

For example:

"aws::elastic_ip" returns [:aws, "elastic_ip"]
"aws" returns [:aws, "default"]
"::elastic_ip" returns [ current_cookbook, "elastic_ip" ]

– TODO: Duplicates functionality of RunListItem



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/chef/recipe.rb', line 45

def self.parse_recipe_name(recipe_name, current_cookbook: nil)
  case recipe_name
  when /(.+?)::(.+)/
    [ $1.to_sym, $2 ]
  when /^::(.+)/
    raise "current_cookbook is nil, cannot resolve #{recipe_name}" if current_cookbook.nil?

    [ current_cookbook.to_sym, $1 ]
  else
    [ recipe_name.to_sym, "default" ]
  end
end