Class: Oldskool::Puppetdoc
- Inherits:
-
Object
- Object
- Oldskool::Puppetdoc
- Defined in:
- lib/oldskool/puppetdoc.rb
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #doc ⇒ Object
-
#initialize(type) ⇒ Puppetdoc
constructor
A new instance of Puppetdoc.
- #loadall ⇒ Object
- #paramdoc(param) ⇒ Object
- #settype(type) ⇒ Object
Constructor Details
#initialize(type) ⇒ Puppetdoc
Returns a new instance of Puppetdoc.
7 8 9 10 11 |
# File 'lib/oldskool/puppetdoc.rb', line 7 def initialize(type) loadall settype(type) end |
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/oldskool/puppetdoc.rb', line 5 def type @type end |
Instance Method Details
#doc ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/oldskool/puppetdoc.rb', line 43 def doc param_docs = {:name => type.name, :description => type.doc, :version => Puppet.version, :params => {}, :metaparams => {}} type.parameters.each {|param| param_docs[:params][param] = paramdoc(param)} type.validproperties.each {|param| param_docs[:params][param] = paramdoc(param)} type..each {|param| param_docs[:metaparams][param] = paramdoc(param)} param_docs end |
#loadall ⇒ Object
13 14 15 |
# File 'lib/oldskool/puppetdoc.rb', line 13 def loadall Puppet::Type.loadall unless Puppet::Type.constants.include?("File") end |
#paramdoc(param) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/oldskool/puppetdoc.rb', line 22 def paramdoc(param) doc = {} if type.parameters.include?(param) doc[:markdown] = type.attrclass(param).doc doc[:type] = :param elsif type.validproperties.include?(param) doc[:markdown] = type.propertybyname(param).doc doc[:type] = :property elsif type..include?(param) doc[:markdown] = type.attrclass(param).doc doc[:type] = :meta end if type.key_attributes.include?(param) and param != :name doc[:type] = :namevar end doc end |
#settype(type) ⇒ Object
17 18 19 20 |
# File 'lib/oldskool/puppetdoc.rb', line 17 def settype(type) raise "Cannot find Puppet Type #{type}" unless Puppet::Type.const_defined?(type.capitalize) @type = Puppet::Type.const_get(type.capitalize) end |