Psych treats CAS registry numbers as dates #58

Closed
erebor opened this Issue Apr 7, 2012 · 1 comment

Projects

None yet

1 participant

@erebor
erebor commented Apr 7, 2012

When trying to yaml-ize Chemical Abstract Service numbers (http://en.wikipedia.org/wiki/CAS_registry_number), the format of the string leads psych to think it's a date.

For instance, the CAS registry number of water is '7732-18-5'. So we get this:

1.9.3p0 :043 > {:cas => '7732-18-5'}.to_yaml
ArgumentError: invalid date
from /Users/rew/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/psych/scalar_scanner.rb:45:in strptime' from /Users/rew/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/psych/scalar_scanner.rb:45:intokenize'

The regexp being triggered is thusly:

  when /^\d{4}-\d{1,2}-\d{1,2}$/

There my be a way to alter psych's behavior other than hacking up a copy of the gem, but I don't know what it might be. Unfortunately, I don't have the option to convince the CAS people to not use 4-digit-prefix CAS numbers. :)

erebor commented Apr 7, 2012

Mea culpa, didn't check the closed issues to see that this is duplicate of #47 and #42 .

@erebor erebor closed this Apr 7, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment