irb 1.11.0 → 1.11.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -0
- data/README.md +39 -12
- data/Rakefile +1 -1
- data/irb.gemspec +1 -1
- data/lib/irb/cmd/exit.rb +22 -0
- data/lib/irb/completion.rb +7 -1
- data/lib/irb/context.rb +7 -10
- data/lib/irb/ext/tracer.rb +11 -50
- data/lib/irb/extend-command.rb +6 -13
- data/lib/irb/history.rb +10 -2
- data/lib/irb/init.rb +6 -3
- data/lib/irb/input-method.rb +8 -7
- data/lib/irb/inspector.rb +1 -1
- data/lib/irb/locale.rb +1 -1
- data/lib/irb/nesting_parser.rb +13 -3
- data/lib/irb/ruby-lex.rb +1 -1
- data/lib/irb/source_finder.rb +3 -2
- data/lib/irb/version.rb +2 -2
- data/lib/irb.rb +11 -30
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53ffdc8550a2c9debc40dc6565f23010c02959bf924fc917a6736465960dc660
|
4
|
+
data.tar.gz: ca6f06898a6b431303c5b63b9f8ff88295106ad66d8cb30e85a6f5f879449c8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '059eb872f0be29fec2c8fe7c64b809f9346b3e25b084a1033ab4ea6e02e7c3e311317d2a169a18d5a9291acc578e56c1587c12f901d2e09fa52d58fe3717377c'
|
7
|
+
data.tar.gz: 8b6cce5c6bc85f25db7a78977e433746efa47d2eb0b0828d9adebb813ce0648396aae6e0c903aca30b79f2c1e947f319e75b21e916eb6f8a8a8f8d5553431d5c
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -15,6 +15,10 @@ The `irb` command from your shell will start the interpreter.
|
|
15
15
|
- [Debugging with IRB](#debugging-with-irb)
|
16
16
|
- [More about `debug.gem`](#more-about-debuggem)
|
17
17
|
- [Advantages Over `debug.gem`'s Console](#advantages-over-debuggems-console)
|
18
|
+
- [Type Based Completion](#type-based-completion)
|
19
|
+
- [How to Enable IRB::TypeCompletor](#how-to-enable-irbtypecompletor)
|
20
|
+
- [Advantage over Default IRB::RegexpCompletor](#advantage-over-default-irbregexpcompletor)
|
21
|
+
- [Difference between Steep's Completion](#difference-between-steeps-completion)
|
18
22
|
- [Configuration](#configuration)
|
19
23
|
- [Environment Variables](#environment-variables)
|
20
24
|
- [Documentation](#documentation)
|
@@ -105,15 +109,9 @@ Hello World
|
|
105
109
|
|
106
110
|
The following commands are available on IRB. You can get the same output from the `show_cmds` command.
|
107
111
|
|
108
|
-
```
|
109
|
-
Workspace
|
110
|
-
cwws Show the current workspace.
|
111
|
-
chws Change the current workspace to an object.
|
112
|
-
workspaces Show workspaces.
|
113
|
-
pushws Push an object to the workspace stack.
|
114
|
-
popws Pop a workspace from the workspace stack.
|
115
|
-
|
112
|
+
```txt
|
116
113
|
IRB
|
114
|
+
exit Exit the current irb session.
|
117
115
|
irb_load Load a Ruby file.
|
118
116
|
irb_require Require a Ruby file.
|
119
117
|
source Loads a given file in the current session.
|
@@ -121,6 +119,13 @@ IRB
|
|
121
119
|
show_cmds List all available commands and their description.
|
122
120
|
history Shows the input history. `-g [query]` or `-G [query]` allows you to filter the output.
|
123
121
|
|
122
|
+
Workspace
|
123
|
+
cwws Show the current workspace.
|
124
|
+
chws Change the current workspace to an object.
|
125
|
+
workspaces Show workspaces.
|
126
|
+
pushws Push an object to the workspace stack.
|
127
|
+
popws Pop a workspace from the workspace stack.
|
128
|
+
|
124
129
|
Multi-irb (DEPRECATED)
|
125
130
|
irb Start a child IRB.
|
126
131
|
jobs List of current sessions.
|
@@ -149,6 +154,10 @@ Context
|
|
149
154
|
ls Show methods, constants, and variables. `-g [query]` or `-G [query]` allows you to filter out the output.
|
150
155
|
show_source Show the source code of a given method or constant.
|
151
156
|
whereami Show the source code around binding.irb again.
|
157
|
+
|
158
|
+
Aliases
|
159
|
+
$ Alias for `show_source`
|
160
|
+
@ Alias for `whereami`
|
152
161
|
```
|
153
162
|
|
154
163
|
## Debugging with IRB
|
@@ -242,15 +251,33 @@ IRB's default completion `IRB::RegexpCompletor` uses Regexp. IRB has another exp
|
|
242
251
|
|
243
252
|
### How to Enable IRB::TypeCompletor
|
244
253
|
|
245
|
-
|
254
|
+
Install [ruby/repl_type_completor](https://github.com/ruby/repl_type_completor/) with:
|
255
|
+
```
|
256
|
+
$ gem install repl_type_completor
|
257
|
+
```
|
258
|
+
Or add these lines to your project's Gemfile.
|
259
|
+
```ruby
|
260
|
+
gem 'irb'
|
261
|
+
gem 'repl_type_completor', group: [:development, :test]
|
262
|
+
```
|
263
|
+
|
264
|
+
Now you can use type based completion by:
|
265
|
+
|
266
|
+
Running IRB with the `--type-completor` option
|
246
267
|
```
|
247
268
|
$ irb --type-completor
|
248
269
|
```
|
249
|
-
|
270
|
+
|
271
|
+
Or writing this line to IRB's rc-file (e.g. `~/.irbrc`)
|
250
272
|
```ruby
|
251
273
|
IRB.conf[:COMPLETOR] = :type # default is :regexp
|
252
274
|
```
|
253
|
-
|
275
|
+
|
276
|
+
Or setting the environment variable `IRB_COMPLETOR`
|
277
|
+
```ruby
|
278
|
+
ENV['IRB_COMPLETOR'] = 'type'
|
279
|
+
IRB.start
|
280
|
+
```
|
254
281
|
|
255
282
|
To check if it's enabled, type `irb_info` into IRB and see the `Completion` section.
|
256
283
|
```
|
@@ -357,7 +384,7 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/i
|
|
357
384
|
|
358
385
|
### Run integration tests
|
359
386
|
|
360
|
-
If your changes affect component rendering, such as the autocompletion's dialog/dropdown, you may need to run IRB's integration tests, known as `
|
387
|
+
If your changes affect component rendering, such as the autocompletion's dialog/dropdown, you may need to run IRB's integration tests, known as `yamatanooroti`.
|
361
388
|
|
362
389
|
Before running these tests, ensure that you have `libvterm` installed. If you're using Homebrew, you can install it by running:
|
363
390
|
|
data/Rakefile
CHANGED
@@ -17,7 +17,7 @@ task :test_in_isolation do
|
|
17
17
|
ENV["TEST"] = test_file
|
18
18
|
begin
|
19
19
|
Rake::Task["test"].execute
|
20
|
-
rescue
|
20
|
+
rescue
|
21
21
|
failed = true
|
22
22
|
msg = "Test '#{test_file}' failed when being executed in isolation. Please make sure 'rake test TEST=#{test_file}' passes."
|
23
23
|
separation_line = '=' * msg.length
|
data/irb.gemspec
CHANGED
data/lib/irb/cmd/exit.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "nop"
|
4
|
+
|
5
|
+
module IRB
|
6
|
+
# :stopdoc:
|
7
|
+
|
8
|
+
module ExtendCommand
|
9
|
+
class Exit < Nop
|
10
|
+
category "IRB"
|
11
|
+
description "Exit the current irb session."
|
12
|
+
|
13
|
+
def execute(*)
|
14
|
+
IRB.irb_exit
|
15
|
+
rescue UncaughtThrowError
|
16
|
+
Kernel.exit
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# :startdoc:
|
22
|
+
end
|
data/lib/irb/completion.rb
CHANGED
@@ -406,7 +406,13 @@ module IRB
|
|
406
406
|
else
|
407
407
|
select_message(receiver, message, candidates.sort)
|
408
408
|
end
|
409
|
-
|
409
|
+
when /^\s*$/
|
410
|
+
# empty input
|
411
|
+
if doc_namespace
|
412
|
+
nil
|
413
|
+
else
|
414
|
+
[]
|
415
|
+
end
|
410
416
|
else
|
411
417
|
if doc_namespace
|
412
418
|
vars = (bind.local_variables | bind.eval_instance_variables).collect{|m| m.to_s}
|
data/lib/irb/context.rb
CHANGED
@@ -61,7 +61,7 @@ module IRB
|
|
61
61
|
@io = nil
|
62
62
|
|
63
63
|
self.inspect_mode = IRB.conf[:INSPECT_MODE]
|
64
|
-
self.use_tracer = IRB.conf[:USE_TRACER]
|
64
|
+
self.use_tracer = IRB.conf[:USE_TRACER]
|
65
65
|
self.use_loader = IRB.conf[:USE_LOADER] if IRB.conf[:USE_LOADER]
|
66
66
|
self.eval_history = IRB.conf[:EVAL_HISTORY] if IRB.conf[:EVAL_HISTORY]
|
67
67
|
|
@@ -161,6 +161,11 @@ module IRB
|
|
161
161
|
|
162
162
|
private_constant :KEYWORD_ALIASES
|
163
163
|
|
164
|
+
def use_tracer=(val)
|
165
|
+
require_relative "ext/tracer" if val
|
166
|
+
IRB.conf[:USE_TRACER] = val
|
167
|
+
end
|
168
|
+
|
164
169
|
private def build_completor
|
165
170
|
completor_type = IRB.conf[:COMPLETOR]
|
166
171
|
case completor_type
|
@@ -178,7 +183,7 @@ module IRB
|
|
178
183
|
|
179
184
|
private def build_type_completor
|
180
185
|
if RUBY_ENGINE == 'truffleruby'
|
181
|
-
# Avoid
|
186
|
+
# Avoid SyntaxError. truffleruby does not support endless method definition yet.
|
182
187
|
warn 'TypeCompletor is not supported on TruffleRuby yet'
|
183
188
|
return
|
184
189
|
end
|
@@ -573,14 +578,6 @@ module IRB
|
|
573
578
|
@inspect_method.inspect_value(@last_value)
|
574
579
|
end
|
575
580
|
|
576
|
-
alias __exit__ exit
|
577
|
-
# Exits the current session, see IRB.irb_exit
|
578
|
-
def exit(ret = 0)
|
579
|
-
IRB.irb_exit(@irb, ret)
|
580
|
-
rescue UncaughtThrowError
|
581
|
-
super
|
582
|
-
end
|
583
|
-
|
584
581
|
NOPRINTING_IVARS = ["@last_value"] # :nodoc:
|
585
582
|
NO_INSPECTING_IVARS = ["@irb", "@io"] # :nodoc:
|
586
583
|
IDNAME_IVARS = ["@prompt_mode"] # :nodoc:
|
data/lib/irb/ext/tracer.rb
CHANGED
@@ -3,76 +3,37 @@
|
|
3
3
|
# irb/lib/tracer.rb -
|
4
4
|
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
|
5
5
|
#
|
6
|
-
|
6
|
+
# Loading the gem "tracer" will cause it to extend IRB commands with:
|
7
|
+
# https://github.com/ruby/tracer/blob/v0.2.2/lib/tracer/irb.rb
|
7
8
|
begin
|
8
9
|
require "tracer"
|
9
10
|
rescue LoadError
|
10
11
|
$stderr.puts "Tracer extension of IRB is enabled but tracer gem wasn't found."
|
11
|
-
module IRB
|
12
|
-
class Context
|
13
|
-
def use_tracer=(opt)
|
14
|
-
# do nothing
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
12
|
return # This is about to disable loading below
|
19
13
|
end
|
20
14
|
|
21
15
|
module IRB
|
16
|
+
class CallTracer < ::CallTracer
|
17
|
+
IRB_DIR = File.expand_path('../..', __dir__)
|
22
18
|
|
23
|
-
|
24
|
-
|
25
|
-
Tracer.verbose = false
|
26
|
-
Tracer.add_filter {
|
27
|
-
|event, file, line, id, binding, *rests|
|
28
|
-
/^#{Regexp.quote(@CONF[:IRB_LIB_PATH])}/ !~ file and
|
29
|
-
File::basename(file) != "irb.rb"
|
30
|
-
}
|
31
|
-
end
|
32
|
-
|
33
|
-
class Context
|
34
|
-
# Whether Tracer is used when evaluating statements in this context.
|
35
|
-
#
|
36
|
-
# See +lib/tracer.rb+ for more information.
|
37
|
-
attr_reader :use_tracer
|
38
|
-
alias use_tracer? use_tracer
|
39
|
-
|
40
|
-
# Sets whether or not to use the Tracer library when evaluating statements
|
41
|
-
# in this context.
|
42
|
-
#
|
43
|
-
# See +lib/tracer.rb+ for more information.
|
44
|
-
def use_tracer=(opt)
|
45
|
-
if opt
|
46
|
-
Tracer.set_get_line_procs(@irb_path) {
|
47
|
-
|line_no, *rests|
|
48
|
-
@io.line(line_no)
|
49
|
-
}
|
50
|
-
elsif !opt && @use_tracer
|
51
|
-
Tracer.off
|
52
|
-
end
|
53
|
-
@use_tracer=opt
|
19
|
+
def skip?(tp)
|
20
|
+
super || tp.path.match?(IRB_DIR) || tp.path.match?('<internal:prelude>')
|
54
21
|
end
|
55
22
|
end
|
56
|
-
|
57
23
|
class WorkSpace
|
58
24
|
alias __evaluate__ evaluate
|
59
25
|
# Evaluate the context of this workspace and use the Tracer library to
|
60
26
|
# output the exact lines of code are being executed in chronological order.
|
61
27
|
#
|
62
|
-
# See
|
63
|
-
def evaluate(
|
64
|
-
if
|
65
|
-
|
66
|
-
begin
|
28
|
+
# See https://github.com/ruby/tracer for more information.
|
29
|
+
def evaluate(statements, file = __FILE__, line = __LINE__)
|
30
|
+
if IRB.conf[:USE_TRACER] == true
|
31
|
+
CallTracer.new(colorize: Color.colorable?).start do
|
67
32
|
__evaluate__(statements, file, line)
|
68
|
-
ensure
|
69
|
-
Tracer.off
|
70
33
|
end
|
71
34
|
else
|
72
|
-
__evaluate__(statements, file
|
35
|
+
__evaluate__(statements, file, line)
|
73
36
|
end
|
74
37
|
end
|
75
38
|
end
|
76
|
-
|
77
|
-
IRB.initialize_tracer
|
78
39
|
end
|
data/lib/irb/extend-command.rb
CHANGED
@@ -16,15 +16,6 @@ module IRB # :nodoc:
|
|
16
16
|
# See #install_alias_method.
|
17
17
|
OVERRIDE_ALL = 0x02
|
18
18
|
|
19
|
-
# Quits the current irb context
|
20
|
-
#
|
21
|
-
# +ret+ is the optional signal or message to send to Context#exit
|
22
|
-
#
|
23
|
-
# Same as <code>IRB.CurrentContext.exit</code>.
|
24
|
-
def irb_exit(ret = 0)
|
25
|
-
irb_context.exit(ret)
|
26
|
-
end
|
27
|
-
|
28
19
|
# Displays current configuration.
|
29
20
|
#
|
30
21
|
# Modifying the configuration is achieved by sending a message to IRB.conf.
|
@@ -35,13 +26,16 @@ module IRB # :nodoc:
|
|
35
26
|
@ALIASES = [
|
36
27
|
[:context, :irb_context, NO_OVERRIDE],
|
37
28
|
[:conf, :irb_context, NO_OVERRIDE],
|
38
|
-
[:irb_quit, :irb_exit, OVERRIDE_PRIVATE_ONLY],
|
39
|
-
[:exit, :irb_exit, OVERRIDE_PRIVATE_ONLY],
|
40
|
-
[:quit, :irb_exit, OVERRIDE_PRIVATE_ONLY],
|
41
29
|
]
|
42
30
|
|
43
31
|
|
44
32
|
@EXTEND_COMMANDS = [
|
33
|
+
[
|
34
|
+
:irb_exit, :Exit, "cmd/exit",
|
35
|
+
[:exit, OVERRIDE_PRIVATE_ONLY],
|
36
|
+
[:quit, OVERRIDE_PRIVATE_ONLY],
|
37
|
+
[:irb_quit, OVERRIDE_PRIVATE_ONLY],
|
38
|
+
],
|
45
39
|
[
|
46
40
|
:irb_current_working_workspace, :CurrentWorkingWorkspace, "cmd/chws",
|
47
41
|
[:cwws, NO_OVERRIDE],
|
@@ -323,7 +317,6 @@ module IRB # :nodoc:
|
|
323
317
|
|
324
318
|
@EXTEND_COMMANDS = [
|
325
319
|
[:eval_history=, "ext/eval_history.rb"],
|
326
|
-
[:use_tracer=, "ext/tracer.rb"],
|
327
320
|
[:use_loader=, "ext/use-loader.rb"],
|
328
321
|
]
|
329
322
|
|
data/lib/irb/history.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require "pathname"
|
2
|
+
|
1
3
|
module IRB
|
2
4
|
module HistorySavingAbility # :nodoc:
|
3
5
|
def support_history_saving?
|
@@ -5,7 +7,7 @@ module IRB
|
|
5
7
|
end
|
6
8
|
|
7
9
|
def reset_history_counter
|
8
|
-
@loaded_history_lines = self.class::HISTORY.size
|
10
|
+
@loaded_history_lines = self.class::HISTORY.size
|
9
11
|
end
|
10
12
|
|
11
13
|
def load_history
|
@@ -59,13 +61,19 @@ module IRB
|
|
59
61
|
append_history = true
|
60
62
|
end
|
61
63
|
|
64
|
+
pathname = Pathname.new(history_file)
|
65
|
+
unless Dir.exist?(pathname.dirname)
|
66
|
+
warn "Warning: The directory to save IRB's history file does not exist. Please double check `IRB.conf[:HISTORY_FILE]`'s value."
|
67
|
+
return
|
68
|
+
end
|
69
|
+
|
62
70
|
File.open(history_file, (append_history ? 'a' : 'w'), 0o600, encoding: IRB.conf[:LC_MESSAGES]&.encoding) do |f|
|
63
71
|
hist = history.map{ |l| l.scrub.split("\n").join("\\\n") }
|
64
72
|
unless append_history
|
65
73
|
begin
|
66
74
|
hist = hist.last(num) if hist.size > num and num > 0
|
67
75
|
rescue RangeError # bignum too big to convert into `long'
|
68
|
-
# Do nothing because the bignum should be treated as
|
76
|
+
# Do nothing because the bignum should be treated as infinity
|
69
77
|
end
|
70
78
|
end
|
71
79
|
f.puts(hist)
|
data/lib/irb/init.rb
CHANGED
@@ -6,6 +6,7 @@
|
|
6
6
|
|
7
7
|
module IRB # :nodoc:
|
8
8
|
@CONF = {}
|
9
|
+
@INITIALIZED = false
|
9
10
|
# Displays current configuration.
|
10
11
|
#
|
11
12
|
# Modifying the configuration is achieved by sending a message to IRB.conf.
|
@@ -41,6 +42,10 @@ module IRB # :nodoc:
|
|
41
42
|
format("irb %s (%s)", @RELEASE_VERSION, @LAST_UPDATE_DATE)
|
42
43
|
end
|
43
44
|
|
45
|
+
def IRB.initialized?
|
46
|
+
!!@INITIALIZED
|
47
|
+
end
|
48
|
+
|
44
49
|
# initialize config
|
45
50
|
def IRB.setup(ap_path, argv: ::ARGV)
|
46
51
|
IRB.init_config(ap_path)
|
@@ -52,13 +57,11 @@ module IRB # :nodoc:
|
|
52
57
|
unless @CONF[:PROMPT][@CONF[:PROMPT_MODE]]
|
53
58
|
fail UndefinedPromptMode, @CONF[:PROMPT_MODE]
|
54
59
|
end
|
60
|
+
@INITIALIZED = true
|
55
61
|
end
|
56
62
|
|
57
63
|
# @CONF default setting
|
58
64
|
def IRB.init_config(ap_path)
|
59
|
-
# class instance variables
|
60
|
-
@TRACER_INITIALIZED = false
|
61
|
-
|
62
65
|
# default configurations
|
63
66
|
unless ap_path and @CONF[:AP_NAME]
|
64
67
|
ap_path = File.join(File.dirname(File.dirname(__FILE__)), "irb.rb")
|
data/lib/irb/input-method.rb
CHANGED
@@ -291,11 +291,13 @@ module IRB
|
|
291
291
|
@auto_indent_proc = block
|
292
292
|
end
|
293
293
|
|
294
|
+
def retrieve_doc_namespace(matched)
|
295
|
+
preposing, _target, postposing, bind = @completion_params
|
296
|
+
@completor.doc_namespace(preposing, matched, postposing, bind: bind)
|
297
|
+
end
|
298
|
+
|
294
299
|
def show_doc_dialog_proc
|
295
|
-
|
296
|
-
preposing, _target, postposing, bind = @completion_params
|
297
|
-
@completor.doc_namespace(preposing, matched, postposing, bind: bind)
|
298
|
-
}
|
300
|
+
input_method = self # self is changed in the lambda below.
|
299
301
|
->() {
|
300
302
|
dialog.trap_key = nil
|
301
303
|
alt_d = [
|
@@ -311,7 +313,7 @@ module IRB
|
|
311
313
|
cursor_pos_to_render, result, pointer, autocomplete_dialog = context.pop(4)
|
312
314
|
return nil if result.nil? or pointer.nil? or pointer < 0
|
313
315
|
|
314
|
-
name =
|
316
|
+
name = input_method.retrieve_doc_namespace(result[pointer])
|
315
317
|
# Use first one because document dialog does not support multiple namespaces.
|
316
318
|
name = name.first if name.is_a?(Array)
|
317
319
|
|
@@ -419,8 +421,7 @@ module IRB
|
|
419
421
|
return
|
420
422
|
end
|
421
423
|
|
422
|
-
|
423
|
-
namespace = @completor.doc_namespace(preposing, matched, postposing, bind: bind)
|
424
|
+
namespace = retrieve_doc_namespace(matched)
|
424
425
|
return unless namespace
|
425
426
|
|
426
427
|
driver ||= RDoc::RI::Driver.new
|
data/lib/irb/inspector.rb
CHANGED
@@ -46,7 +46,7 @@ module IRB # :nodoc:
|
|
46
46
|
# Determines the inspector to use where +inspector+ is one of the keys passed
|
47
47
|
# during inspector definition.
|
48
48
|
def self.keys_with_inspector(inspector)
|
49
|
-
INSPECTORS.select{|k,v| v == inspector}.collect{|k, v| k}
|
49
|
+
INSPECTORS.select{|k, v| v == inspector}.collect{|k, v| k}
|
50
50
|
end
|
51
51
|
|
52
52
|
# Example
|
data/lib/irb/locale.rb
CHANGED
data/lib/irb/nesting_parser.rb
CHANGED
@@ -12,6 +12,8 @@ module IRB
|
|
12
12
|
skip = false
|
13
13
|
last_tok, state, args = opens.last
|
14
14
|
case state
|
15
|
+
when :in_alias_undef
|
16
|
+
skip = t.event == :on_kw
|
15
17
|
when :in_unquoted_symbol
|
16
18
|
unless IGNORE_TOKENS.include?(t.event)
|
17
19
|
opens.pop
|
@@ -61,17 +63,17 @@ module IRB
|
|
61
63
|
if args.include?(:arg)
|
62
64
|
case t.event
|
63
65
|
when :on_nl, :on_semicolon
|
64
|
-
# def
|
66
|
+
# def receiver.f;
|
65
67
|
body = :normal
|
66
68
|
when :on_lparen
|
67
|
-
# def
|
69
|
+
# def receiver.f()
|
68
70
|
next_args << :eq
|
69
71
|
else
|
70
72
|
if t.event == :on_op && t.tok == '='
|
71
73
|
# def receiver.f =
|
72
74
|
body = :oneliner
|
73
75
|
else
|
74
|
-
# def
|
76
|
+
# def receiver.f arg
|
75
77
|
next_args << :arg_without_paren
|
76
78
|
end
|
77
79
|
end
|
@@ -130,6 +132,10 @@ module IRB
|
|
130
132
|
opens.pop
|
131
133
|
opens << [t, nil]
|
132
134
|
end
|
135
|
+
when 'alias'
|
136
|
+
opens << [t, :in_alias_undef, 2]
|
137
|
+
when 'undef'
|
138
|
+
opens << [t, :in_alias_undef, 1]
|
133
139
|
when 'elsif', 'else', 'when'
|
134
140
|
opens.pop
|
135
141
|
opens << [t, nil]
|
@@ -174,6 +180,10 @@ module IRB
|
|
174
180
|
pending_heredocs.reverse_each { |t| opens << [t, nil] }
|
175
181
|
pending_heredocs = []
|
176
182
|
end
|
183
|
+
if opens.last && opens.last[1] == :in_alias_undef && !IGNORE_TOKENS.include?(t.event) && t.event != :on_heredoc_end
|
184
|
+
tok, state, arg = opens.pop
|
185
|
+
opens << [tok, state, arg - 1] if arg >= 1
|
186
|
+
end
|
177
187
|
yield t, opens if block_given?
|
178
188
|
end
|
179
189
|
opens.map(&:first) + pending_heredocs.reverse
|
data/lib/irb/ruby-lex.rb
CHANGED
data/lib/irb/source_finder.rb
CHANGED
@@ -19,7 +19,7 @@ module IRB
|
|
19
19
|
def find_source(signature, super_level = 0)
|
20
20
|
context_binding = @irb_context.workspace.binding
|
21
21
|
case signature
|
22
|
-
when /\A[A-Z]\w*(::[A-Z]\w*)*\z/ # Const::Name
|
22
|
+
when /\A(::)?[A-Z]\w*(::[A-Z]\w*)*\z/ # Const::Name
|
23
23
|
eval(signature, context_binding) # trigger autoload
|
24
24
|
base = context_binding.receiver.yield_self { |r| r.is_a?(Module) ? r : Object }
|
25
25
|
file, line = base.const_source_location(signature)
|
@@ -34,7 +34,8 @@ module IRB
|
|
34
34
|
return unless receiver.respond_to?(method, true)
|
35
35
|
file, line = method_target(receiver, super_level, method, "receiver")
|
36
36
|
end
|
37
|
-
|
37
|
+
# If the line is zero, it means that the target's source is probably in a binary file, which we should ignore.
|
38
|
+
if file && line && !line.zero? && File.exist?(file)
|
38
39
|
Source.new(file: file, first_line: line, last_line: find_end(file, line))
|
39
40
|
end
|
40
41
|
end
|
data/lib/irb/version.rb
CHANGED
data/lib/irb.rb
CHANGED
@@ -203,11 +203,10 @@ require_relative "irb/pager"
|
|
203
203
|
#
|
204
204
|
# === Input Command History
|
205
205
|
#
|
206
|
-
# By default, \IRB stores a history of up to 1000 input commands
|
207
|
-
#
|
208
|
-
#
|
209
|
-
#
|
210
|
-
# inin the same directory as that file).
|
206
|
+
# By default, \IRB stores a history of up to 1000 input commands in a
|
207
|
+
# file named <tt>.irb_history</tt>. The history file will be in the same directory
|
208
|
+
# as the {configuration file}[rdoc-ref:IRB@Configuration+File] if one is found, or
|
209
|
+
# in <tt>~/</tt> otherwise.
|
211
210
|
#
|
212
211
|
# A new \IRB session creates the history file if it does not exist,
|
213
212
|
# and appends to the file if it does exist.
|
@@ -365,7 +364,7 @@ require_relative "irb/pager"
|
|
365
364
|
# You can change the initial behavior and suppress all echoing by:
|
366
365
|
#
|
367
366
|
# - Adding to the configuration file: <tt>IRB.conf[:ECHO] = false</tt>.
|
368
|
-
# (The default value for this entry is +
|
367
|
+
# (The default value for this entry is +nil+, which means the same as +true+.)
|
369
368
|
# - Giving command-line option <tt>--noecho</tt>.
|
370
369
|
# (The default is <tt>--echo</tt>.)
|
371
370
|
#
|
@@ -392,7 +391,7 @@ require_relative "irb/pager"
|
|
392
391
|
# (The default value for this entry is +niL+, which means the same as +:truncate+.)
|
393
392
|
# - Giving command-line option <tt>--noecho-on-assignment</tt>
|
394
393
|
# or <tt>--echo-on-assignment</tt>.
|
395
|
-
# (The default is <tt>--truncate-echo-on-
|
394
|
+
# (The default is <tt>--truncate-echo-on-assignment</tt>.)
|
396
395
|
#
|
397
396
|
# During the session, you can change the current setting
|
398
397
|
# with configuration method <tt>conf.echo_on_assignment=</tt>
|
@@ -413,7 +412,7 @@ require_relative "irb/pager"
|
|
413
412
|
#
|
414
413
|
# By default, \IRB prefixes a newline to a multiline response.
|
415
414
|
#
|
416
|
-
# You can change the initial default value by adding to the
|
415
|
+
# You can change the initial default value by adding to the configuration file:
|
417
416
|
#
|
418
417
|
# IRB.conf[:NEWLINE_BEFORE_MULTILINE_OUTPUT] = false
|
419
418
|
#
|
@@ -705,12 +704,6 @@ require_relative "irb/pager"
|
|
705
704
|
# Command-line option <tt>-W[_level_]<tt>
|
706
705
|
# sets warning level; 0=silence, 1=medium, 2=verbose.
|
707
706
|
#
|
708
|
-
# :stopdoc:
|
709
|
-
# === Performance Measurement
|
710
|
-
#
|
711
|
-
# IRB.conf[:MEASURE] IRB.conf[:MEASURE_CALLBACKS] IRB.conf[:MEASURE_PROC]
|
712
|
-
# :startdoc:
|
713
|
-
#
|
714
707
|
# == Other Features
|
715
708
|
#
|
716
709
|
# === Load Modules
|
@@ -771,12 +764,6 @@ require_relative "irb/pager"
|
|
771
764
|
#
|
772
765
|
# Note that the configuration file entry overrides the command-line options.
|
773
766
|
#
|
774
|
-
# :stopdoc:
|
775
|
-
# === \Context Mode
|
776
|
-
#
|
777
|
-
# IRB.conf[:CONTEXT_MODE]
|
778
|
-
# :startdoc:
|
779
|
-
#
|
780
767
|
# === \IRB Name
|
781
768
|
#
|
782
769
|
# You can specify a name for \IRB.
|
@@ -815,12 +802,6 @@ require_relative "irb/pager"
|
|
815
802
|
# Each time the configuration is changed,
|
816
803
|
# that proc is called with argument +conf+:
|
817
804
|
#
|
818
|
-
# :stopdoc:
|
819
|
-
# === \Locale
|
820
|
-
#
|
821
|
-
# IRB.conf[:LC_MESSAGES]
|
822
|
-
# :startdoc:
|
823
|
-
#
|
824
805
|
# === Encodings
|
825
806
|
#
|
826
807
|
# Command-line option <tt>-E _ex_[:_in_]</tt>
|
@@ -904,8 +885,8 @@ module IRB
|
|
904
885
|
end
|
905
886
|
|
906
887
|
# Quits irb
|
907
|
-
def IRB.irb_exit(
|
908
|
-
throw :IRB_EXIT
|
888
|
+
def IRB.irb_exit(*)
|
889
|
+
throw :IRB_EXIT
|
909
890
|
end
|
910
891
|
|
911
892
|
# Aborts then interrupts irb.
|
@@ -963,7 +944,7 @@ module IRB
|
|
963
944
|
# Irb#eval_input will simply return the input, and we need to pass it to the debugger.
|
964
945
|
input = if IRB.conf[:SAVE_HISTORY] && context.io.support_history_saving?
|
965
946
|
# Previous IRB session's history has been saved when `Irb#run` is exited
|
966
|
-
# We need to make sure the saved history is not saved again by
|
947
|
+
# We need to make sure the saved history is not saved again by resetting the counter
|
967
948
|
context.io.reset_history_counter
|
968
949
|
|
969
950
|
begin
|
@@ -1533,7 +1514,7 @@ class Binding
|
|
1533
1514
|
# See IRB for more information.
|
1534
1515
|
def irb(show_code: true)
|
1535
1516
|
# Setup IRB with the current file's path and no command line arguments
|
1536
|
-
IRB.setup(source_location[0], argv: [])
|
1517
|
+
IRB.setup(source_location[0], argv: []) unless IRB.initialized?
|
1537
1518
|
# Create a new workspace using the current binding
|
1538
1519
|
workspace = IRB::WorkSpace.new(self)
|
1539
1520
|
# Print the code around the binding if show_code is true
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: irb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.11.
|
4
|
+
version: 1.11.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- aycabta
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2024-02-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: reline
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 0.
|
20
|
+
version: 0.4.2
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: 0.
|
27
|
+
version: 0.4.2
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: rdoc
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -68,6 +68,7 @@ files:
|
|
68
68
|
- lib/irb/cmd/debug.rb
|
69
69
|
- lib/irb/cmd/delete.rb
|
70
70
|
- lib/irb/cmd/edit.rb
|
71
|
+
- lib/irb/cmd/exit.rb
|
71
72
|
- lib/irb/cmd/finish.rb
|
72
73
|
- lib/irb/cmd/help.rb
|
73
74
|
- lib/irb/cmd/history.rb
|
@@ -148,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
149
|
- !ruby/object:Gem::Version
|
149
150
|
version: '0'
|
150
151
|
requirements: []
|
151
|
-
rubygems_version: 3.5.
|
152
|
+
rubygems_version: 3.5.4
|
152
153
|
signing_key:
|
153
154
|
specification_version: 4
|
154
155
|
summary: Interactive Ruby command-line tool for REPL (Read Eval Print Loop).
|