diff options
author | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-10-03 20:49:19 +0000 |
---|---|---|
committer | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-10-03 20:49:19 +0000 |
commit | bdadd499402bc12749758ded92588f3f36d04dda (patch) | |
tree | 730925608e7d0c5e406ad08ae62a4c304b47ff0b | |
parent | aee487367ae52afe43b145e4ce645af21640dea6 (diff) |
* ext/psych/lib/psych/visitors/to_ruby.rb: Define Regexp::NOENCODING
for 1.9.2 backwards compatibility.
* ext/psych/lib/psych/visitors/yaml_tree.rb: Fix Date string
generation for 1.9.2 backwards compatibility.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33381 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | ext/psych/lib/psych/visitors/to_ruby.rb | 4 | ||||
-rw-r--r-- | ext/psych/lib/psych/visitors/yaml_tree.rb | 26 |
3 files changed, 32 insertions, 5 deletions
@@ -1,3 +1,10 @@ +Tue Oct 4 05:47:23 2011 Aaron Patterson <aaron@tenderlovemaking.com> + + * ext/psych/lib/psych/visitors/to_ruby.rb: Define Regexp::NOENCODING + for 1.9.2 backwards compatibility. + * ext/psych/lib/psych/visitors/yaml_tree.rb: Fix Date string + generation for 1.9.2 backwards compatibility. + Mon Oct 3 23:56:39 2011 CHIKANAGA Tomoyuki <nagachika00@gmail.com> * gc.c (rb_gc_set_params): output GC parameter change messages only diff --git a/ext/psych/lib/psych/visitors/to_ruby.rb b/ext/psych/lib/psych/visitors/to_ruby.rb index fd899f65a6..b76cd7d5ec 100644 --- a/ext/psych/lib/psych/visitors/to_ruby.rb +++ b/ext/psych/lib/psych/visitors/to_ruby.rb @@ -1,5 +1,9 @@ require 'psych/scalar_scanner' +unless defined?(Regexp::NOENCODING) + Regexp::NOENCODING = 32 +end + module Psych module Visitors ### diff --git a/ext/psych/lib/psych/visitors/yaml_tree.rb b/ext/psych/lib/psych/visitors/yaml_tree.rb index 70db181a95..1f1acdbbcf 100644 --- a/ext/psych/lib/psych/visitors/yaml_tree.rb +++ b/ext/psych/lib/psych/visitors/yaml_tree.rb @@ -311,11 +311,27 @@ module Psych end private - def format_time time - if time.utc? - time.strftime("%Y-%m-%d %H:%M:%S.%9N Z") - else - time.strftime("%Y-%m-%d %H:%M:%S.%9N %:z") + # '%:z' was no defined until 1.9.3 + if RUBY_VERSION < '1.9.3' + def format_time time + formatted = time.strftime("%Y-%m-%d %H:%M:%S.%9N") + + if time.utc? + formatted += " Z" + else + zone = time.strftime('%z') + formatted += " #{zone[0,3]}:#{zone[3,5]}" + end + + formatted + end + else + def format_time time + if time.utc? + time.strftime("%Y-%m-%d %H:%M:%S.%9N Z") + else + time.strftime("%Y-%m-%d %H:%M:%S.%9N %:z") + end end end |