summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/parser_support.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/parser/parser_support.rb')
-rw-r--r--lib/puppet/parser/parser_support.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/puppet/parser/parser_support.rb b/lib/puppet/parser/parser_support.rb
index 288abb582..16cd0ee0f 100644
--- a/lib/puppet/parser/parser_support.rb
+++ b/lib/puppet/parser/parser_support.rb
@@ -146,8 +146,7 @@ class Puppet::Parser::Parser
# how should I do error handling here?
def parse(string = nil)
if self.file =~ /\.rb$/
- parse_ruby_file
- main = nil
+ main = parse_ruby_file
else
self.string = string if string
begin
@@ -189,7 +188,11 @@ class Puppet::Parser::Parser
def parse_ruby_file
# Execute the contents of the file inside its own "main" object so
# that it can call methods in the resource type API.
- Puppet::DSL::ResourceTypeAPI.new.instance_eval(File.read(self.file))
+ main_object = Puppet::DSL::ResourceTypeAPI.new
+ main_object.instance_eval(File.read(self.file))
+
+ # Then extract any types that were created.
+ Puppet::Parser::AST::ASTArray.new :children => main_object.instance_eval { @__created_ast_objects__ }
end
def string=(string)