Skip to content

Instantly share code, notes, and snippets.

@jhass
Created December 30, 2011 17:53
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 jhass/1540794 to your computer and use it in GitHub Desktop.
Save jhass/1540794 to your computer and use it in GitHub Desktop.
Simple script that tries to load it's arguments as YAML files. Don't forget to chmod +x it.
#!/usr/bin/env ruby
require 'yaml'
files = ARGV
if !files.nil? && files.length >= 1
files.each do |file|
if File.exists?(file) && File.file?(file)
begin
print "checking #{file}..."
YAML.load_file file
puts " looks good"
rescue Psych::SyntaxError => e
puts "is invalid!"
raise e
rescue
puts "is not a valid (YAML) file!"
end
else
puts "#{file} does not exists or is not a file"
end
end
else
puts "Usage: #{File.basename(__FILE__)} path/to/yaml/file path/to/another/yaml/file ..."
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment