Skip to content

Instantly share code, notes, and snippets.

@rsutphin
Created August 17, 2011 22:24
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 rsutphin/1152801 to your computer and use it in GitHub Desktop.
Save rsutphin/1152801 to your computer and use it in GitHub Desktop.
Demonstrating an issue round-tripping between Syck and Psych. Clone then run syck-psych-syck.sh.
# I'm not sure why but sometimes Syck is used for 'yaml' even under 1.9.2. This forces the issue.
Y =
if RUBY_VERSION =~ /1.9/
require 'psych'
Psych
else
require 'yaml'
YAML
end
FILENAME = 'durations.yml'
$stderr.puts "Updating #{FILENAME} under\n #{RUBY_DESCRIPTION}"
d =
if File.exist?(FILENAME)
Y.load(File.read(FILENAME))
else
{}
end
d[d.size + 1] = ARGV[0]
Y.dump(d, File.open(FILENAME, 'w'))
$ ./syck-psych-syck.sh
Updating durations.yml under
ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin10.8.0]
---
1: "01:03:05"
Updating durations.yml under
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0]
---
1: 01:03:05
2: 02:04:03
Updating durations.yml under
ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin10.8.0]
---
1: 3785
2: 7443
3: "03:05:10"
#!/bin/bash -e
FILENAME=durations.yml
rm -f $FILENAME
rvm 1.8.7 ruby duration_updater.rb '01:03:05'
cat $FILENAME
rvm 1.9.2 ruby duration_updater.rb '02:04:03'
cat $FILENAME
rvm 1.8.7 ruby duration_updater.rb '03:05:10'
cat $FILENAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment