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

ruby-changes:44549

From: nobu <ko1@a...>
Date: Sun, 6 Nov 2016 11:49:53 +0900 (JST)
Subject: [ruby-changes:44549] nobu:r56622 (trunk): irb.rb: IRB::Irb#run

nobu	2016-11-06 11:49:49 +0900 (Sun, 06 Nov 2016)

  New Revision: 56622

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56622

  Log:
    irb.rb: IRB::Irb#run
    
    * lib/irb.rb (IRB::Irb#run): split from IRB.start.

  Modified files:
    trunk/ChangeLog
    trunk/lib/irb.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 56621)
+++ ChangeLog	(revision 56622)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Nov  6 11:49:47 2016  Nobuyoshi Nakada  <nobu@r...>
+
+	* lib/irb.rb (IRB::Irb#run): split from IRB.start.
+
 Sun Nov  6 11:45:11 2016  Nobuyoshi Nakada  <nobu@r...>
 
 	* lib/e2mmap.rb (E2MM.def_exception): remove old definition if
Index: lib/irb.rb
===================================================================
--- lib/irb.rb	(revision 56621)
+++ lib/irb.rb	(revision 56622)
@@ -382,21 +382,7 @@ module IRB https://github.com/ruby/ruby/blob/trunk/lib/irb.rb#L382
     else
       irb = Irb.new
     end
-
-    @CONF[:IRB_RC].call(irb.context) if @CONF[:IRB_RC]
-    @CONF[:MAIN_CONTEXT] = irb.context
-
-    trap("SIGINT") do
-      irb.signal_handle
-    end
-
-    begin
-      catch(:IRB_EXIT) do
-        irb.eval_input
-      end
-    ensure
-      irb_at_exit
-    end
+    irb.run(@CONF)
   end
 
   # Calls each event hook of IRB.conf[:AT_EXIT] when the current session quits.
@@ -430,6 +416,24 @@ module IRB https://github.com/ruby/ruby/blob/trunk/lib/irb.rb#L416
       @scanner = RubyLex.new
       @scanner.exception_on_syntax_error = false
     end
+
+    def run(conf = IRB.conf)
+      conf[:IRB_RC].call(context) if conf[:IRB_RC]
+      conf[:MAIN_CONTEXT] = context
+
+      trap("SIGINT") do
+        signal_handle
+      end
+
+      begin
+        catch(:IRB_EXIT) do
+          eval_input
+        end
+      ensure
+        conf[:AT_EXIT].each{|hook| hook.call}
+      end
+    end
+
     # Returns the current context of this irb session
     attr_reader :context
     # The lexer used by this irb session

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

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