irb 1.4.0 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/README.md +4 -0
- data/irb.gemspec +2 -2
- data/lib/irb/cmd/chws.rb +4 -2
- data/lib/irb/cmd/fork.rb +5 -2
- data/lib/irb/cmd/help.rb +4 -2
- data/lib/irb/cmd/info.rb +4 -2
- data/lib/irb/cmd/load.rb +3 -2
- data/lib/irb/cmd/ls.rb +4 -2
- data/lib/irb/cmd/measure.rb +4 -2
- data/lib/irb/cmd/nop.rb +4 -2
- data/lib/irb/cmd/pushws.rb +4 -2
- data/lib/irb/cmd/show_source.rb +4 -2
- data/lib/irb/cmd/subirb.rb +4 -2
- data/lib/irb/cmd/whereami.rb +4 -2
- data/lib/irb/color.rb +42 -29
- data/lib/irb/color_printer.rb +4 -1
- data/lib/irb/completion.rb +37 -8
- data/lib/irb/context.rb +21 -17
- data/lib/irb/ext/multi-irb.rb +0 -1
- data/lib/irb/ext/save-history.rb +3 -3
- data/lib/irb/extend-command.rb +25 -25
- data/lib/irb/init.rb +12 -4
- data/lib/irb/input-method.rb +20 -7
- data/lib/irb/inspector.rb +3 -11
- data/lib/irb/lc/error.rb +4 -7
- data/lib/irb/lc/help-message +43 -53
- data/lib/irb/lc/ja/encoding_aliases.rb +4 -2
- data/lib/irb/lc/ja/error.rb +4 -7
- data/lib/irb/lc/ja/help-message +0 -12
- data/lib/irb/ruby-lex.rb +24 -36
- data/lib/irb/version.rb +2 -2
- data/lib/irb/workspace.rb +6 -13
- data/lib/irb.rb +11 -59
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25f63261bbf06e8b1605b8a680e538dd90641ad2492c0bfb0f8e127f673e2793
|
4
|
+
data.tar.gz: 9f113f6c97887e83f9d476dba5e4c0a5656d76cc554e1e818c94e8828b4051fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 024d8e4dc13978bbae5ed3404e3ecff763da3fcc01e26c43d3e7e54822121bbc708de49c5a9c951a15c0ceee05a60cf282cbbd6ae6ec42960e9a8943a9217417
|
7
|
+
data.tar.gz: 146edac46f0d81a01e120493e56eefa8d8b51143851718876617673bcbddf19b54e246d55541833101926e17186ce55b6484e2fb20e6f57735ee49ddfe0b6890
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -40,6 +40,10 @@ irb(main):006:1> end
|
|
40
40
|
|
41
41
|
The Readline extension module can be used with irb. Use of Readline is default if it's installed.
|
42
42
|
|
43
|
+
## Documentation
|
44
|
+
|
45
|
+
https://docs.ruby-lang.org/en/master/IRB.html
|
46
|
+
|
43
47
|
## Development
|
44
48
|
|
45
49
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/irb.gemspec
CHANGED
@@ -8,8 +8,8 @@ end
|
|
8
8
|
Gem::Specification.new do |spec|
|
9
9
|
spec.name = "irb"
|
10
10
|
spec.version = IRB::VERSION
|
11
|
-
spec.authors = ["Keiju ISHITSUKA"]
|
12
|
-
spec.email = ["keiju@ruby-lang.org"]
|
11
|
+
spec.authors = ["aycabta", "Keiju ISHITSUKA"]
|
12
|
+
spec.email = ["aycabta@gmail.com", "keiju@ruby-lang.org"]
|
13
13
|
|
14
14
|
spec.summary = %q{Interactive Ruby command-line tool for REPL (Read Eval Print Loop).}
|
15
15
|
spec.description = %q{Interactive Ruby command-line tool for REPL (Read Eval Print Loop).}
|
data/lib/irb/cmd/chws.rb
CHANGED
@@ -13,8 +13,9 @@
|
|
13
13
|
require_relative "nop"
|
14
14
|
require_relative "../ext/change-ws"
|
15
15
|
|
16
|
-
# :stopdoc:
|
17
16
|
module IRB
|
17
|
+
# :stopdoc:
|
18
|
+
|
18
19
|
module ExtendCommand
|
19
20
|
|
20
21
|
class CurrentWorkingWorkspace < Nop
|
@@ -30,5 +31,6 @@ module IRB
|
|
30
31
|
end
|
31
32
|
end
|
32
33
|
end
|
34
|
+
|
35
|
+
# :startdoc:
|
33
36
|
end
|
34
|
-
# :startdoc:
|
data/lib/irb/cmd/fork.rb
CHANGED
@@ -10,9 +10,11 @@
|
|
10
10
|
#
|
11
11
|
#
|
12
12
|
|
13
|
+
require_relative "nop"
|
13
14
|
|
14
|
-
# :stopdoc:
|
15
15
|
module IRB
|
16
|
+
# :stopdoc:
|
17
|
+
|
16
18
|
module ExtendCommand
|
17
19
|
class Fork < Nop
|
18
20
|
def execute
|
@@ -33,5 +35,6 @@ module IRB
|
|
33
35
|
end
|
34
36
|
end
|
35
37
|
end
|
38
|
+
|
39
|
+
# :startdoc:
|
36
40
|
end
|
37
|
-
# :startdoc:
|
data/lib/irb/cmd/help.rb
CHANGED
@@ -11,8 +11,9 @@
|
|
11
11
|
|
12
12
|
require_relative "nop"
|
13
13
|
|
14
|
-
# :stopdoc:
|
15
14
|
module IRB
|
15
|
+
# :stopdoc:
|
16
|
+
|
16
17
|
module ExtendCommand
|
17
18
|
class Help < Nop
|
18
19
|
def execute(*names)
|
@@ -43,5 +44,6 @@ module IRB
|
|
43
44
|
end
|
44
45
|
end
|
45
46
|
end
|
47
|
+
|
48
|
+
# :startdoc:
|
46
49
|
end
|
47
|
-
# :startdoc:
|
data/lib/irb/cmd/info.rb
CHANGED
data/lib/irb/cmd/load.rb
CHANGED
@@ -13,8 +13,9 @@
|
|
13
13
|
require_relative "nop"
|
14
14
|
require_relative "../ext/loader"
|
15
15
|
|
16
|
-
# :stopdoc:
|
17
16
|
module IRB
|
17
|
+
# :stopdoc:
|
18
|
+
|
18
19
|
module ExtendCommand
|
19
20
|
class Load < Nop
|
20
21
|
include IrbLoader
|
@@ -63,5 +64,5 @@ module IRB
|
|
63
64
|
end
|
64
65
|
end
|
65
66
|
|
67
|
+
# :startdoc:
|
66
68
|
end
|
67
|
-
# :startdoc:
|
data/lib/irb/cmd/ls.rb
CHANGED
@@ -4,8 +4,9 @@ require "reline"
|
|
4
4
|
require_relative "nop"
|
5
5
|
require_relative "../color"
|
6
6
|
|
7
|
-
# :stopdoc:
|
8
7
|
module IRB
|
8
|
+
# :stopdoc:
|
9
|
+
|
9
10
|
module ExtendCommand
|
10
11
|
class Ls < Nop
|
11
12
|
def execute(*arg, grep: nil)
|
@@ -97,5 +98,6 @@ module IRB
|
|
97
98
|
private_constant :Output
|
98
99
|
end
|
99
100
|
end
|
101
|
+
|
102
|
+
# :startdoc:
|
100
103
|
end
|
101
|
-
# :startdoc:
|
data/lib/irb/cmd/measure.rb
CHANGED
data/lib/irb/cmd/nop.rb
CHANGED
data/lib/irb/cmd/pushws.rb
CHANGED
@@ -13,8 +13,9 @@
|
|
13
13
|
require_relative "nop"
|
14
14
|
require_relative "../ext/workspaces"
|
15
15
|
|
16
|
-
# :stopdoc:
|
17
16
|
module IRB
|
17
|
+
# :stopdoc:
|
18
|
+
|
18
19
|
module ExtendCommand
|
19
20
|
class Workspaces < Nop
|
20
21
|
def execute(*obj)
|
@@ -36,5 +37,6 @@ module IRB
|
|
36
37
|
end
|
37
38
|
end
|
38
39
|
end
|
40
|
+
|
41
|
+
# :startdoc:
|
39
42
|
end
|
40
|
-
# :startdoc:
|
data/lib/irb/cmd/show_source.rb
CHANGED
@@ -4,8 +4,9 @@ require_relative "nop"
|
|
4
4
|
require_relative "../color"
|
5
5
|
require_relative "../ruby-lex"
|
6
6
|
|
7
|
-
# :stopdoc:
|
8
7
|
module IRB
|
8
|
+
# :stopdoc:
|
9
|
+
|
9
10
|
module ExtendCommand
|
10
11
|
class ShowSource < Nop
|
11
12
|
def execute(str = nil)
|
@@ -89,5 +90,6 @@ module IRB
|
|
89
90
|
private_constant :Source
|
90
91
|
end
|
91
92
|
end
|
93
|
+
|
94
|
+
# :startdoc:
|
92
95
|
end
|
93
|
-
# :startdoc:
|
data/lib/irb/cmd/subirb.rb
CHANGED
@@ -12,8 +12,9 @@
|
|
12
12
|
require_relative "nop"
|
13
13
|
require_relative "../ext/multi-irb"
|
14
14
|
|
15
|
-
# :stopdoc:
|
16
15
|
module IRB
|
16
|
+
# :stopdoc:
|
17
|
+
|
17
18
|
module ExtendCommand
|
18
19
|
class IrbCommand < Nop
|
19
20
|
def execute(*obj)
|
@@ -39,5 +40,6 @@ module IRB
|
|
39
40
|
end
|
40
41
|
end
|
41
42
|
end
|
43
|
+
|
44
|
+
# :startdoc:
|
42
45
|
end
|
43
|
-
# :startdoc:
|
data/lib/irb/cmd/whereami.rb
CHANGED
data/lib/irb/color.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require 'reline'
|
3
3
|
require 'ripper'
|
4
|
-
|
4
|
+
require_relative 'ruby-lex'
|
5
5
|
|
6
6
|
module IRB # :nodoc:
|
7
7
|
module Color
|
@@ -77,7 +77,15 @@ module IRB # :nodoc:
|
|
77
77
|
|
78
78
|
class << self
|
79
79
|
def colorable?
|
80
|
-
$stdout.tty? && (/mswin|mingw/ =~ RUBY_PLATFORM || (ENV.key?('TERM') && ENV['TERM'] != 'dumb'))
|
80
|
+
supported = $stdout.tty? && (/mswin|mingw/ =~ RUBY_PLATFORM || (ENV.key?('TERM') && ENV['TERM'] != 'dumb'))
|
81
|
+
|
82
|
+
# because ruby/debug also uses irb's color module selectively,
|
83
|
+
# irb won't be activated in that case.
|
84
|
+
if IRB.respond_to?(:conf)
|
85
|
+
supported && IRB.conf.fetch(:USE_COLORIZE, true)
|
86
|
+
else
|
87
|
+
supported
|
88
|
+
end
|
81
89
|
end
|
82
90
|
|
83
91
|
def inspect_colorable?(obj, seen: {}.compare_by_identity)
|
@@ -120,10 +128,14 @@ module IRB # :nodoc:
|
|
120
128
|
|
121
129
|
symbol_state = SymbolState.new
|
122
130
|
colored = +''
|
123
|
-
length = 0
|
124
|
-
end_seen = false
|
125
131
|
|
126
132
|
scan(code, allow_last_error: !complete) do |token, str, expr|
|
133
|
+
# handle uncolorable code
|
134
|
+
if token.nil?
|
135
|
+
colored << Reline::Unicode.escape_for_print(str)
|
136
|
+
next
|
137
|
+
end
|
138
|
+
|
127
139
|
# IRB::ColorPrinter skips colorizing fragments with any invalid token
|
128
140
|
if ignore_error && ERROR_TOKENS.include?(token)
|
129
141
|
return Reline::Unicode.escape_for_print(code)
|
@@ -139,15 +151,7 @@ module IRB # :nodoc:
|
|
139
151
|
colored << line
|
140
152
|
end
|
141
153
|
end
|
142
|
-
length += str.bytesize
|
143
|
-
end_seen = true if token == :on___end__
|
144
|
-
end
|
145
|
-
|
146
|
-
# give up colorizing incomplete Ripper tokens
|
147
|
-
unless end_seen or length == code.bytesize
|
148
|
-
return Reline::Unicode.escape_for_print(code)
|
149
154
|
end
|
150
|
-
|
151
155
|
colored
|
152
156
|
end
|
153
157
|
|
@@ -162,33 +166,42 @@ module IRB # :nodoc:
|
|
162
166
|
end
|
163
167
|
|
164
168
|
def scan(code, allow_last_error:)
|
165
|
-
pos = [1, 0]
|
166
|
-
|
167
169
|
verbose, $VERBOSE = $VERBOSE, nil
|
168
170
|
RubyLex.compile_with_errors_suppressed(code) do |inner_code, line_no|
|
169
171
|
lexer = Ripper::Lexer.new(inner_code, '(ripper)', line_no)
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
172
|
+
byte_pos = 0
|
173
|
+
line_positions = [0]
|
174
|
+
inner_code.lines.each do |line|
|
175
|
+
line_positions << line_positions.last + line.bytesize
|
176
|
+
end
|
177
|
+
|
178
|
+
on_scan = proc do |elem|
|
179
|
+
start_pos = line_positions[elem.pos[0] - 1] + elem.pos[1]
|
175
180
|
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
else
|
181
|
-
pos[1] += line.bytesize
|
182
|
-
end
|
183
|
-
end
|
181
|
+
# yield uncolorable code
|
182
|
+
if byte_pos < start_pos
|
183
|
+
yield(nil, inner_code.byteslice(byte_pos...start_pos), nil)
|
184
|
+
end
|
184
185
|
|
186
|
+
if byte_pos <= start_pos
|
187
|
+
str = elem.tok
|
185
188
|
yield(elem.event, str, elem.state)
|
189
|
+
byte_pos = start_pos + str.bytesize
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
if lexer.respond_to?(:scan) # Ruby 2.7+
|
194
|
+
lexer.scan.each do |elem|
|
195
|
+
next if allow_last_error and /meets end of file|unexpected end-of-input/ =~ elem.message
|
196
|
+
on_scan.call(elem)
|
186
197
|
end
|
187
198
|
else
|
188
|
-
lexer.parse.each do |elem|
|
189
|
-
|
199
|
+
lexer.parse.sort_by(&:pos).each do |elem|
|
200
|
+
on_scan.call(elem)
|
190
201
|
end
|
191
202
|
end
|
203
|
+
# yield uncolorable DATA section
|
204
|
+
yield(nil, inner_code.byteslice(byte_pos...inner_code.bytesize), nil) if byte_pos < inner_code.bytesize
|
192
205
|
end
|
193
206
|
ensure
|
194
207
|
$VERBOSE = verbose
|
data/lib/irb/color_printer.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require 'pp'
|
3
|
-
|
3
|
+
require_relative 'color'
|
4
4
|
|
5
5
|
module IRB
|
6
6
|
class ColorPrinter < ::PP
|
@@ -37,6 +37,9 @@ module IRB
|
|
37
37
|
width ||= str.length
|
38
38
|
|
39
39
|
case str
|
40
|
+
when ''
|
41
|
+
when ',', '=>', '[', ']', '{', '}', '..', '...', /\A@\w+\z/
|
42
|
+
super(str, width)
|
40
43
|
when /\A#</, '=', '>'
|
41
44
|
super(Color.colorize(str, [:GREEN]), width)
|
42
45
|
else
|
data/lib/irb/completion.rb
CHANGED
@@ -11,7 +11,29 @@ require_relative 'ruby-lex'
|
|
11
11
|
|
12
12
|
module IRB
|
13
13
|
module InputCompletor # :nodoc:
|
14
|
+
using Module.new {
|
15
|
+
refine ::Binding do
|
16
|
+
def eval_methods
|
17
|
+
::Kernel.instance_method(:methods).bind(eval("self")).call
|
18
|
+
end
|
19
|
+
|
20
|
+
def eval_private_methods
|
21
|
+
::Kernel.instance_method(:private_methods).bind(eval("self")).call
|
22
|
+
end
|
23
|
+
|
24
|
+
def eval_instance_variables
|
25
|
+
::Kernel.instance_method(:instance_variables).bind(eval("self")).call
|
26
|
+
end
|
27
|
+
|
28
|
+
def eval_global_variables
|
29
|
+
::Kernel.instance_method(:global_variables).bind(eval("self")).call
|
30
|
+
end
|
14
31
|
|
32
|
+
def eval_class_constants
|
33
|
+
::Module.instance_method(:constants).bind(eval("self.class")).call
|
34
|
+
end
|
35
|
+
end
|
36
|
+
}
|
15
37
|
|
16
38
|
# Set of reserved words used by Ruby, you should not use these for
|
17
39
|
# constants or variables
|
@@ -60,7 +82,14 @@ module IRB
|
|
60
82
|
end
|
61
83
|
}
|
62
84
|
}.flatten if defined?(Gem::Specification)
|
63
|
-
(gem_paths.to_a | $LOAD_PATH)
|
85
|
+
candidates = (gem_paths.to_a | $LOAD_PATH)
|
86
|
+
candidates.map do |p|
|
87
|
+
if p.respond_to?(:to_path)
|
88
|
+
p.to_path
|
89
|
+
else
|
90
|
+
String(p) rescue nil
|
91
|
+
end
|
92
|
+
end.compact.sort
|
64
93
|
end
|
65
94
|
|
66
95
|
def self.retrieve_files_to_require_from_load_path
|
@@ -296,10 +325,10 @@ module IRB
|
|
296
325
|
sep = $2
|
297
326
|
message = $3
|
298
327
|
|
299
|
-
gv =
|
300
|
-
lv =
|
301
|
-
iv =
|
302
|
-
cv =
|
328
|
+
gv = bind.eval_global_variables.collect{|m| m.to_s}.push("true", "false", "nil")
|
329
|
+
lv = bind.local_variables.collect{|m| m.to_s}
|
330
|
+
iv = bind.eval_instance_variables.collect{|m| m.to_s}
|
331
|
+
cv = bind.eval_class_constants.collect{|m| m.to_s}
|
303
332
|
|
304
333
|
if (gv | lv | iv | cv).include?(receiver) or /^[A-Z]/ =~ receiver && /\./ !~ receiver
|
305
334
|
# foo.func and foo is var. OR
|
@@ -349,17 +378,17 @@ module IRB
|
|
349
378
|
|
350
379
|
else
|
351
380
|
if doc_namespace
|
352
|
-
vars =
|
381
|
+
vars = (bind.local_variables | bind.eval_instance_variables).collect{|m| m.to_s}
|
353
382
|
perfect_match_var = vars.find{|m| m.to_s == input}
|
354
383
|
if perfect_match_var
|
355
384
|
eval("#{perfect_match_var}.class.name", bind)
|
356
385
|
else
|
357
|
-
candidates =
|
386
|
+
candidates = (bind.eval_methods | bind.eval_private_methods | bind.local_variables | bind.eval_instance_variables | bind.eval_class_constants).collect{|m| m.to_s}
|
358
387
|
candidates |= ReservedWords
|
359
388
|
candidates.find{ |i| i == input }
|
360
389
|
end
|
361
390
|
else
|
362
|
-
candidates =
|
391
|
+
candidates = (bind.eval_methods | bind.eval_private_methods | bind.local_variables | bind.eval_instance_variables | bind.eval_class_constants).collect{|m| m.to_s}
|
363
392
|
candidates |= ReservedWords
|
364
393
|
candidates.grep(/^#{Regexp.quote(input)}/)
|
365
394
|
end
|
data/lib/irb/context.rb
CHANGED
@@ -22,7 +22,7 @@ module IRB
|
|
22
22
|
#
|
23
23
|
# The optional +input_method+ argument:
|
24
24
|
#
|
25
|
-
# +nil+:: uses stdin or
|
25
|
+
# +nil+:: uses stdin or Reline or Readline
|
26
26
|
# +String+:: uses a File
|
27
27
|
# +other+:: uses this as InputMethod
|
28
28
|
def initialize(irb, workspace = nil, input_method = nil)
|
@@ -32,7 +32,7 @@ module IRB
|
|
32
32
|
else
|
33
33
|
@workspace = WorkSpace.new
|
34
34
|
end
|
35
|
-
@thread = Thread.current
|
35
|
+
@thread = Thread.current
|
36
36
|
|
37
37
|
# copy of default configuration
|
38
38
|
@ap_name = IRB.conf[:AP_NAME]
|
@@ -48,12 +48,16 @@ module IRB
|
|
48
48
|
end
|
49
49
|
if IRB.conf.has_key?(:USE_MULTILINE)
|
50
50
|
@use_multiline = IRB.conf[:USE_MULTILINE]
|
51
|
-
elsif IRB.conf.has_key?(:
|
52
|
-
@use_multiline = IRB.conf[:
|
51
|
+
elsif IRB.conf.has_key?(:USE_RELINE) # backward compatibility
|
52
|
+
@use_multiline = IRB.conf[:USE_RELINE]
|
53
|
+
elsif IRB.conf.has_key?(:USE_REIDLINE)
|
54
|
+
warn <<~MSG.strip
|
55
|
+
USE_REIDLINE is deprecated, please use USE_RELINE instead.
|
56
|
+
MSG
|
57
|
+
@use_multiline = IRB.conf[:USE_RELINE]
|
53
58
|
else
|
54
59
|
@use_multiline = nil
|
55
60
|
end
|
56
|
-
@use_colorize = IRB.conf[:USE_COLORIZE]
|
57
61
|
@use_autocomplete = IRB.conf[:USE_AUTOCOMPLETE]
|
58
62
|
@verbose = IRB.conf[:VERBOSE]
|
59
63
|
@io = nil
|
@@ -84,14 +88,14 @@ module IRB
|
|
84
88
|
when nil
|
85
89
|
if STDIN.tty? && IRB.conf[:PROMPT_MODE] != :INF_RUBY && !use_singleline?
|
86
90
|
# Both of multiline mode and singleline mode aren't specified.
|
87
|
-
@io =
|
91
|
+
@io = RelineInputMethod.new
|
88
92
|
else
|
89
93
|
@io = nil
|
90
94
|
end
|
91
95
|
when false
|
92
96
|
@io = nil
|
93
97
|
when true
|
94
|
-
@io =
|
98
|
+
@io = RelineInputMethod.new
|
95
99
|
end
|
96
100
|
unless @io
|
97
101
|
case use_singleline?
|
@@ -116,6 +120,10 @@ module IRB
|
|
116
120
|
end
|
117
121
|
@io = StdioInputMethod.new unless @io
|
118
122
|
|
123
|
+
when '-'
|
124
|
+
@io = FileInputMethod.new($stdin)
|
125
|
+
@irb_name = '-'
|
126
|
+
@irb_path = '-'
|
119
127
|
when String
|
120
128
|
@io = FileInputMethod.new(input_method)
|
121
129
|
@irb_name = File.basename(input_method)
|
@@ -157,7 +165,7 @@ module IRB
|
|
157
165
|
# The current input method.
|
158
166
|
#
|
159
167
|
# Can be either StdioInputMethod, ReadlineInputMethod,
|
160
|
-
#
|
168
|
+
# RelineInputMethod, FileInputMethod or other specified when the
|
161
169
|
# context is created. See ::new for more # information on +input_method+.
|
162
170
|
attr_accessor :io
|
163
171
|
|
@@ -186,8 +194,6 @@ module IRB
|
|
186
194
|
attr_reader :use_singleline
|
187
195
|
# Whether colorization is enabled or not.
|
188
196
|
#
|
189
|
-
# A copy of the default <code>IRB.conf[:USE_COLORIZE]</code>
|
190
|
-
attr_reader :use_colorize
|
191
197
|
# A copy of the default <code>IRB.conf[:USE_AUTOCOMPLETE]</code>
|
192
198
|
attr_reader :use_autocomplete
|
193
199
|
# A copy of the default <code>IRB.conf[:INSPECT_MODE]</code>
|
@@ -325,15 +331,13 @@ module IRB
|
|
325
331
|
# Alias for #use_singleline
|
326
332
|
alias use_singleline? use_singleline
|
327
333
|
# backward compatibility
|
328
|
-
alias
|
334
|
+
alias use_reline use_multiline
|
329
335
|
# backward compatibility
|
330
|
-
alias
|
336
|
+
alias use_reline? use_multiline
|
331
337
|
# backward compatibility
|
332
338
|
alias use_readline use_singleline
|
333
339
|
# backward compatibility
|
334
340
|
alias use_readline? use_singleline
|
335
|
-
# Alias for #use_colorize
|
336
|
-
alias use_colorize? use_colorize
|
337
341
|
# Alias for #use_autocomplete
|
338
342
|
alias use_autocomplete? use_autocomplete
|
339
343
|
# Alias for #rc
|
@@ -347,7 +351,7 @@ module IRB
|
|
347
351
|
# Returns whether messages are displayed or not.
|
348
352
|
def verbose?
|
349
353
|
if @verbose.nil?
|
350
|
-
if @io.kind_of?(
|
354
|
+
if @io.kind_of?(RelineInputMethod)
|
351
355
|
false
|
352
356
|
elsif defined?(ReadlineInputMethod) && @io.kind_of?(ReadlineInputMethod)
|
353
357
|
false
|
@@ -362,11 +366,11 @@ module IRB
|
|
362
366
|
end
|
363
367
|
|
364
368
|
# Whether #verbose? is +true+, and +input_method+ is either
|
365
|
-
# StdioInputMethod or
|
369
|
+
# StdioInputMethod or RelineInputMethod or ReadlineInputMethod, see #io
|
366
370
|
# for more information.
|
367
371
|
def prompting?
|
368
372
|
verbose? || (STDIN.tty? && @io.kind_of?(StdioInputMethod) ||
|
369
|
-
@io.kind_of?(
|
373
|
+
@io.kind_of?(RelineInputMethod) ||
|
370
374
|
(defined?(ReadlineInputMethod) && @io.kind_of?(ReadlineInputMethod)))
|
371
375
|
end
|
372
376
|
|
data/lib/irb/ext/multi-irb.rb
CHANGED
data/lib/irb/ext/save-history.rb
CHANGED
@@ -107,13 +107,13 @@ module IRB
|
|
107
107
|
raise
|
108
108
|
end
|
109
109
|
|
110
|
-
if File.exist?(history_file) &&
|
110
|
+
if File.exist?(history_file) &&
|
111
111
|
File.mtime(history_file) != @loaded_history_mtime
|
112
|
-
history = history[@loaded_history_lines..-1]
|
112
|
+
history = history[@loaded_history_lines..-1] if @loaded_history_lines
|
113
113
|
append_history = true
|
114
114
|
end
|
115
115
|
|
116
|
-
open(history_file,
|
116
|
+
File.open(history_file, (append_history ? 'a' : 'w'), 0o600, encoding: IRB.conf[:LC_MESSAGES]&.encoding) do |f|
|
117
117
|
hist = history.map{ |l| l.split("\n").join("\\\n") }
|
118
118
|
unless append_history
|
119
119
|
begin
|