Sha256: e08f4cd6b8ae1b94f026446b16b7c51b6a62593878eb6b43e93f0b1869861c1c
Contents?: true
Size: 874 Bytes
Versions: 2
Compression:
Stored size: 874 Bytes
Contents
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 def use_syck YAML::ENGINE.yamler = 'syck' raise "Oops! Something went horribly wrong." unless YAML == Syck end def use_psych YAML::ENGINE.yamler = 'psych' raise "Oops! Something went horribly wrong." unless YAML == Psych end ARGV.each do |filename| $stdout.print "Converting #{filename} from Syck to Psych..." use_syck hash = YAML.load(File.read filename) FileUtils.cp filename, "#{filename}.bak" use_psych File.open(filename, 'w'){ |file| file.write(YAML.dump(hash)) } $stdout.puts " done." end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
code_rippa-1.0.1 | lib/code_rippa/syntax/yaml_converter.rb |
code_rippa-1.0.0 | lib/code_rippa/syntax/yaml_converter.rb |