Skip to content

Instantly share code, notes, and snippets.

@r0h1t4sh
Last active April 21, 2016 20:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save r0h1t4sh/5948614 to your computer and use it in GitHub Desktop.
Save r0h1t4sh/5948614 to your computer and use it in GitHub Desktop.
Recursively validate yml files in a directory using ruby
require 'yaml'
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}/**/*.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!"
raise e
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment