summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-06 02:49:49 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-06 02:49:49 +0000
commit5e214d40d5879e94cb076f12fc8d51d01f2c7174 (patch)
tree5c4b71562c544f74eb5bc1f868a6f4ca4fed9ba7
parentd903681a13ef9b25735e0d2ed9fbd16a9465d23d (diff)
irb.rb: IRB::Irb#run
* lib/irb.rb (IRB::Irb#run): split from IRB.start. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56622 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--lib/irb.rb34
2 files changed, 23 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index 7821c559b9..b83aa623c3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Sun Nov 6 11:49:47 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * lib/irb.rb (IRB::Irb#run): split from IRB.start.
+
Sun Nov 6 11:45:11 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/e2mmap.rb (E2MM.def_exception): remove old definition if
diff --git a/lib/irb.rb b/lib/irb.rb
index 92b79b3301..869f5ad894 100644
--- a/lib/irb.rb
+++ b/lib/irb.rb
@@ -382,21 +382,7 @@ module IRB
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
@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