Class: YARD::CodeObjects::Chef::ProviderObject
- Inherits:
-
ChefObject
- Object
- YARD::CodeObjects::ClassObject
- ChefObject
- YARD::CodeObjects::Chef::ProviderObject
- Defined in:
- lib/yard-chef/code_objects/provider_object.rb
Overview
A ProviderObject represents a lightweight provider in Chef. See docs.opscode.com/essentials_cookbook_lwrp.html
Instance Attribute Summary
Attributes inherited from ChefObject
Instance Method Summary collapse
-
#actions ⇒ Array<ActionObject>
Actions implemented in the lightweight provider.
-
#initialize(namespace, name) ⇒ ProviderObject
constructor
Creates a new instance of ProviderObject.
-
#long_name ⇒ String
Constructs class name for the lightweight provider.
-
#map_resource(file) ⇒ Object
Maps provider with a lightweight resource.
Methods inherited from ChefObject
#children_by_type, #cookbooks, register, register_element
Constructor Details
#initialize(namespace, name) ⇒ ProviderObject
Creates a new instance of ProviderObject.
provider belongs
40 41 42 43 |
# File 'lib/yard-chef/code_objects/provider_object.rb', line 40 def initialize(namespace, name) super(namespace, name) @description = '' end |
Instance Method Details
#actions ⇒ Array<ActionObject>
Actions implemented in the lightweight provider.
81 82 83 |
# File 'lib/yard-chef/code_objects/provider_object.rb', line 81 def actions children_by_type(:action) end |
#long_name ⇒ String
Constructs class name for the lightweight provider.
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/yard-chef/code_objects/provider_object.rb', line 49 def long_name name = '' if @name.to_s =~ /_/ @name.to_s.split('_').each do |str| name << str.to_s.capitalize end else name = @name.to_s.capitalize end namespace = @namespace.to_s.split('::').map(&:capitalize) "#{namespace.join('::')}::#{name}" end |
#map_resource(file) ⇒ Object
Maps provider with a lightweight resource.
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/yard-chef/code_objects/provider_object.rb', line 66 def map_resource(file) file_handle = File.open(File.(file), 'r') file_handle.readlines.each do |line| next unless line =~ /#\s@resource/ resource_name = line.split(/@resource /)[1].strip @resource = ChefObject.register(RESOURCE, resource_name, :resource) @resource.providers.push(self) unless @resource.providers.include?(self) break end end |