[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 0.25.5-639-g8f94f35
test branch
puppet-dev at googlegroups.com
Wed Jul 14 10:31:34 UTC 2010
The following commit has been merged in the upstream branch:
commit df2d39248dd0bb2adc7b4f723722079cad2749ad
Author: Luke Kanies <luke at reductivelabs.com>
Date: Mon Jan 4 16:43:15 2010 -0800
Adding support for parsing ruby files
This doesn't work without the later commits - it just relies
on Ruby to read in Ruby files.
Signed-off-by: Luke Kanies <luke at reductivelabs.com>
diff --git a/lib/puppet/parser/parser_support.rb b/lib/puppet/parser/parser_support.rb
index 1b961cd..df89ed7 100644
--- a/lib/puppet/parser/parser_support.rb
+++ b/lib/puppet/parser/parser_support.rb
@@ -5,6 +5,7 @@ class Puppet::Parser::Parser
require 'puppet/parser/files'
require 'puppet/parser/loaded_code'
require 'puppet/parser/resource_type'
+ require 'puppet/dsl'
require 'monitor'
AST = Puppet::Parser::AST
@@ -83,11 +84,11 @@ class Puppet::Parser::Parser
end
def file=(file)
- unless FileTest.exists?(file)
+ unless FileTest.exist?(file)
unless file =~ /\.pp$/
file = file + ".pp"
end
- unless FileTest.exists?(file)
+ unless FileTest.exist?(file)
raise Puppet::Error, "Could not find file %s" % file
end
end
@@ -317,6 +318,7 @@ class Puppet::Parser::Parser
# how should I do error handling here?
def parse(string = nil)
+ return parse_ruby_file if self.file =~ /\.rb$/
if string
self.string = string
end
@@ -358,6 +360,10 @@ class Puppet::Parser::Parser
@lexer.clear
end
+ def parse_ruby_file
+ require self.file
+ end
+
# See if any of the files have changed.
def reparse?
if file = @files.detect { |name, file| file.changed? }
diff --git a/spec/unit/parser/parser.rb b/spec/unit/parser/parser.rb
index 6a8b0e3..f10517f 100755
--- a/spec/unit/parser/parser.rb
+++ b/spec/unit/parser/parser.rb
@@ -12,6 +12,29 @@ describe Puppet::Parser do
@true_ast = Puppet::Parser::AST::Boolean.new :value => true
end
+ describe "when parsing files" do
+ before do
+ FileTest.stubs(:exist?).returns true
+ File.stubs(:open)
+ @parser.stubs(:check_and_add_to_watched_files).returns true
+ end
+
+ it "should treat files ending in 'rb' as ruby files" do
+ @parser.expects(:parse_ruby_file)
+ @parser.file = "/my/file.rb"
+ @parser.parse
+ end
+
+ describe "in ruby" do
+ it "should use the ruby interpreter to load the file" do
+ @parser.file = "/my/file.rb"
+ @parser.expects(:require).with "/my/file.rb"
+
+ @parser.parse_ruby_file
+ end
+ end
+ end
+
describe "when parsing append operator" do
it "should not raise syntax errors" do
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list