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

ruby-changes:67676

From: aycabta <ko1@a...>
Date: Fri, 10 Sep 2021 06:37:20 +0900 (JST)
Subject: [ruby-changes:67676] 90afe5f11f (master): [ruby/irb] Move IRB::TOPLEVEL_BINDING from exe/irb to lib/irb/workspace.rb

https://git.ruby-lang.org/ruby.git/commit/?id=90afe5f11f

From 90afe5f11f9c70ebab1ccb318712692884498931 Mon Sep 17 00:00:00 2001
From: aycabta <aycabta@g...>
Date: Fri, 10 Sep 2021 06:08:56 +0900
Subject: [ruby/irb] Move IRB::TOPLEVEL_BINDING from exe/irb to
 lib/irb/workspace.rb

https://github.com/ruby/irb/commit/e736a77076
---
 lib/irb.rb           | 2 ++
 lib/irb/workspace.rb | 3 ++-
 libexec/irb          | 1 -
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/irb.rb b/lib/irb.rb
index c22e6db..665f67b 100644
--- a/lib/irb.rb
+++ b/lib/irb.rb
@@ -669,6 +669,8 @@ module IRB https://github.com/ruby/ruby/blob/trunk/lib/irb.rb#L669
           lines = lines.reverse if order == :bottom
           lines.map{ |l| l + "\n" }.join
         }
+        # The "<top (required)>" in "(irb)" may be the top level of IRB so imitate the main object.
+        message = message.gsub(/\(irb\):(?<num>\d+):in `<(?<frame>top \(required\))>'/)  { "(irb):#{$~[:num]}:in `<main>'" }
         puts message
       end
       print "Maybe IRB bug!\n" if irb_bug
diff --git a/lib/irb/workspace.rb b/lib/irb/workspace.rb
index 8157e21..2c4c40f 100644
--- a/lib/irb/workspace.rb
+++ b/lib/irb/workspace.rb
@@ -12,6 +12,7 @@ https://github.com/ruby/ruby/blob/trunk/lib/irb/workspace.rb#L12
 
 require "delegate"
 
+IRB::TOPLEVEL_BINDING = binding
 module IRB # :nodoc:
   class WorkSpace
     # Creates a new workspace.
@@ -57,7 +58,7 @@ EOF https://github.com/ruby/ruby/blob/trunk/lib/irb/workspace.rb#L58
                           __FILE__,
                           __LINE__ - 3)
         when 4  # binding is a copy of TOPLEVEL_BINDING (default)
-          # Note that this will typically be IRB::TOPLEVEL_BINDING (see exe/irb)
+          # Note that this will typically be IRB::TOPLEVEL_BINDING
           # This is to avoid RubyGems' local variables (see issue #17623)
           @binding = TOPLEVEL_BINDING.dup
         end
diff --git a/libexec/irb b/libexec/irb
index 7cd2448..c64ee85 100755
--- a/libexec/irb
+++ b/libexec/irb
@@ -8,5 +8,4 @@ https://github.com/ruby/ruby/blob/trunk/libexec/irb#L8
 
 require "irb"
 
-IRB::TOPLEVEL_BINDING = binding
 IRB.start(__FILE__)
-- 
cgit v1.1


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

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