[#43186] [Ruby 1.9-Bug#4388][Open] open-uriで環境変数http_proxyを使うときに認証付きのProxyが使えません — あつし よしだ <redmine@...>

Bug #4388: open-uri=E3=81=A7=E7=92=B0=E5=A2=83=E5=A4=89=E6=95=B0http_prox=

11 messages 2011/02/10
[#43192] [Ruby 1.9-Bug#4388] open-uriで環境変数http_proxyを使うときに認証付きのProxyが使えません — あつし よしだ <redmine@...> 2011/02/11

チケット #4388 が更新されました。 (by あつし よしだ)

[#43193] Re: [Ruby 1.9-Bug#4388] open-uriで環境変数http_proxyを使うときに認証付きのProxyが使えません — Tanaka Akira <akr@...> 2011/02/11

2011年2月11日12:59 あつし よしだ <redmine@ruby-lang.org>:

[#43203] [Ruby 1.9-Bug#4397][Open] test-mkmf fails due to compilation errors — Shyouhei Urabe <redmine@...>

Bug #4397: test-mkmf fails due to compilation errors

10 messages 2011/02/14

[#43272] [Ruby 1.9 - Bug #4443] [Open] odd evaluation order in a multiple assignment — Yusuke Endoh <mame@...>

13 messages 2011/02/24

[#43274] [Ruby 1.9 - Bug #4445] [Open] ext/openssl の verify_callback が rb_protect で保護されていない — Ippei Obayashi <ohai@...>

13 messages 2011/02/24

[#43276] iseq_compile_each()でのマジックナンバ — きたざわけんいち <peisunstar@...>

きたざわです。

15 messages 2011/02/27
[#43303] Re: iseq_compile_each()でのマジックナンバ — nagachika <nagachika00@...> 2011/03/04

近永と申します。

[#43304] Re: iseq_compile_each()でのマジックナンバ — Yusuke ENDOH <mame@...> 2011/03/04

遠藤です。

[ruby-dev:43194] [Ruby 1.9-Feature#4043] グローバル関数current_classの提案

From: Makoto Kishimoto <redmine@...>
Date: 2011-02-11 08:53:46 UTC
List: ruby-dev #43194
=E3=83=81=E3=82=B1=E3=83=83=E3=83=88 #4043 =E3=81=8C=E6=9B=B4=E6=96=B0=E3=
=81=95=E3=82=8C=E3=81=BE=E3=81=97=E3=81=9F=E3=80=82 (by Makoto Kishimoto)=


=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB patch-current-class =E8=BF=BD=E5=8A=A0=


Module.current =E3=81=AB +1

=E6=96=B0=E3=81=97=E3=81=84=E3=83=91=E3=83=83=E3=83=81=E4=BD=9C=E3=82=8A=E3=
=81=BE=E3=81=97=E3=81=9F
----------------------------------------
http://redmine.ruby-lang.org/issues/show/4043

----------------------------------------
http://redmine.ruby-lang.org

Attachments (1)

patch-current-class (2.17 KB, text/x-diff)
diff --git a/eval.c b/eval.c
index 5fe00e1..22a0a60 100644
--- a/eval.c
+++ b/eval.c
@@ -347,6 +347,20 @@ rb_mod_s_constants(int argc, VALUE *argv, VALUE mod)
     return rb_const_list(data);
 }
 
+/*
+ *  call-seq:
+ *     Module.current -> Module
+ *
+ *  Returns "current class".
+ */
+
+VALUE rb_vm_cref_cls(void);
+static VALUE
+rb_mod_current(void)
+{
+    return rb_vm_cref_cls();
+}
+
 void
 rb_frozen_class_p(VALUE klass)
 {
@@ -1144,6 +1158,8 @@ Init_eval(void)
     rb_define_singleton_method(rb_cModule, "nesting", rb_mod_nesting, 0);
     rb_define_singleton_method(rb_cModule, "constants", rb_mod_s_constants, -1);
 
+    rb_define_singleton_method(rb_cModule, "current", rb_mod_current, 0);
+
     rb_define_singleton_method(rb_vm_top_self(), "include", top_include, -1);
 
     rb_define_method(rb_mKernel, "extend", rb_obj_extend, -1);
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb
index ce6e8a6..b6277dc 100644
--- a/test/ruby/test_module.rb
+++ b/test/ruby/test_module.rb
@@ -1000,4 +1000,28 @@ class TestModule < Test::Unit::TestCase
     INPUT
     assert_in_out_err([], src, %w(Object :ok), [])
   end
+
+  class ModuleCurrentTestModule1
+    CURRENT = Module.current
+
+    def self.foo
+      Module.current
+    end
+
+    def foo
+      Module.current
+    end
+  end
+
+  def test_module_current
+    assert_equal(TestModule, Module.current)
+    assert_equal(ModuleCurrentTestModule1, ModuleCurrentTestModule1::CURRENT)
+    assert_equal(ModuleCurrentTestModule1, ModuleCurrentTestModule1.foo)
+    module_current_test = ModuleCurrentTestModule1.new
+    assert_equal(ModuleCurrentTestModule1, module_current_test.foo)
+    foo = ModuleCurrentTestModule1.module_eval{Module.current}
+    assert_equal(ModuleCurrentTestModule1, foo)
+    foo = ModuleCurrentTestModule1.instance_eval{Module.current}
+    assert_equal("#<Class:TestModule::ModuleCurrentTestModule1>", foo.to_s)
+  end
 end
diff --git a/vm.c b/vm.c
index d0c2592..03f15e7 100644
--- a/vm.c
+++ b/vm.c
@@ -827,6 +827,12 @@ rb_vm_cref(void)
     return vm_get_cref(cfp->iseq, cfp->lfp, cfp->dfp);
 }
 
+VALUE
+rb_vm_cref_cls(void)
+{
+    return rb_vm_cref()->nd_clss;
+}
+
 #if 0
 void
 debug_cref(NODE *cref)

In This Thread

Prev Next