19
21
@watched_files = {}
24
def import_ast(ast, modname)
25
ast.instantiate(modname).each do |instance|
23
31
"TypeCollection" + { :hostclasses => @hostclasses.keys, :definitions => @definitions.keys, :nodes => @nodes.keys }.inspect
96
104
@definitions[munge_name(name)]
99
def find(namespaces, name, type)
100
#Array("") == [] for some reason
101
namespaces = [namespaces] unless namespaces.is_a?(Array)
104
return send(type, name.sub(/^::/, ''))
107
namespaces.each do |namespace|
108
ary = namespace.split("::")
111
tmp_namespace = ary.join("::")
112
if r = find_partially_qualified(tmp_namespace, name, type)
116
# Delete the second to last object, which reduces our namespace by one.
120
if result = send(type, name)
127
def find_or_load(namespaces, name, type)
129
namespaces = [namespaces] unless namespaces.is_a?(Array)
130
namespaces = namespaces.collect { |ns| ns.downcase }
132
# This could be done in the load_until, but the knowledge seems to
134
if r = find(namespaces, name, type)
138
loader.load_until(namespaces, name) { find(namespaces, name, type) }
141
107
def find_node(namespaces, name)
142
find("", name, :node)
108
@nodes[munge_name(name)]
145
111
def find_hostclass(namespaces, name)
159
def perform_initial_import
160
parser = Puppet::Parser::Parser.new(environment)
161
if code = Puppet.settings.uninterpolated_value(:code, environment.to_s) and code != ""
164
file = Puppet.settings.value(:manifest, environment.to_s)
171
msg = "Could not parse for environment #{environment}: #{detail}"
172
error = Puppet::Error.new(msg)
173
error.set_backtrace(detail.backtrace)
177
125
def require_reparse?
178
126
@parse_failed || stale?
209
def find_partially_qualified(namespace, name, type)
210
send(type, [namespace, name].join("::"))
157
# Return a list of all possible fully-qualified names that might be
158
# meant by the given name, in the context of namespaces.
159
def resolve_namespaces(namespaces, name)
162
# name is explicitly fully qualified, so just return it, sans
164
return [name.sub(/^::/, '')]
167
# The name "" has special meaning--it always refers to a "main"
168
# hostclass which contains all toplevel resources.
172
namespaces = [namespaces] unless namespaces.is_a?(Array)
173
namespaces = namespaces.collect { |ns| ns.downcase }
176
namespaces.each do |namespace|
177
ary = namespace.split("::")
179
# Search each namespace nesting in innermost-to-outermost order.
181
result << "#{ary.join("::")}::#{name}"
185
# Finally, search the toplevel namespace.
192
# Resolve namespaces and find the given object. Autoload it if
194
def find_or_load(namespaces, name, type)
195
resolve_namespaces(namespaces, name).each do |fqname|
196
if result = send(type, fqname) || loader.try_load_fqname(type, fqname)
213
205
def munge_name(name)