aboutsummaryrefslogtreecommitdiff
path: root/vendor/supply_drop/lib/supply_drop/syntax_checker.rb
blob: fe9cda4007bb131a0d4212b68e9d13c3171bf2b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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