irb 1.6.2 → 1.6.3
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 +13 -10
- data/README.md +53 -16
- data/exe/irb +0 -2
- data/irb.gemspec +5 -0
- data/lib/irb/cmd/chws.rb +0 -6
- data/lib/irb/cmd/fork.rb +0 -6
- data/lib/irb/cmd/help.rb +0 -6
- data/lib/irb/cmd/load.rb +0 -6
- data/lib/irb/cmd/ls.rb +20 -7
- data/lib/irb/cmd/nop.rb +1 -6
- data/lib/irb/cmd/pushws.rb +0 -6
- data/lib/irb/cmd/show_source.rb +3 -3
- data/lib/irb/cmd/subirb.rb +1 -6
- data/lib/irb/color.rb +1 -1
- data/lib/irb/completion.rb +8 -14
- data/lib/irb/context.rb +2 -7
- data/lib/irb/ext/change-ws.rb +0 -6
- data/lib/irb/ext/history.rb +2 -8
- data/lib/irb/ext/loader.rb +0 -7
- data/lib/irb/ext/multi-irb.rb +0 -6
- data/lib/irb/ext/save-history.rb +1 -6
- data/lib/irb/ext/tracer.rb +3 -8
- data/lib/irb/ext/use-loader.rb +0 -6
- data/lib/irb/ext/workspaces.rb +0 -6
- data/lib/irb/extend-command.rb +5 -10
- data/lib/irb/frame.rb +0 -6
- data/lib/irb/help.rb +0 -6
- data/lib/irb/init.rb +1 -9
- data/lib/irb/input-method.rb +1 -6
- data/lib/irb/inspector.rb +13 -10
- data/lib/irb/lc/error.rb +0 -6
- data/lib/irb/lc/help-message +2 -2
- data/lib/irb/lc/ja/error.rb +1 -7
- data/lib/irb/locale.rb +1 -6
- data/lib/irb/notifier.rb +0 -6
- data/lib/irb/output-method.rb +0 -6
- data/lib/irb/ruby-lex.rb +37 -52
- data/lib/irb/version.rb +2 -8
- data/lib/irb/workspace.rb +4 -15
- data/lib/irb/ws-for-case-2.rb +0 -6
- data/lib/irb/xmp.rb +0 -6
- data/lib/irb.rb +20 -12
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f82a38c3bf30c31ffcac5b5dd8f7883d9edd65edfbba779d87a18eb028c88c93
|
4
|
+
data.tar.gz: d45c6f3671612e3186a902c9c3406df16b350ae9a91e89d85383544267bc3eed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32eee54235bcc829238f55cb70d29cebce2c0024b6ebb76d9dfc6e168fd4d35fffccd228fa1b848ac4b5a3a0f35e4743533499a060ae2cf5858ffc9caee4ee8c
|
7
|
+
data.tar.gz: 20bc4fdda9f15c9c668ece83acf81c0b9828664d74dac042430cbbfe798e8467ddf9af0c41a63267ceee402eb92f71c9bc4413f7e91b95b5f8ba2bf64c989505
|
data/Gemfile
CHANGED
@@ -2,14 +2,17 @@ source "https://rubygems.org"
|
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
gem "
|
10
|
-
gem "
|
11
|
-
gem "stackprof" if is_unix && !is_truffleruby
|
12
|
-
gem "test-unit"
|
13
|
-
gem "reline", github: "ruby/reline" if ENV["WITH_LATEST_RELINE"] == "true"
|
14
|
-
gem "debug", github: "ruby/debug"
|
5
|
+
is_unix = RUBY_PLATFORM =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i
|
6
|
+
is_truffleruby = RUBY_DESCRIPTION =~ /truffleruby/
|
7
|
+
|
8
|
+
if is_unix && ENV['WITH_VTERM']
|
9
|
+
gem "vterm", github: "ruby/vterm-gem"
|
10
|
+
gem "yamatanooroti", github: "ruby/yamatanooroti"
|
15
11
|
end
|
12
|
+
|
13
|
+
gem "stackprof" if is_unix && !is_truffleruby
|
14
|
+
|
15
|
+
gem "reline", github: "ruby/reline" if ENV["WITH_LATEST_RELINE"] == "true"
|
16
|
+
gem "rake"
|
17
|
+
gem "test-unit"
|
18
|
+
gem "debug", github: "ruby/debug"
|
data/README.md
CHANGED
@@ -6,7 +6,13 @@ The `irb` command from your shell will start the interpreter.
|
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
9
|
-
|
9
|
+
> **Note**
|
10
|
+
>
|
11
|
+
> IRB is a default gem of Ruby so you shouldn't need to install it separately.
|
12
|
+
>
|
13
|
+
> But if you're using Ruby 2.6 or later and want to upgrade/install a specific version of IRB, please follow these steps.
|
14
|
+
|
15
|
+
To install it with `bundler`, add this line to your application's Gemfile:
|
10
16
|
|
11
17
|
```ruby
|
12
18
|
gem 'irb'
|
@@ -14,31 +20,62 @@ gem 'irb'
|
|
14
20
|
|
15
21
|
And then execute:
|
16
22
|
|
17
|
-
|
23
|
+
```shell
|
24
|
+
$ bundle
|
25
|
+
```
|
18
26
|
|
19
|
-
Or install it
|
27
|
+
Or install it directly with:
|
20
28
|
|
21
|
-
|
29
|
+
```shell
|
30
|
+
$ gem install irb
|
31
|
+
```
|
22
32
|
|
23
33
|
## Usage
|
24
34
|
|
25
|
-
|
35
|
+
### The `irb` Executable
|
26
36
|
|
27
|
-
|
37
|
+
You can start a fresh IRB session by typing `irb` in your terminal.
|
28
38
|
|
29
|
-
|
39
|
+
In the session, you can evaluate Ruby expressions or even prototype a small Ruby script. An input is executed when it is syntactically complete.
|
40
|
+
|
41
|
+
```shell
|
30
42
|
$ irb
|
31
|
-
irb(main):001:0> 1+2
|
32
|
-
|
33
|
-
irb(main):002:
|
34
|
-
irb(main):003:
|
35
|
-
irb(main):004:2
|
36
|
-
irb(main):005:
|
37
|
-
irb(main):006:
|
38
|
-
|
43
|
+
irb(main):001:0> 1 + 2
|
44
|
+
=> 3
|
45
|
+
irb(main):002:1* class Foo
|
46
|
+
irb(main):003:2* def foo
|
47
|
+
irb(main):004:2* puts 1
|
48
|
+
irb(main):005:1* end
|
49
|
+
irb(main):006:0> end
|
50
|
+
=> :foo
|
51
|
+
irb(main):007:0> Foo.new.foo
|
52
|
+
1
|
53
|
+
=> nil
|
39
54
|
```
|
40
55
|
|
41
|
-
The
|
56
|
+
### The `binding.irb` Breakpoint
|
57
|
+
|
58
|
+
If you use Ruby 2.5 or later versions, you can also use `binding.irb` in your program as breakpoints.
|
59
|
+
|
60
|
+
Once a `binding.irb` is evaluated, a new IRB session will be started with the surrounding context:
|
61
|
+
|
62
|
+
```shell
|
63
|
+
$ ruby test.rb
|
64
|
+
|
65
|
+
From: test.rb @ line 2 :
|
66
|
+
|
67
|
+
1: def greet(word)
|
68
|
+
=> 2: binding.irb
|
69
|
+
3: puts "Hello #{word}"
|
70
|
+
4: end
|
71
|
+
5:
|
72
|
+
6: greet("World")
|
73
|
+
|
74
|
+
irb(main):001:0> word
|
75
|
+
=> "World"
|
76
|
+
irb(main):002:0> exit
|
77
|
+
Hello World
|
78
|
+
```
|
42
79
|
|
43
80
|
## Commands
|
44
81
|
|
data/exe/irb
CHANGED
data/irb.gemspec
CHANGED
@@ -16,6 +16,11 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.homepage = "https://github.com/ruby/irb"
|
17
17
|
spec.licenses = ["Ruby", "BSD-2-Clause"]
|
18
18
|
|
19
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
20
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
21
|
+
spec.metadata["documentation_uri"] = spec.homepage
|
22
|
+
spec.metadata["changelog_uri"] = "#{spec.homepage}/releases"
|
23
|
+
|
19
24
|
spec.files = [
|
20
25
|
".document",
|
21
26
|
"Gemfile",
|
data/lib/irb/cmd/chws.rb
CHANGED
data/lib/irb/cmd/fork.rb
CHANGED
data/lib/irb/cmd/help.rb
CHANGED
data/lib/irb/cmd/load.rb
CHANGED
data/lib/irb/cmd/ls.rb
CHANGED
@@ -38,21 +38,34 @@ module IRB
|
|
38
38
|
|
39
39
|
def dump_methods(o, klass, obj)
|
40
40
|
singleton_class = begin obj.singleton_class; rescue TypeError; nil end
|
41
|
-
|
41
|
+
dumped_mods = Array.new
|
42
|
+
# singleton_class' ancestors should be at the front
|
43
|
+
maps = class_method_map(singleton_class&.ancestors || [], dumped_mods) + class_method_map(klass.ancestors, dumped_mods)
|
42
44
|
maps.each do |mod, methods|
|
43
45
|
name = mod == singleton_class ? "#{klass}.methods" : "#{mod}#methods"
|
44
46
|
o.dump(name, methods)
|
45
47
|
end
|
46
48
|
end
|
47
49
|
|
48
|
-
def class_method_map(classes)
|
49
|
-
|
50
|
-
classes.reject { |mod| mod >= Object }
|
51
|
-
|
52
|
-
|
50
|
+
def class_method_map(classes, dumped_mods)
|
51
|
+
dumped_methods = Array.new
|
52
|
+
classes = classes.reject { |mod| mod >= Object }
|
53
|
+
classes.map do |mod|
|
54
|
+
next if dumped_mods.include? mod
|
55
|
+
|
56
|
+
dumped_mods << mod
|
57
|
+
|
58
|
+
methods = mod.public_instance_methods(false).select do |method|
|
59
|
+
if dumped_methods.include? method
|
60
|
+
false
|
61
|
+
else
|
62
|
+
dumped_methods << method
|
63
|
+
true
|
64
|
+
end
|
53
65
|
end
|
66
|
+
|
54
67
|
[mod, methods]
|
55
|
-
end.
|
68
|
+
end.compact
|
56
69
|
end
|
57
70
|
|
58
71
|
class Output
|
data/lib/irb/cmd/nop.rb
CHANGED
data/lib/irb/cmd/pushws.rb
CHANGED
data/lib/irb/cmd/show_source.rb
CHANGED
@@ -40,15 +40,15 @@ module IRB
|
|
40
40
|
file, line = receiver.method(method).source_location if receiver.respond_to?(method)
|
41
41
|
end
|
42
42
|
if file && line
|
43
|
-
Source.new(file: file, first_line: line, last_line: find_end(file, line))
|
43
|
+
Source.new(file: file, first_line: line, last_line: find_end(file, line, irb_context))
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
47
|
private
|
48
48
|
|
49
|
-
def find_end(file, first_line)
|
49
|
+
def find_end(file, first_line, irb_context)
|
50
50
|
return first_line unless File.exist?(file)
|
51
|
-
lex = RubyLex.new
|
51
|
+
lex = RubyLex.new(irb_context)
|
52
52
|
lines = File.read(file).lines[(first_line - 1)..-1]
|
53
53
|
tokens = RubyLex.ripper_lex_without_warning(lines.join)
|
54
54
|
prev_tokens = []
|
data/lib/irb/cmd/subirb.rb
CHANGED
data/lib/irb/color.rb
CHANGED
@@ -242,7 +242,7 @@ module IRB # :nodoc:
|
|
242
242
|
case token
|
243
243
|
when :on_symbeg, :on_symbols_beg, :on_qsymbols_beg
|
244
244
|
@stack << true
|
245
|
-
when :on_ident, :on_op, :on_const, :on_ivar, :on_cvar, :on_gvar, :on_kw
|
245
|
+
when :on_ident, :on_op, :on_const, :on_ivar, :on_cvar, :on_gvar, :on_kw, :on_backtick
|
246
246
|
if @stack.last # Pop only when it's Symbol
|
247
247
|
@stack.pop
|
248
248
|
return prev_state
|
data/lib/irb/completion.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
2
|
#
|
3
3
|
# irb/completion.rb -
|
4
|
-
# $Release Version: 0.9$
|
5
|
-
# $Revision$
|
6
4
|
# by Keiju ISHITSUKA(keiju@ishitsuka.com)
|
7
5
|
# From Original Idea of shugo@ruby-lang.org
|
8
6
|
#
|
@@ -168,10 +166,12 @@ module IRB
|
|
168
166
|
|
169
167
|
def self.retrieve_completion_data(input, bind: IRB.conf[:MAIN_CONTEXT].workspace.binding, doc_namespace: false)
|
170
168
|
case input
|
171
|
-
|
169
|
+
# this regexp only matches the closing character because of irb's Reline.completer_quote_characters setting
|
170
|
+
# details are described in: https://github.com/ruby/irb/pull/523
|
171
|
+
when /^(.*["'`])\.([^.]*)$/
|
172
172
|
# String
|
173
173
|
receiver = $1
|
174
|
-
message = $
|
174
|
+
message = $2
|
175
175
|
|
176
176
|
if doc_namespace
|
177
177
|
"String.#{message}"
|
@@ -180,7 +180,9 @@ module IRB
|
|
180
180
|
select_message(receiver, message, candidates)
|
181
181
|
end
|
182
182
|
|
183
|
-
|
183
|
+
# this regexp only matches the closing character because of irb's Reline.completer_quote_characters setting
|
184
|
+
# details are described in: https://github.com/ruby/irb/pull/523
|
185
|
+
when /^(.*\/)\.([^.]*)$/
|
184
186
|
# Regexp
|
185
187
|
receiver = $1
|
186
188
|
message = $2
|
@@ -217,7 +219,7 @@ module IRB
|
|
217
219
|
select_message(receiver, message, proc_candidates | hash_candidates)
|
218
220
|
end
|
219
221
|
|
220
|
-
when /^(:[^:.]
|
222
|
+
when /^(:[^:.]+)$/
|
221
223
|
# Symbol
|
222
224
|
if doc_namespace
|
223
225
|
nil
|
@@ -358,14 +360,6 @@ module IRB
|
|
358
360
|
else
|
359
361
|
# func1.func2
|
360
362
|
candidates = []
|
361
|
-
to_ignore = ignored_modules
|
362
|
-
ObjectSpace.each_object(Module){|m|
|
363
|
-
next if (to_ignore.include?(m) rescue true)
|
364
|
-
next unless m.respond_to?(:instance_methods) # JRuby has modules that represent java packages. They don't include many common ruby methods
|
365
|
-
candidates.concat m.instance_methods(false).collect{|x| x.to_s}
|
366
|
-
}
|
367
|
-
candidates.sort!
|
368
|
-
candidates.uniq!
|
369
363
|
end
|
370
364
|
|
371
365
|
if doc_namespace
|
data/lib/irb/context.rb
CHANGED
@@ -1,14 +1,9 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
2
|
#
|
3
3
|
# irb/context.rb - irb context
|
4
|
-
# $Release Version: 0.9.6$
|
5
|
-
# $Revision$
|
6
4
|
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
|
7
5
|
#
|
8
|
-
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
6
|
+
|
12
7
|
require_relative "workspace"
|
13
8
|
require_relative "inspector"
|
14
9
|
require_relative "input-method"
|
@@ -499,7 +494,7 @@ module IRB
|
|
499
494
|
line = "#{command} #{command_class.transform_args(args)}"
|
500
495
|
end
|
501
496
|
|
502
|
-
set_last_value(@workspace.evaluate(
|
497
|
+
set_last_value(@workspace.evaluate(line, irb_path, line_no))
|
503
498
|
end
|
504
499
|
|
505
500
|
def inspect_last_value # :nodoc:
|
data/lib/irb/ext/change-ws.rb
CHANGED
data/lib/irb/ext/history.rb
CHANGED
@@ -1,14 +1,8 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
2
|
#
|
3
3
|
# history.rb -
|
4
|
-
# $Release Version: 0.9.6$
|
5
|
-
# $Revision$
|
6
4
|
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
|
7
5
|
#
|
8
|
-
# --
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
6
|
|
13
7
|
module IRB # :nodoc:
|
14
8
|
|
@@ -24,7 +18,7 @@ module IRB # :nodoc:
|
|
24
18
|
|
25
19
|
if defined?(@eval_history) && @eval_history
|
26
20
|
@eval_history_values.push @line_no, @last_value
|
27
|
-
@workspace.evaluate
|
21
|
+
@workspace.evaluate "__ = IRB.CurrentContext.instance_eval{@eval_history_values}"
|
28
22
|
end
|
29
23
|
|
30
24
|
@last_value
|
@@ -55,7 +49,7 @@ module IRB # :nodoc:
|
|
55
49
|
else
|
56
50
|
@eval_history_values = History.new(no)
|
57
51
|
IRB.conf[:__TMP__EHV__] = @eval_history_values
|
58
|
-
@workspace.evaluate(
|
52
|
+
@workspace.evaluate("__ = IRB.conf[:__TMP__EHV__]")
|
59
53
|
IRB.conf.delete(:__TMP_EHV__)
|
60
54
|
end
|
61
55
|
else
|
data/lib/irb/ext/loader.rb
CHANGED
@@ -1,15 +1,8 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
2
|
#
|
3
3
|
# loader.rb -
|
4
|
-
# $Release Version: 0.9.6$
|
5
|
-
# $Revision$
|
6
4
|
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
|
7
5
|
#
|
8
|
-
# --
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
|
13
6
|
|
14
7
|
module IRB # :nodoc:
|
15
8
|
# Raised in the event of an exception in a file loaded from an Irb session
|
data/lib/irb/ext/multi-irb.rb
CHANGED
data/lib/irb/ext/save-history.rb
CHANGED
data/lib/irb/ext/tracer.rb
CHANGED
@@ -1,14 +1,9 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
2
|
#
|
3
3
|
# irb/lib/tracer.rb -
|
4
|
-
# $Release Version: 0.9.6$
|
5
|
-
# $Revision$
|
6
4
|
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
|
7
5
|
#
|
8
|
-
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
6
|
+
|
12
7
|
begin
|
13
8
|
require "tracer"
|
14
9
|
rescue LoadError
|
@@ -70,12 +65,12 @@ module IRB
|
|
70
65
|
if context.use_tracer? && file != nil && line != nil
|
71
66
|
Tracer.on
|
72
67
|
begin
|
73
|
-
__evaluate__(
|
68
|
+
__evaluate__(statements, file, line)
|
74
69
|
ensure
|
75
70
|
Tracer.off
|
76
71
|
end
|
77
72
|
else
|
78
|
-
__evaluate__(
|
73
|
+
__evaluate__(statements, file || __FILE__, line || __LINE__)
|
79
74
|
end
|
80
75
|
end
|
81
76
|
end
|
data/lib/irb/ext/use-loader.rb
CHANGED
data/lib/irb/ext/workspaces.rb
CHANGED
data/lib/irb/extend-command.rb
CHANGED
@@ -1,14 +1,9 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
2
|
#
|
3
3
|
# irb/extend-command.rb - irb extend command
|
4
|
-
# $Release Version: 0.9.6$
|
5
|
-
# $Revision$
|
6
4
|
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
|
7
5
|
#
|
8
|
-
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
6
|
+
|
12
7
|
module IRB # :nodoc:
|
13
8
|
# Installs the default irb extensions command bundle.
|
14
9
|
module ExtendCommandBundle
|
@@ -264,8 +259,8 @@ module IRB # :nodoc:
|
|
264
259
|
kwargs = ", **kwargs" if RUBY_ENGINE == "ruby" && RUBY_VERSION >= "2.7.0"
|
265
260
|
line = __LINE__; eval %[
|
266
261
|
def #{cmd_name}(*opts#{kwargs}, &b)
|
267
|
-
require_relative "#{load_file}"
|
268
|
-
arity = ExtendCommand::#{cmd_class}.instance_method(:execute).arity
|
262
|
+
Kernel.require_relative "#{load_file}"
|
263
|
+
arity = ::IRB::ExtendCommand::#{cmd_class}.instance_method(:execute).arity
|
269
264
|
args = (1..(arity < 0 ? ~arity : arity)).map {|i| "arg" + i.to_s }
|
270
265
|
args << "*opts#{kwargs}" if arity < 0
|
271
266
|
args << "&block"
|
@@ -274,7 +269,7 @@ module IRB # :nodoc:
|
|
274
269
|
unless singleton_class.class_variable_defined?(:@@#{cmd_name}_)
|
275
270
|
singleton_class.class_variable_set(:@@#{cmd_name}_, true)
|
276
271
|
def self.#{cmd_name}_(\#{args})
|
277
|
-
ExtendCommand::#{cmd_class}.execute(irb_context, \#{args})
|
272
|
+
::IRB::ExtendCommand::#{cmd_class}.execute(irb_context, \#{args})
|
278
273
|
end
|
279
274
|
end
|
280
275
|
], nil, __FILE__, line
|
@@ -284,7 +279,7 @@ module IRB # :nodoc:
|
|
284
279
|
else
|
285
280
|
line = __LINE__; eval %[
|
286
281
|
def #{cmd_name}(*opts, &b)
|
287
|
-
ExtendCommand::#{cmd_class}.execute(irb_context, *opts, &b)
|
282
|
+
::IRB::ExtendCommand::#{cmd_class}.execute(irb_context, *opts, &b)
|
288
283
|
end
|
289
284
|
], nil, __FILE__, line
|
290
285
|
end
|
data/lib/irb/frame.rb
CHANGED