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

ruby-changes:33100

From: nobu <ko1@a...>
Date: Wed, 26 Feb 2014 13:26:13 +0900 (JST)
Subject: [ruby-changes:33100] nobu:r45179 (trunk): envutil.rb: move labeled_module and labeled_class

nobu	2014-02-26 13:26:09 +0900 (Wed, 26 Feb 2014)

  New Revision: 45179

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

  Log:
    envutil.rb: move labeled_module and labeled_class
    
    * test/ruby/envutil.rb (labeled_module, labeled_class): move from
      test/ruby/test_module.rb.

  Modified files:
    trunk/test/ruby/envutil.rb
    trunk/test/ruby/test_module.rb
Index: test/ruby/test_module.rb
===================================================================
--- test/ruby/test_module.rb	(revision 45178)
+++ test/ruby/test_module.rb	(revision 45179)
@@ -1564,17 +1564,11 @@ class TestModule < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_module.rb#L1564
   end
 
   def labeled_module(name, &block)
-    Module.new do
-      singleton_class.class_eval {define_method(:to_s) {name}; alias inspect to_s}
-      class_eval(&block) if block
-    end
+    EnvUtil.labeled_module(name, &block)
   end
 
   def labeled_class(name, superclass = Object, &block)
-    Class.new(superclass) do
-      singleton_class.class_eval {define_method(:to_s) {name}; alias inspect to_s}
-      class_eval(&block) if block
-    end
+    EnvUtil.labeled_class(name, superclass, &block)
   end
 
   def test_prepend_instance_methods_false
Index: test/ruby/envutil.rb
===================================================================
--- test/ruby/envutil.rb	(revision 45178)
+++ test/ruby/envutil.rb	(revision 45179)
@@ -157,6 +157,22 @@ module EnvUtil https://github.com/ruby/ruby/blob/trunk/test/ruby/envutil.rb#L157
   end
   module_function :with_default_internal
 
+  def labeled_module(name, &block)
+    Module.new do
+      singleton_class.class_eval {define_method(:to_s) {name}; alias inspect to_s}
+      class_eval(&block) if block
+    end
+  end
+  module_function :labeled_module
+
+  def labeled_class(name, superclass = Object, &block)
+    Class.new(superclass) do
+      singleton_class.class_eval {define_method(:to_s) {name}; alias inspect to_s}
+      class_eval(&block) if block
+    end
+  end
+  module_function :labeled_class
+
   if /darwin/ =~ RUBY_PLATFORM
     DIAGNOSTIC_REPORTS_PATH = File.expand_path("~/Library/Logs/DiagnosticReports")
     DIAGNOSTIC_REPORTS_TIMEFORMAT = '%Y-%m-%d-%H%M%S'

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

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