diff options
Diffstat (limited to 'vendor/supply_drop/lib/supply_drop/syntax_checker.rb')
-rw-r--r-- | vendor/supply_drop/lib/supply_drop/syntax_checker.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/vendor/supply_drop/lib/supply_drop/syntax_checker.rb b/vendor/supply_drop/lib/supply_drop/syntax_checker.rb new file mode 100644 index 0000000..fe9cda4 --- /dev/null +++ b/vendor/supply_drop/lib/supply_drop/syntax_checker.rb @@ -0,0 +1,21 @@ +module SupplyDrop + class SyntaxChecker + def initialize(path) + @path = path + end + + def validate_puppet_files + Dir.glob("#{@path}/**/*.pp").map do |puppet_file| + output = `puppet parser validate #{puppet_file}` + $?.to_i == 0 ? nil : [puppet_file, output] + end.compact + end + + def validate_templates + Dir.glob("#{@path}/**/*.erb").map do |template_file| + output = `erb -x -T '-' #{template_file} | ruby -c 2>&1` + $?.to_i == 0 ? nil : [template_file, output] + end.compact + end + end +end |