summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/ast
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/parser/ast')
-rw-r--r--lib/puppet/parser/ast/collection.rb17
-rw-r--r--lib/puppet/parser/ast/component.rb8
-rw-r--r--lib/puppet/parser/ast/hostclass.rb3
-rw-r--r--lib/puppet/parser/ast/objectdef.rb8
4 files changed, 27 insertions, 9 deletions
diff --git a/lib/puppet/parser/ast/collection.rb b/lib/puppet/parser/ast/collection.rb
index e3afbbd8f..030f1c239 100644
--- a/lib/puppet/parser/ast/collection.rb
+++ b/lib/puppet/parser/ast/collection.rb
@@ -13,7 +13,20 @@ class Puppet::Parser::AST
count = 0
# Now perform the actual collection, yo.
+
+ # First get everything from the export table.
+
+ # FIXME This will only find objects that are before us in the tree,
+ # which is a problem.
+ objects = scope.exported(type)
+
+ array = objects.values
+
Puppet::Rails::RailsObject.find_all_by_collectable(true).each do |obj|
+ if objects.include?(obj.name)
+ debug("%s[%s] is already exported" % [type, obj.name])
+ next
+ end
count += 1
trans = obj.to_trans
@@ -30,13 +43,15 @@ class Puppet::Parser::AST
args[:arguments] = {}
trans.each do |p,v| args[:arguments][p] = v end
-
+
# XXX Because the scopes don't expect objects to return values,
# we have to manually add our objects to the scope. This is
# uber-lame.
scope.setobject(args)
end
+
+
scope.debug("Collected %s objects of type %s" %
[count, type])
diff --git a/lib/puppet/parser/ast/component.rb b/lib/puppet/parser/ast/component.rb
index 5cf3f5c57..317c8ced5 100644
--- a/lib/puppet/parser/ast/component.rb
+++ b/lib/puppet/parser/ast/component.rb
@@ -10,7 +10,7 @@ class Puppet::Parser::AST
# The class name
@name = :component
- attr_accessor :type, :args, :code, :scope, :keyword
+ attr_accessor :type, :args, :code, :scope, :keyword, :collectable
#def evaluate(scope,hash,objtype,objname)
def evaluate(hash)
@@ -19,6 +19,8 @@ class Puppet::Parser::AST
objname = hash[:name]
arguments = hash[:arguments] || {}
+ @collectable = hash[:collectable]
+
pscope = origscope
#pscope = if ! Puppet[:lexical] or hash[:asparent] == false
# origscope
@@ -32,6 +34,10 @@ class Puppet::Parser::AST
)
newcontext = hash[:newcontext]
+ if @collectable or origscope.collectable
+ scope.collectable = true
+ end
+
unless self.is_a? AST::HostClass and ! newcontext
#scope.warning "Setting context to %s" % self.object_id
scope.context = self.object_id
diff --git a/lib/puppet/parser/ast/hostclass.rb b/lib/puppet/parser/ast/hostclass.rb
index 7f381db2a..f66078d7a 100644
--- a/lib/puppet/parser/ast/hostclass.rb
+++ b/lib/puppet/parser/ast/hostclass.rb
@@ -148,7 +148,8 @@ class Puppet::Parser::AST
:scope => scope,
:arguments => args,
:name => name,
- :asparent => true
+ :asparent => true,
+ :collectable => self.collectable
)
else
return false
diff --git a/lib/puppet/parser/ast/objectdef.rb b/lib/puppet/parser/ast/objectdef.rb
index f15a082e2..7ccc9851a 100644
--- a/lib/puppet/parser/ast/objectdef.rb
+++ b/lib/puppet/parser/ast/objectdef.rb
@@ -91,13 +91,9 @@ class Puppet::Parser::AST
:name => objname,
:arguments => hash,
:file => @file,
- :line => @line
+ :line => @line,
+ :collectable => self.collectable
)
-
- # Retain our collectable marking
- if self.collectable
- obj.collectable = true
- end
rescue Puppet::ParseError => except
except.line = self.line
except.file = self.file