Class: YARD::Handlers::Chef::Base
- Inherits:
-
Ruby::Base
- Object
- Ruby::Base
- YARD::Handlers::Chef::Base
- Includes:
- CodeObjects::Chef
- Defined in:
- lib/yard-chef/handlers/base.rb
Overview
Base handler for chef elements.
Direct Known Subclasses
ActionHandler, ActionsHandler, AttributeHandler, CookbookHandler, DefinitionHandler, DependencyHandler, RecipeHandler
Instance Method Summary collapse
-
#cookbook ⇒ CookbookObject
Registers the cookbook in Registry and returns the same.
-
#lwrp ⇒ ResourceObject or ProviderObject
Registers the lightweight resource and provider in YARD::Registry and returns the same.
-
#name ⇒ Object
Gets the name of the handled object.
Instance Method Details
#cookbook ⇒ CookbookObject
Registers the cookbook in Registry and returns the same.
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/yard-chef/handlers/base.rb', line 41 def cookbook cookbook_name = '' path_array = File.(statement.file).to_s.split('/') cookbook_name = if path_array.include?('metadata.rb') path_array[path_array.index('metadata.rb') - 1] else path_array[path_array.length - 3] end ChefObject.register(CHEF, cookbook_name, :cookbook) end |
#lwrp ⇒ ResourceObject or ProviderObject
Registers the lightweight resource and provider in YARD::Registry and returns the same.
provider
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/yard-chef/handlers/base.rb', line 58 def lwrp path_array = File.(statement.file).to_s.split('/') if path_array.include?('resources') type = RESOURCE type_sym = :resource elsif path_array.include?('providers') type = PROVIDER type_sym = :provider else raise "Invalid LWRP type #{@path_array.join(',')}" end file_name = path_array.last.to_s.sub('.rb', '') cookbook_obj = cookbook lwrp_name = if file_name == 'default' cookbook_obj.name else "#{cookbook_obj.name}_#{file_name}" end ChefObject.register(type, lwrp_name, type_sym) end |
#name ⇒ Object
Gets the name of the handled object.
33 34 35 |
# File 'lib/yard-chef/handlers/base.rb', line 33 def name statement.parameters.first.jump(:string_content, :ident).source end |