[前][次][番号順一覧][スレッド一覧]

ruby-changes:21332

From: tenderlove <ko1@a...>
Date: Tue, 4 Oct 2011 05:49:37 +0900 (JST)
Subject: [ruby-changes:21332] tenderlove:r33381 (trunk): * ext/psych/lib/psych/visitors/to_ruby.rb: Define Regexp::NOENCODING

tenderlove	2011-10-04 05:49:19 +0900 (Tue, 04 Oct 2011)

  New Revision: 33381

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=33381

  Log:
    * 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.

  Modified files:
    trunk/ChangeLog
    trunk/ext/psych/lib/psych/visitors/to_ruby.rb
    trunk/ext/psych/lib/psych/visitors/yaml_tree.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 33380)
+++ ChangeLog	(revision 33381)
@@ -1,3 +1,10 @@
+Tue Oct  4 05:47:23 2011  Aaron Patterson <aaron@t...>
+
+	* 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@g...>
 
 	* gc.c (rb_gc_set_params): output GC parameter change messages only
Index: ext/psych/lib/psych/visitors/yaml_tree.rb
===================================================================
--- ext/psych/lib/psych/visitors/yaml_tree.rb	(revision 33380)
+++ ext/psych/lib/psych/visitors/yaml_tree.rb	(revision 33381)
@@ -311,12 +311,28 @@
       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
 
       # FIXME: remove this method once "to_yaml_properties" is removed
Index: ext/psych/lib/psych/visitors/to_ruby.rb
===================================================================
--- ext/psych/lib/psych/visitors/to_ruby.rb	(revision 33380)
+++ ext/psych/lib/psych/visitors/to_ruby.rb	(revision 33381)
@@ -1,5 +1,9 @@
 require 'psych/scalar_scanner'
 
+unless defined?(Regexp::NOENCODING)
+  Regexp::NOENCODING = 32
+end
+
 module Psych
   module Visitors
     ###

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]