diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-04-04 22:23:08 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-04-04 22:23:08 +0000 |
commit | d8b4b0dbf35b2b183cd62adf591ebf4650448a0d (patch) | |
tree | d51d99be35d0702ffc08bd0e8a28e82d8daf2e6b /lib/puppet/parser | |
parent | c0a9e5f2e9df8e6e1aed74653ae675029af8a9bb (diff) | |
download | puppet-d8b4b0dbf35b2b183cd62adf591ebf4650448a0d.tar.gz puppet-d8b4b0dbf35b2b183cd62adf591ebf4650448a0d.tar.xz puppet-d8b4b0dbf35b2b183cd62adf591ebf4650448a0d.zip |
adding -e ability to puppet executable
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1065 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/parser')
-rw-r--r-- | lib/puppet/parser/interpreter.rb | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/lib/puppet/parser/interpreter.rb b/lib/puppet/parser/interpreter.rb index 4f5f1f69a..730b59e15 100644 --- a/lib/puppet/parser/interpreter.rb +++ b/lib/puppet/parser/interpreter.rb @@ -42,11 +42,11 @@ module Puppet # create our interpreter def initialize(hash) - unless hash.include?(:Manifest) - raise Puppet::DevError, "Interpreter was not passed a manifest" + if @code = hash[:Code] + @file = nil # to avoid warnings + elsif ! @file = hash[:Manifest] + raise Puppet::DevError, "You must provide code or a manifest" end - - @file = hash[:Manifest] @filetimeout = hash[:ParseCheck] || 15 @lastchecked = 0 @@ -258,24 +258,26 @@ module Puppet end def parsefiles - if defined? @parser - # Only check the files every 15 seconds or so, not on - # every single connection - if (Time.now - @lastchecked).to_i >= @filetimeout.to_i - unless @parser.reparse? - @lastchecked = Time.now - return false + if @file + if defined? @parser + # Only check the files every 15 seconds or so, not on + # every single connection + if (Time.now - @lastchecked).to_i >= @filetimeout.to_i + unless @parser.reparse? + @lastchecked = Time.now + return false + end + else + return end - else - return end - end - unless FileTest.exists?(@file) - if @ast - return - else - raise Puppet::Error, "Manifest %s must exist" % @file + unless FileTest.exists?(@file) + if @ast + return + else + raise Puppet::Error, "Manifest %s must exist" % @file + end end end @@ -284,7 +286,11 @@ module Puppet end # should i be creating a new parser each time...? @parser = Puppet::Parser::Parser.new() - @parser.file = @file + if @code + @parser.string = @code + else + @parser.file = @file + end @ast = @parser.parse # Mark when we parsed, so we can check freshness |