Skip to content

Commit 2f8cc0e

Browse files
committed
Add --context-mode 5: evaluates inside Ruby::Box
1 parent dfb89f2 commit 2f8cc0e

5 files changed

Lines changed: 7 additions & 4 deletions

File tree

doc/COMMAND_LINE_OPTIONS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ These are the IRB command-line options, with links to explanatory text:
2121
- `--colorize`: Use {color-highlighting}[rdoc-ref:IRB@Color+Highlighting]
2222
for input and output.
2323
- `--context-mode _n_`: Select method to create Binding object
24-
for new {workspace}[rdoc-ref:IRB@Commands]; `n` in range `0..4`.
24+
for new {workspace}[rdoc-ref:IRB@Commands]; `n` in range `0..5`.
2525
- `--echo`: Print ({echo}[rdoc-ref:IRB@Return-Value+Printing+-28Echoing-29])
2626
return values.
2727
- `--extra-doc-dir _dirpath_`:

doc/irb/irb.rd.ja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ irbの使い方は, Rubyさえ知っていればいたって簡単です. 基本
4848
-w ruby -w と同じ.
4949
-W[level=2] ruby -W と同じ.
5050
--context-mode n 新しいワークスペースを作成した時に関連する Binding
51-
オブジェクトの作成方法を 0 から 3 のいずれかに設定する.
51+
オブジェクトの作成方法を 0 から 5 のいずれかに設定する.
5252
--echo 実行結果を表示する(デフォルト).
5353
--noecho 実行結果を表示しない.
5454
--echo-on-assignment

lib/irb/lc/help-message

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Usage: irb.rb [options] [programfile] [arguments]
99
-w Suppress warnings (same as 'ruby -w').
1010
-W[level=2] Set warning level: 0=silence, 1=medium, 2=verbose
1111
(same as 'ruby -W').
12-
--context-mode n Set n[0-4] to method to create Binding Object,
12+
--context-mode n Set n[0-5] to method to create Binding Object,
1313
when new workspace was created.
1414
--extra-doc-dir Add an extra doc dir for the doc dialog.
1515
--echo Show result (default).

lib/irb/lc/ja/help-message

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Usage: irb.rb [options] [programfile] [arguments]
88
-w ruby -w と同じ.
99
-W[level=2] ruby -W と同じ.
1010
--context-mode n 新しいワークスペースを作成した時に関連する Binding
11-
オブジェクトの作成方法を 0 から 4 のいずれかに設定する.
11+
オブジェクトの作成方法を 0 から 5 のいずれかに設定する.
1212
--extra-doc-dir 指定したディレクトリのドキュメントを追加で読み込む.
1313
--echo 実行結果を表示する(デフォルト).
1414
--noecho 実行結果を表示しない.

lib/irb/workspace.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ def initialize(*main)
5555
# Note that this will typically be IRB::TOPLEVEL_BINDING
5656
# This is to avoid RubyGems' local variables (see issue #17623)
5757
@binding = TOPLEVEL_BINDING.dup
58+
when 5
59+
puts 'Context-mode-5 (binding in new Ruby::Box) is experimental. It may be removed or changed without notice.'
60+
@binding = Ruby::Box.new.eval('Kernel.binding')
5861
end
5962
end
6063

0 commit comments

Comments
 (0)