Class: RDoc::PuppetModule

Inherits:
NormalModule
  • Object
show all
Includes:
AddClassModuleComment
Defined in:
lib/puppet/util/rdoc/code_objects.rb

Overview

PuppetModule holds a Puppet Module This is mapped to an HTMLPuppetModule it leverage the RDoc (ruby) module infrastructure

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from AddClassModuleComment

#add_comment

Constructor Details

#initialize(name, superclass = nil) ⇒ PuppetModule


32
33
34
35
36
37
# File 'lib/puppet/util/rdoc/code_objects.rb', line 32

def initialize(name,superclass=nil)
  @facts = []
  @plugins = []
  @nodes = {}
  super(name,superclass)
end

Instance Attribute Details

#factsObject

Returns the value of attribute facts


30
31
32
# File 'lib/puppet/util/rdoc/code_objects.rb', line 30

def facts
  @facts
end

#pluginsObject

Returns the value of attribute plugins


30
31
32
# File 'lib/puppet/util/rdoc/code_objects.rb', line 30

def plugins
  @plugins
end

Instance Method Details

#add_fact(fact) ⇒ Object


57
58
59
60
61
62
# File 'lib/puppet/util/rdoc/code_objects.rb', line 57

def add_fact(fact)
  @fact_container ||= add_module(NormalModule, "__facts__")
  confine_str = fact.confine.empty? ? '' : fact.confine.to_s
  const = Constant.new(fact.name, confine_str, fact.comment)
  @fact_container.add_constant(const)
end

#add_node(name, superclass) ⇒ Object

Adds a module called __nodes__ and adds nodes to it as classes


66
67
68
69
70
71
72
73
74
75
# File 'lib/puppet/util/rdoc/code_objects.rb', line 66

def add_node(name,superclass)
  cls = @nodes[name]
  if cls
    return cls
  end
  @node_container ||= add_module(NormalModule, "__nodes__")
  cls = @node_container.add_class(PuppetNode, name, superclass)
  @nodes[name] = cls if !@done_documenting
  cls
end

#add_plugin(plugin) ⇒ Object


39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/puppet/util/rdoc/code_objects.rb', line 39

def add_plugin(plugin)
  name = plugin.name
  type = plugin.type
  meth = AnyMethod.new("*args", name)
  meth.params = "(*args)"
  meth.visibility = :public
  meth.document_self = true
  meth.singleton = false
  meth.comment = plugin.comment
  if type == 'function'
    @function_container ||= add_module(NormalModule, "__functions__")
    @function_container.add_method(meth)
  elsif type == 'type'
    @type_container ||= add_module(NormalModule, "__types__")
    @type_container.add_method(meth)
  end
end

#each_factObject


77
78
79
# File 'lib/puppet/util/rdoc/code_objects.rb', line 77

def each_fact
  @facts.each {|c| yield c}
end

#each_nodeObject


85
86
87
# File 'lib/puppet/util/rdoc/code_objects.rb', line 85

def each_node
  @nodes.each {|c| yield c}
end

#each_pluginObject


81
82
83
# File 'lib/puppet/util/rdoc/code_objects.rb', line 81

def each_plugin
  @plugins.each {|c| yield c}
end

#nodesObject


89
90
91
# File 'lib/puppet/util/rdoc/code_objects.rb', line 89

def nodes
  @nodes.values
end