summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2005-09-10 18:47:44 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2005-09-10 18:47:44 +0000
commitee1eba23029ecbc29e75dc9646519bda49fa46b0 (patch)
tree5e7c9586fcc211077d4bb6b4ab3aa435619df36e
parentf69abc9e69781f94ec37e8c879fb6b0f4bb465da (diff)
downloadpuppet-ee1eba23029ecbc29e75dc9646519bda49fa46b0.tar.gz
puppet-ee1eba23029ecbc29e75dc9646519bda49fa46b0.tar.xz
puppet-ee1eba23029ecbc29e75dc9646519bda49fa46b0.zip
small updates
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@643 980ebf18-57e1-0310-9a29-db15c13687c0
-rwxr-xr-xbin/cf2puppet68
1 files changed, 47 insertions, 21 deletions
diff --git a/bin/cf2puppet b/bin/cf2puppet
index 1f380b79c..8253d8394 100755
--- a/bin/cf2puppet
+++ b/bin/cf2puppet
@@ -55,29 +55,55 @@ module Cf2Puppet
@params = {}
end
end
-end
-def handle(file)
-end
+ class Parser
+ def initialize(file)
+ @file = file
+ @dir = File.dirname(file)
+
+ unless FileTest.exists?(file)
+ $stderr.puts "%s does not exist" % file
+ exit(18)
+ end
+ end
-def parse(file)
- begin
- File.open(file) { |f|
- f.foreach { |line|
- case line.chomp
- when /(\w+):\s*\n/:
- $action = $1
- when /(\w+):\s*\n/:
- $action = $1
- end
- }
- }
- rescue Errno::ENOENT => detail
- $stderr.puts "File %s not found" % file
- return
- rescue Errno::EACCES => detail
- $stderr.puts "Could not open file %s" % file
- return
+ def parse
+ begin
+ File.open(@file) { |f|
+ str = f.read
+
+ # get rid of comments
+ str.gsub(/#.+\n/)
+ str.gsub(/^\s*$/, '') # and blank lines
+
+ while str do
+ case str
+ when /\A(\w+):[^:]/n:
+ action = $1
+ end
+ end
+ f.foreach { |line|
+ case line.chomp
+ when /(\w+):\s*\n/:
+ $action = $1
+ when /(\w+):\s*\n/:
+ $action = $1
+ end
+ }
+ }
+ rescue Errno::ENOENT => detail
+ $stderr.puts "File %s not found" % file
+ return
+ rescue Errno::EACCES => detail
+ $stderr.puts "Could not open file %s" % file
+ return
+ end
+ end
+
+ module Actions
+ def import
+ end
+ end
end
end