Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Psych treats CAS registry numbers as dates #58

Closed
erebor opened this Issue · 1 comment

1 participant

@erebor

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:in
tokenize'

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

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

@erebor erebor closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.