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

ruby-changes:34005

From: hsbt <ko1@a...>
Date: Sun, 25 May 2014 08:54:35 +0900 (JST)
Subject: [ruby-changes:34005] hsbt:r46086 (trunk): * lib/logger.rb: refactored to include Logger::Period.

hsbt	2014-05-25 08:54:17 +0900 (Sun, 25 May 2014)

  New Revision: 46086

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

  Log:
    * lib/logger.rb: refactored to include Logger::Period.

  Modified files:
    trunk/ChangeLog
    trunk/lib/logger.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 46085)
+++ ChangeLog	(revision 46086)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun May 25 08:43:16 2014  SHIBATA Hiroshi  <shibata.hiroshi@g...>
+
+	* lib/logger.rb: refactored to include Logger::Period.
+
 Sun May 25 06:50:19 2014  Zachary Scott  <e@z...>
 
 	* vm_eval.c: [DOC] Improve instance_eval description when given a
Index: lib/logger.rb
===================================================================
--- lib/logger.rb	(revision 46085)
+++ lib/logger.rb	(revision 46086)
@@ -530,9 +530,48 @@ private https://github.com/ruby/ruby/blob/trunk/lib/logger.rb#L530
     end
   end
 
+  module Period
+    module_function
+
+    SiD = 24 * 60 * 60
+
+    def next_rotate_time(now, shift_age)
+      case shift_age
+      when /^daily$/
+        t = Time.mktime(now.year, now.month, now.mday) + SiD
+      when /^weekly$/
+        t = Time.mktime(now.year, now.month, now.mday) + SiD * (7 - now.wday)
+      when /^monthly$/
+        t = Time.mktime(now.year, now.month, 1) + SiD * 31
+        mday = (1 if t.mday > 1)
+      else
+        return now
+      end
+      if mday or t.hour.nonzero? or t.min.nonzero? or t.sec.nonzero?
+        t = Time.mktime(t.year, t.month, mday || (t.mday + (t.hour > 12 ? 1 : 0)))
+      end
+      t
+    end
+
+    def previous_period_end(now, shift_age)
+      case shift_age
+      when /^daily$/
+        t = Time.mktime(now.year, now.month, now.mday) - SiD / 2
+      when /^weekly$/
+        t = Time.mktime(now.year, now.month, now.mday) - (SiD * (now.wday + 1) + SiD / 2)
+      when /^monthly$/
+        t = Time.mktime(now.year, now.month, 1) - SiD / 2
+      else
+        return now
+      end
+      Time.mktime(t.year, t.month, t.mday, 23, 59, 59)
+    end
+  end
 
   # Device used for logging messages.
   class LogDevice
+    include Period
+
     attr_reader :dev
     attr_reader :filename
 
@@ -700,49 +739,6 @@ private https://github.com/ruby/ruby/blob/trunk/lib/logger.rb#L739
     end
   end
 
-  module Period
-    module_function
-
-    SiD = 24 * 60 * 60
-
-    def next_rotate_time(now, shift_age)
-      case shift_age
-      when /^daily$/
-        t = Time.mktime(now.year, now.month, now.mday) + SiD
-      when /^weekly$/
-        t = Time.mktime(now.year, now.month, now.mday) + SiD * (7 - now.wday)
-      when /^monthly$/
-        t = Time.mktime(now.year, now.month, 1) + SiD * 31
-        mday = (1 if t.mday > 1)
-      else
-        return now
-      end
-      if mday or t.hour.nonzero? or t.min.nonzero? or t.sec.nonzero?
-        t = Time.mktime(t.year, t.month, mday || (t.mday + (t.hour > 12 ? 1 : 0)))
-      end
-      t
-    end
-
-    def previous_period_end(now, shift_age)
-      case shift_age
-      when /^daily$/
-        t = Time.mktime(now.year, now.month, now.mday) - SiD / 2
-      when /^weekly$/
-        t = Time.mktime(now.year, now.month, now.mday) - (SiD * (now.wday + 1) + SiD / 2)
-      when /^monthly$/
-        t = Time.mktime(now.year, now.month, 1) - SiD / 2
-      else
-        return now
-      end
-      Time.mktime(t.year, t.month, t.mday, 23, 59, 59)
-    end
-  end
-
-  class LogDevice
-    include Period
-  end
-
-
   #
   # == Description
   #

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

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