Class: SupplyDrop::SyntaxChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/supply_drop/syntax_checker.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ SyntaxChecker

Returns a new instance of SyntaxChecker.



3
4
5
# File 'lib/supply_drop/syntax_checker.rb', line 3

def initialize(path)
  @path = path
end

Instance Method Details

#validate_puppet_filesObject



7
8
9
10
11
12
# File 'lib/supply_drop/syntax_checker.rb', line 7

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

#validate_templatesObject



14
15
16
17
18
19
# File 'lib/supply_drop/syntax_checker.rb', line 14

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