Class: YARD::Handlers::Chef::ActionsHandler

Inherits:
Base
  • Object
show all
Defined in:
lib/yard-chef/handlers/actions.rb

Overview

Handles list of actions in a lightweight resource.

Instance Method Summary collapse

Methods inherited from Base

#cookbook, #lwrp, #name

Instance Method Details

#processObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# 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