Skip to content

Instantly share code, notes, and snippets.

@SpringMT
Created October 10, 2014 07:50
Show Gist options
  • Save SpringMT/f01e1d9782b1fd1bb9b4 to your computer and use it in GitHub Desktop.
Save SpringMT/f01e1d9782b1fd1bb9b4 to your computer and use it in GitHub Desktop.
yaml_checker.rb
require 'optparse'
require 'yaml'
require 'erb'
require 'pp'
verbose = false
opt = OptionParser.new
opt.on('--verbose') {|v| verbose = v }
opt.parse!(ARGV)
file_name = ARGV.first
begin
file_contents = open(file_name).read
contents = YAML.load(ERB.new(file_contents).result)
rescue => e
puts e
puts "\e[31mFail\e[m"
exit 1
end
if verbose
pp contents
end
puts "\e[32mSuccess\e[m"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment