-
-
Save pilisera/f563761ebbe437dc448b to your computer and use it in GitHub Desktop.
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' | |
require 'syck' | |
require 'fileutils' | |
if ARGV.empty? | |
$stderr.puts "! Must pass one or more filenames to convert from Syck output to Psych output." | |
exit 1 | |
end | |
bad_files = ARGV.select{ |f| ! File.exists?(f) } | |
if bad_files.any? | |
$stderr.puts "! Aborting because the following files do not exist:" | |
$stderr.puts bad_files | |
exit 1 | |
end | |
ARGV.each do |filename| | |
$stdout.print "Converting #{filename} from Syck to Psych..." | |
hash = Syck.load(File.read filename) | |
FileUtils.cp filename, "#{filename}.bak" | |
File.open(filename, 'w'){ |file| file.write(Psych.dump(hash)) } | |
$stdout.puts " done." | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Forked to work on ruby 2, where you need to require 'syck'.