Skip to content

Instantly share code, notes, and snippets.

@endzyme
Forked from r0h1t4sh/validate_ymls.rb
Last active December 21, 2015 00:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save endzyme/6222546 to your computer and use it in GitHub Desktop.
Save endzyme/6222546 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'yaml'
exit_code = 0
if ARGV.length != 1
puts "Usage: ruby validate_ymls.rb directory_absolute_path"
exit!
end
base_path = ARGV[0].chomp("/")
base_dir = Dir.glob("#{base_path}/**/*.yaml") + Dir.glob("#{base_path}/**/*.yml")
base_dir.each do |file_name|
#puts "validating #{file_name}"
begin
env_constants = YAML::load(open(file_name))
rescue Exception => e
puts "ERROR!!! #{file_name} contains error! Message: #{e.message}"
exit_code = 1
end
end
if exit_code == 0
puts "No Errors Detected in loading Yamls"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment