Last active
April 21, 2016 20:53
-
-
Save r0h1t4sh/5948614 to your computer and use it in GitHub Desktop.
Recursively validate yml files in a directory using ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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