class YARD::Handlers::Chef::Base

Base handler for chef elements.

Public Instance Methods

cookbook() click to toggle source

Registers the cookbook in {YARD::Registry} and returns the same.

@return [ChefObject] the ChefObject

# File lib/yard-chefdoc/handlers/base.rb, line 27
def cookbook
  cbs = YARD::Registry.all(:cookbook)
  raise 'Something went wrong! Found more that one cookbook.' if cbs.length > 1
  raise 'Something went wrong! Could not find any cookbook' if cbs.empty?

  cbs.first
end
filename() click to toggle source

Gets the filename which is often used as the object name in chef

@return [String] the file name without the rb extension

# File lib/yard-chefdoc/handlers/base.rb, line 19
def filename
  File.basename(statement.file, '.rb')
end
name() click to toggle source

Gets the name of the handled object.

# File lib/yard-chefdoc/handlers/base.rb, line 11
def name
  statement.parameters.first.jump(:string_content, :ident).source
end