irb 1.7.0 → 1.7.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/irb.gemspec +1 -1
- data/lib/irb/cmd/irb_info.rb +14 -18
- data/lib/irb/cmd/nop.rb +4 -8
- data/lib/irb/cmd/show_cmds.rb +1 -1
- data/lib/irb/cmd/show_source.rb +3 -3
- data/lib/irb/completion.rb +2 -2
- data/lib/irb/context.rb +47 -16
- data/lib/irb/ext/{history.rb → eval_history.rb} +4 -4
- data/lib/irb/ext/loader.rb +2 -0
- data/lib/irb/extend-command.rb +2 -4
- data/lib/irb/{ext/save-history.rb → history.rb} +0 -51
- data/lib/irb/input-method.rb +6 -15
- data/lib/irb/nesting_parser.rb +227 -0
- data/lib/irb/ruby-lex.rb +220 -495
- data/lib/irb/version.rb +2 -2
- data/lib/irb.rb +24 -30
- metadata +7 -8
- data/lib/irb/cmd/fork.rb +0 -34
- data/lib/irb/src_encoding.rb +0 -7
data/lib/irb/version.rb
CHANGED
data/lib/irb.rb
CHANGED
@@ -154,7 +154,7 @@ require_relative "irb/easter-egg"
|
|
154
154
|
#
|
155
155
|
# IRB.conf[:EVAL_HISTORY] = <number>
|
156
156
|
#
|
157
|
-
# See IRB::Context#eval_history= and
|
157
|
+
# See IRB::Context#eval_history= and EvalHistory class. The history of command
|
158
158
|
# results is not permanently saved in any file.
|
159
159
|
#
|
160
160
|
# == Customizing the IRB Prompt
|
@@ -506,8 +506,6 @@ module IRB
|
|
506
506
|
|
507
507
|
# Evaluates input for this session.
|
508
508
|
def eval_input
|
509
|
-
exc = nil
|
510
|
-
|
511
509
|
@scanner.set_prompt do
|
512
510
|
|ltype, indent, continue, line_no|
|
513
511
|
if ltype
|
@@ -560,26 +558,10 @@ module IRB
|
|
560
558
|
@scanner.each_top_level_statement do |line, line_no|
|
561
559
|
signal_status(:IN_EVAL) do
|
562
560
|
begin
|
563
|
-
if
|
564
|
-
IRB.set_measure_callback
|
565
|
-
end
|
566
|
-
# Assignment expression check should be done before @context.evaluate to handle code like `a /2#/ if false; a = 1`
|
561
|
+
# Assignment expression check should be done before evaluate_line to handle code like `a /2#/ if false; a = 1`
|
567
562
|
is_assignment = assignment_expression?(line)
|
568
|
-
|
569
|
-
|
570
|
-
last_proc = proc{ result = @context.evaluate(line, line_no, exception: exc) }
|
571
|
-
IRB.conf[:MEASURE_CALLBACKS].inject(last_proc) { |chain, item|
|
572
|
-
_name, callback, arg = item
|
573
|
-
proc {
|
574
|
-
callback.(@context, line, line_no, arg, exception: exc) do
|
575
|
-
chain.call
|
576
|
-
end
|
577
|
-
}
|
578
|
-
}.call
|
579
|
-
@context.set_last_value(result)
|
580
|
-
else
|
581
|
-
@context.evaluate(line, line_no, exception: exc)
|
582
|
-
end
|
563
|
+
evaluate_line(line, line_no)
|
564
|
+
|
583
565
|
if @context.echo?
|
584
566
|
if is_assignment
|
585
567
|
if @context.echo_on_assignment?
|
@@ -589,21 +571,33 @@ module IRB
|
|
589
571
|
output_value
|
590
572
|
end
|
591
573
|
end
|
592
|
-
rescue Interrupt => exc
|
593
574
|
rescue SystemExit, SignalException
|
594
575
|
raise
|
595
|
-
rescue Exception => exc
|
596
|
-
|
597
|
-
exc
|
598
|
-
next
|
576
|
+
rescue Interrupt, Exception => exc
|
577
|
+
handle_exception(exc)
|
578
|
+
@context.workspace.local_variable_set(:_, exc)
|
599
579
|
end
|
600
|
-
handle_exception(exc)
|
601
|
-
@context.workspace.local_variable_set(:_, exc)
|
602
|
-
exc = nil
|
603
580
|
end
|
604
581
|
end
|
605
582
|
end
|
606
583
|
|
584
|
+
def evaluate_line(line, line_no)
|
585
|
+
# Transform a non-identifier alias (@, $) or keywords (next, break)
|
586
|
+
command, args = line.split(/\s/, 2)
|
587
|
+
if original = @context.command_aliases[command.to_sym]
|
588
|
+
line = line.gsub(/\A#{Regexp.escape(command)}/, original.to_s)
|
589
|
+
command = original
|
590
|
+
end
|
591
|
+
|
592
|
+
# Hook command-specific transformation
|
593
|
+
command_class = ExtendCommandBundle.load_command(command)
|
594
|
+
if command_class&.respond_to?(:transform_args)
|
595
|
+
line = "#{command} #{command_class.transform_args(args)}"
|
596
|
+
end
|
597
|
+
|
598
|
+
@context.evaluate(line, line_no)
|
599
|
+
end
|
600
|
+
|
607
601
|
def convert_invalid_byte_sequence(str, enc)
|
608
602
|
str.force_encoding(enc)
|
609
603
|
str.scrub { |c|
|
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.7.
|
4
|
+
version: 1.7.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: 2023-
|
12
|
+
date: 2023-07-11 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.3.
|
20
|
+
version: 0.3.6
|
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.3.
|
27
|
+
version: 0.3.6
|
28
28
|
description: Interactive Ruby command-line tool for REPL (Read Eval Print Loop).
|
29
29
|
email:
|
30
30
|
- aycabta@gmail.com
|
@@ -55,7 +55,6 @@ files:
|
|
55
55
|
- lib/irb/cmd/delete.rb
|
56
56
|
- lib/irb/cmd/edit.rb
|
57
57
|
- lib/irb/cmd/finish.rb
|
58
|
-
- lib/irb/cmd/fork.rb
|
59
58
|
- lib/irb/cmd/help.rb
|
60
59
|
- lib/irb/cmd/info.rb
|
61
60
|
- lib/irb/cmd/irb_info.rb
|
@@ -77,16 +76,16 @@ files:
|
|
77
76
|
- lib/irb/context.rb
|
78
77
|
- lib/irb/easter-egg.rb
|
79
78
|
- lib/irb/ext/change-ws.rb
|
80
|
-
- lib/irb/ext/
|
79
|
+
- lib/irb/ext/eval_history.rb
|
81
80
|
- lib/irb/ext/loader.rb
|
82
81
|
- lib/irb/ext/multi-irb.rb
|
83
|
-
- lib/irb/ext/save-history.rb
|
84
82
|
- lib/irb/ext/tracer.rb
|
85
83
|
- lib/irb/ext/use-loader.rb
|
86
84
|
- lib/irb/ext/workspaces.rb
|
87
85
|
- lib/irb/extend-command.rb
|
88
86
|
- lib/irb/frame.rb
|
89
87
|
- lib/irb/help.rb
|
88
|
+
- lib/irb/history.rb
|
90
89
|
- lib/irb/init.rb
|
91
90
|
- lib/irb/input-method.rb
|
92
91
|
- lib/irb/inspector.rb
|
@@ -95,11 +94,11 @@ files:
|
|
95
94
|
- lib/irb/lc/ja/error.rb
|
96
95
|
- lib/irb/lc/ja/help-message
|
97
96
|
- lib/irb/locale.rb
|
97
|
+
- lib/irb/nesting_parser.rb
|
98
98
|
- lib/irb/notifier.rb
|
99
99
|
- lib/irb/output-method.rb
|
100
100
|
- lib/irb/ruby-lex.rb
|
101
101
|
- lib/irb/ruby_logo.aa
|
102
|
-
- lib/irb/src_encoding.rb
|
103
102
|
- lib/irb/version.rb
|
104
103
|
- lib/irb/workspace.rb
|
105
104
|
- lib/irb/ws-for-case-2.rb
|
data/lib/irb/cmd/fork.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: false
|
2
|
-
#
|
3
|
-
# fork.rb -
|
4
|
-
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
|
5
|
-
#
|
6
|
-
|
7
|
-
require_relative "nop"
|
8
|
-
|
9
|
-
module IRB
|
10
|
-
# :stopdoc:
|
11
|
-
|
12
|
-
module ExtendCommand
|
13
|
-
class Fork < Nop
|
14
|
-
def execute
|
15
|
-
pid = __send__ ExtendCommand.irb_original_method_name("fork")
|
16
|
-
unless pid
|
17
|
-
class << self
|
18
|
-
alias_method :exit, ExtendCommand.irb_original_method_name('exit')
|
19
|
-
end
|
20
|
-
if block_given?
|
21
|
-
begin
|
22
|
-
yield
|
23
|
-
ensure
|
24
|
-
exit
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
pid
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
# :startdoc:
|
34
|
-
end
|