class PuppetStrings::Yard::Handlers::Ruby::TypeHandler
Implements the handler for Puppet
resource types written in Ruby.
Constants
- DEFAULT_ENSURABLE_DOCSTRING
-
The default docstring when ensurable is used without given a docstring.
Private Instance Methods
Source
# File lib/puppet-strings/yard/handlers/ruby/type_handler.rb, line 43 def populate_type_data(object) # Traverse the block looking for properties/parameters/features block = statement.block return unless block && block.count >= 2 block[1].children.each do |node| next unless node.is_a?(YARD::Parser::Ruby::MethodCallNode) && node.method_name method_name = node.method_name.source parameters = node.parameters(false) case method_name when 'newproperty' # Add a property to the object next unless parameters.count >= 1 name = node_as_string(parameters[0]) next unless name object.add_property(create_property(name, node)) when 'newparam' # Add a parameter to the object next unless parameters.count >= 1 name = node_as_string(parameters[0]) next unless name object.add_parameter(create_parameter(name, node)) when 'newcheck' # Add a check to the object next unless parameters.count >= 1 name = node_as_string(parameters[0]) next unless name object.add_check(create_check(name, node)) when 'feature' # Add a feature to the object next unless parameters.count >= 2 name = node_as_string(parameters[0]) next unless name docstring = node_as_string(parameters[1]) next unless docstring object.add_feature(PuppetStrings::Yard::CodeObjects::Type::Feature.new(name, docstring)) when 'ensurable' if node.block property = create_property('ensure', node) property.docstring = DEFAULT_ENSURABLE_DOCSTRING if property.docstring.empty? else property = PuppetStrings::Yard::CodeObjects::Type::Property.new('ensure', DEFAULT_ENSURABLE_DOCSTRING) property.add('present') property.add('absent') property.default = 'present' end object.add_property property end end end