class YARD::Handlers::Chef::ActionsHandler

Handles list of actions in a lightweight resource.

Public Instance Methods

process() click to toggle source
# File lib/yard-chef/handlers/actions.rb, line 31
def process
  # Register the lightweight resource
  resource_obj = lwrp
  resource_obj.add_file(statement.file)

  # Add the lightweight resource to the cookbook in which it is defined
  cookbook_obj = cookbook
  unless cookbook_obj.resources.include?(resource_obj)
    cookbook_obj.resources.push(resource_obj)
  end

  # if multiple actions listed in same line, split the actions and
  # register them
  if statement.first_line =~ /,/
    statement.first_line.split(/,?\s*:/).each do |_action|
      action = ChefObject.register(resource_obj, name, :action)
    end
  else
    action = ChefObject.register(resource_obj, name, :action)
    action.docstring = statement.docstring
  end

  log.info "Found [Actions] in #{parser.file}"
end