Class: RDoc::PuppetClass

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

Overview

PuppetClass holds a puppet class It is mapped to a HTMLPuppetClass for display It leverages RDoc (ruby) Class

Direct Known Subclasses

PuppetNode

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from AddClassModuleComment

#add_comment

Constructor Details

#initialize(name, superclass) ⇒ PuppetClass


102
103
104
105
106
107
108
# File 'lib/puppet/util/rdoc/code_objects.rb', line 102

def initialize(name, superclass)
  super(name,superclass)
  @resource_list = []
  @requires = []
  @realizes = []
  @childs = []
end

Instance Attribute Details

#childsObject

Returns the value of attribute childs


100
101
102
# File 'lib/puppet/util/rdoc/code_objects.rb', line 100

def childs
  @childs
end

#realizesObject

Returns the value of attribute realizes


100
101
102
# File 'lib/puppet/util/rdoc/code_objects.rb', line 100

def realizes
  @realizes
end

#requiresObject

Returns the value of attribute requires


100
101
102
# File 'lib/puppet/util/rdoc/code_objects.rb', line 100

def requires
  @requires
end

#resource_listObject

Returns the value of attribute resource_list


100
101
102
# File 'lib/puppet/util/rdoc/code_objects.rb', line 100

def resource_list
  @resource_list
end

Instance Method Details

#add_child(child) ⇒ Object


137
138
139
# File 'lib/puppet/util/rdoc/code_objects.rb', line 137

def add_child(child)
  @childs << child
end

#add_realize(realized) ⇒ Object


133
134
135
# File 'lib/puppet/util/rdoc/code_objects.rb', line 133

def add_realize(realized)
  add_to(@realizes, realized)
end

#add_require(required) ⇒ Object

we're (ab)using the RDoc require system here. we're adding a required Puppet class, overriding the RDoc add_require method which sees ruby required files.


129
130
131
# File 'lib/puppet/util/rdoc/code_objects.rb', line 129

def add_require(required)
  add_to(@requires, required)
end

#add_resource(resource) ⇒ Object


114
115
116
# File 'lib/puppet/util/rdoc/code_objects.rb', line 114

def add_resource(resource)
  add_to(@resource_list, resource)
end

#aref_prefixObject


110
111
112
# File 'lib/puppet/util/rdoc/code_objects.rb', line 110

def aref_prefix
  'puppet_class'
end

#find_symbol(symbol, method = nil) ⇒ Object

Look up the given symbol. RDoc only looks for class1::class2.method or class1::class2#method. Since our definitions are mapped to RDoc methods but are written class1::class2::define we need to perform the lookup by ourselves.


145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# File 'lib/puppet/util/rdoc/code_objects.rb', line 145

def find_symbol(symbol, method=nil)
  result = super(symbol)
  if not result and symbol =~ /::/
    modules = symbol.split(/::/)
    unless modules.empty?
      module_name = modules.shift
      result = find_module_named(module_name)
      if result
        last_name = ""
        previous = nil
        modules.each do |mod|
          previous = result
          last_name = mod
          result = result.find_module_named(mod)
          break unless result
        end
        unless result
          result = previous
          method = last_name
        end
      end
    end
    if result && method
      if !result.respond_to?(:find_local_symbol)
        p result.name
        p method
        fail
      end
      result = result.find_local_symbol(method)
    end
  end
  result
end

#is_module?Boolean


118
119
120
# File 'lib/puppet/util/rdoc/code_objects.rb', line 118

def is_module?
  false
end

#superclass=(superclass) ⇒ Object


122
123
124
# File 'lib/puppet/util/rdoc/code_objects.rb', line 122

def superclass=(superclass)
  @superclass = superclass
end