irb 1.7.0 → 1.7.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/irb/version.rb CHANGED
@@ -5,7 +5,7 @@
5
5
  #
6
6
 
7
7
  module IRB # :nodoc:
8
- VERSION = "1.7.0"
8
+ VERSION = "1.7.1"
9
9
  @RELEASE_VERSION = VERSION
10
- @LAST_UPDATE_DATE = "2023-06-03"
10
+ @LAST_UPDATE_DATE = "2023-07-01"
11
11
  end
data/lib/irb.rb CHANGED
@@ -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 IRB.conf[:MEASURE] && IRB.conf[:MEASURE_CALLBACKS].empty?
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
- if IRB.conf[:MEASURE] && !IRB.conf[:MEASURE_CALLBACKS].empty?
569
- result = nil
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
- else
597
- exc = nil
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.0
4
+ version: 1.7.1
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-06-04 00:00:00.000000000 Z
12
+ date: 2023-07-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: reline
@@ -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
@@ -95,6 +94,7 @@ 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
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