irb 1.14.0 → 1.14.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/irb/ruby_logo.aa CHANGED
@@ -1,41 +1,41 @@
1
- TYPE: LARGE
1
+ TYPE: ASCII_LARGE
2
2
 
3
- -+smJYYN?mm-
4
- HB"BBYT TQg NggT
5
- 9Q+g Nm,T 8g NJW
6
- YS+ N2NJ"Sg N?
7
- BQg #( gT Nggggk J
8
- 5j NJ NJ NNge
9
- #Q #JJ NgT N(
10
- @j bj mT J
11
- Bj @/d NJ (
12
- #q #(( NgT #J
13
- 5d #(t mT $d
14
- #q @(@J NJB;
15
- @( 5d ? HHH H HQmgggggggmN qD
16
- 5d #uN 2QdH E O
17
- 5 5JSd Nd NJH @d j
18
- Fd @J4d s NQH #d (
19
- #( #o6d Nd NgH #d #d
20
- 4 B&Od v NgT #d F
21
- #( 9JGd NH NgUd F
22
- #d #GJQ d NP $
23
- #J #U+#Q N Q # j
24
- j /W BQ+ BQ d NJ NJ
25
- - NjJH HBIjTQggPJQgW N W k #J
26
- #J b HYWgggN j s Nag d NN b #d
27
- #J 5- D s Ngg N d Nd F
28
- Fd BKH2 #+ s NNgg J Q J ]
29
- F H @ J N y K(d P I
30
- F4 E N? #d y #Q NJ E j
31
- F W Nd q m Bg NxW N(H-
32
- F d b @ m Hd gW vKJ
33
- NJ d K d s Bg aT FDd
34
- b # d N m BQ mV N>
35
- e5 Nd #d NggggggQWH HHHH NJ -
36
- m7 NW H N HSVO1z=?11-
37
- NgTH bB kH WBHWWHBHWmQgg&gggggNNN
38
- NNggggggNN
3
+ ,,,;;;;;;;;;;;;;;;;;;;;;;,,
4
+ ,,,;;;;;;;;;,, ,;;;' ''';;,
5
+ ,,;;;''' ';;;, ,,;;'' '';,
6
+ ,;;'' ;;;;;;;;,,,,,, ';;
7
+ ,;;'' ;;;;';;;'''';;;;;;;;;,,,;;
8
+ ,,;'' ;;;; ';;, ''''';;,
9
+ ,;;' ;;;' ';;, ;;
10
+ ,;;' ,;;; '';,, ;;
11
+ ,;;' ;;; ';;, ,;;
12
+ ;;' ;;;' '';,, ;;;
13
+ ,;' ;;;; ';;, ;;'
14
+ ,;;' ,;;;;' ,,,,,,,,,,,,;;;;;
15
+ ,;' ,;;;;;;;;;;;;;;;;;;;;'''''''';;;
16
+ ;;' ,;;;;;;;;;,, ;;;;
17
+ ;;' ,;;;'' ;;, ';;,, ,;;;;
18
+ ;;' ,;;;' ;; '';;, ,;';;;
19
+ ;;' ,;;;' ;;, '';;,, ,;',;;;
20
+ ,;;; ,;;;' ;; '';;,, ,;' ;;;'
21
+ ;;;; ,,;;;' ;;, ';;;' ;;;
22
+ ,;;; ,;;;;' ;; ,;;; ;;;
23
+ ;;;;; ,,;;;;;' ;;, ,;';; ;;;
24
+ ;;;;;, ,,;;;;;;;' ;; ,;;' ;;; ;;;
25
+ ;;;;;;;,,,,,,,;;;;;;;;;;;;;;,,, ;;, ,;' ;; ;;;
26
+ ;;' ;;;;;;;;;;'''' ,;';; ''';;;;,,, ;; ,;; ;; ;;;
27
+ ;; ;;;'' ;; ';; ''';;;;,,,, ;;, ,;;' ;;, ;;
28
+ ;; ;;;;, ;;' ';; ''';;;;,,;;;;' ';; ;;
29
+ ;;;;;;';, ,;; ;; '';;;;, ;;,;;
30
+ ;;; ;; ;;, ;; ;; ,;;' ';;, ;;;;;
31
+ ;; ;;; ;;, ;;' ;; ,,;'' ';;, ;;;;;
32
+ ;; ;; ;; ;; ;; ,;;' '';, ;;;;
33
+ ;;,;; ;; ;;' ;; ,;;'' ';,, ;;;'
34
+ ;;;; ';; ,;; ;;,,;;'' ';;, ;;;
35
+ ';;; ';; ;; ,;;;;;;;;;;;;;,,,,,,,,,,,, ';;;;;
36
+ ';, ';,;;' ,,,;;'' '''''''';;;;;;;;;;;;;;;;;;;
37
+ ';;,,, ;;;; ,,,,;;;;;;,,,,,;;;;;;;;;;;;;;;;;;;''''''''''''''
38
+ ''';;;;;;;;;;;;;;'''''''''''''''
39
39
  TYPE: ASCII
40
40
  ,,,;;;;''''';;;'';,
41
41
  ,,;'' ';;,;;; ',
@@ -57,6 +57,44 @@ TYPE: ASCII
57
57
  ;;; '; ;' ';,,'' ';,;;
58
58
  '; ';,; ,,;''''''''';;;;;;,,;;;
59
59
  ';,,;;,,;;;;;;;;;;''''''''''''''
60
+ TYPE: UNICODE_LARGE
61
+
62
+ ⣀⣤⣴⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣤⣄⡀
63
+ ⢀⣀⣤⣴⣾⣿⣿⣿⠿⣿⣿⣿⣿⣦⣀ ⢀⣤⣶⣿⠿⠛⠁⠈⠉⠙⠻⢿⣷⣦⡀
64
+ ⢀⣠⣴⣾⡿⠿⠛⠉⠉ ⠈⠙⢿⣿⣷⣤⡀ ⣠⣴⣾⡿⠟⠉ ⠉⠻⣿⣦
65
+ ⢀⣤⣶⣿⠟⠋⠁ ⢿⣿⣿⣿⣿⣿⣿⣧⣤⣤⣤⣀⣀⣀⡀ ⠘⢿⣷⡀
66
+ ⢀⣠⣾⡿⠟⠉ ⢸⣿⣿⣿⠟⢿⣿⣯⡙⠛⠛⠛⠿⠿⠿⢿⣿⣿⣶⣶⣶⣦⣤⣬⣿⣧
67
+ ⣠⣴⣿⠟⠋ ⢸⣿⣿⡿ ⠈⠻⣿⣶⣄ ⠉⠉⠉⠙⠛⢻⣿⡆
68
+ ⣠⣾⡿⠛⠁ ⣼⣿⣿⠃ ⠈⠙⢿⣷⣤⡀ ⠈⣿⡇
69
+ ⣠⣾⡿⠋ ⢠⣿⣿⡏ ⠙⠻⣿⣦⣀ ⣿⡇
70
+ ⣠⣾⡿⠋ ⢀⣿⣿⣿ ⠈⠛⢿⣷⣄⡀ ⢠⣿⡇
71
+ ⢀⣾⡿⠋ ⢀⣾⣿⣿⠇ ⠙⠻⣿⣦⣀ ⢸⣿⡇
72
+ ⢀⣴⣿⠟⠁ ⢀⣾⣿⣿⡟ ⠈⠻⢿⣷⣄ ⣾⣿⠇
73
+ ⢠⣾⡿⠃ ⣠⣿⣿⣿⣿⠃ ⣀⣀⣀⣀⣀⣀⣀⣀⣤⣤⣤⣤⣽⣿⣿⣿⣿
74
+ ⣰⣿⠟ ⣴⣿⣿⣿⣿⣿⣶⣶⣿⣿⣿⣿⣿⠿⠿⠿⠿⠿⠿⠿⠿⠛⠛⠛⠛⠛⠛⠛⠛⣿⣿⣿
75
+ ⣼⣿⠏ ⢠⣾⣿⣿⣿⡿⣿⣿⢿⣷⣦⣄ ⣼⣿⣿⣿
76
+ ⣼⣿⠃ ⢀⣴⣿⣿⣿⠟⠋ ⢸⣿⡆⠈⠛⠿⣿⣦⣄⡀ ⣰⣿⣿⣿⡇
77
+ ⢀⣾⣿⠃ ⢀⣴⣿⣿⣿⠟⠁ ⣿⣷ ⠈⠙⠻⣿⣶⣄⡀ ⣰⣿⠟⣿⣿⡇
78
+ ⢀⣾⣿⠇ ⢀⣴⣿⣿⣿⠟⠁ ⢸⣿⡆ ⠙⠻⢿⣷⣤⣀ ⣰⣿⠏⢠⣿⣿⡇
79
+ ⢠⣿⣿⡟ ⢀⣴⣿⣿⡿⠛⠁ ⣿⣷ ⠉⠻⢿⣷⣦⣀ ⣴⣿⠏ ⢸⣿⣿⠃
80
+ ⣿⣿⣿⡇ ⣠⣴⣿⣿⡿⠋ ⢸⣿⡆ ⠈⠛⢿⣿⣿⠃ ⢸⣿⣿
81
+ ⢠⣿⣿⣿ ⢀⣴⣾⣿⣿⡿⠋ ⠈⣿⣧ ⢠⣾⣿⣿ ⢸⣿⣿
82
+ ⢸⣿⣿⣿⡇ ⣀⣴⣾⣿⣿⣿⡿⠋ ⢹⣿⡆ ⣴⣿⠟⢹⣿⡀ ⢸⣿⡿
83
+ ⢸⣿⡟⣿⣿⣄ ⣀⣤⣶⣿⣿⣿⣿⣿⡟⠉ ⠈⣿⣷ ⢠⣾⡿⠋ ⢸⣿⡇ ⣼⣿⡇
84
+ ⢸⣿⡇⢹⣿⣿⣷⣦⣤⣤⣤⣤⣤⣴⣶⣾⣿⣿⣿⣿⡿⠿⣿⣿⣿⣿⣷⣶⣤⣤⣀⡀ ⢹⣿⡆ ⢀⣴⣿⠟ ⣿⣧ ⣿⣿⡇
85
+ ⢸⣿⠃ ⢿⣿⣿⣿⣿⣿⣿⡿⠿⠿⠛⠛⠉⠉⠁ ⢰⣿⠟⣿⣷⡀⠉⠙⠛⠿⢿⣿⣶⣦⣤⣀⡀ ⠈⣿⣷ ⣠⣿⡿⠁ ⢿⣿ ⣿⣿⡇
86
+ ⢸⣿ ⢀⣾⣿⣿⠋⠉⠁ ⢀⣿⡿ ⠘⣿⣷⡀ ⠉⠙⠛⠿⠿⣿⣶⣦⣤⣄⣀ ⢹⣿⡄ ⣠⣾⡿⠋ ⢸⣿⡆ ⣿⣿
87
+ ⣸⣿⢀⣾⣿⣿⣿⣆ ⣸⣿⠃ ⠘⢿⣷⡀ ⠈⠉⠛⠻⠿⣿⣷⣶⣤⣌⣿⣷⣾⡿⠋ ⠘⣿⡇ ⣿⣿
88
+ ⣿⣿⣾⡿⣿⡿⠹⣿⡆ ⢠⣿⡏ ⠈⢿⣷⡀ ⠈⠉⠙⣻⣿⣿⣿⣀ ⣿⣷⢰⣿⣿
89
+ ⣿⣿⡿⢁⣿⡇ ⢻⣿⡄ ⣾⣿ ⠈⢿⣷⡀ ⢀⣤⣾⡿⠋⠈⠻⢿⣷⣄ ⢻⣿⢸⣿⡟
90
+ ⣿⣿⠁⢸⣿⡇ ⢻⣿⡄ ⢸⣿⠇ ⠈⢿⣷⡀ ⣀⣴⣿⠟⠋ ⠙⢿⣷⣤⡀ ⢸⣿⣿⣿⡇
91
+ ⣿⣿ ⢸⣿⠁ ⠈⢿⣷⡀ ⢀⣿⡟ ⠈⢿⣷⡀ ⢀⣤⣾⡿⠛⠁ ⠙⠻⣿⣦⡀ ⠈⣿⣿⣿⡇
92
+ ⢸⣿⡄⣿⣿ ⠈⣿⣷⡀ ⣼⣿⠃ ⠈⢿⣷⡀ ⢀⣠⣶⣿⠟⠋ ⠈⠻⣿⣦⣄ ⣿⣿⣿⠇
93
+ ⠈⣿⣷⣿⡿ ⠘⣿⣧ ⢠⣿⡏ ⠈⢿⣷⣄⣤⣶⣿⠟⠋ ⠈⠛⢿⣷⣄ ⢸⣿⣿
94
+ ⠘⣿⣿⡇ ⠘⣿⣧ ⣾⣿ ⢀⣠⣼⣿⣿⣿⣿⣿⣷⣶⣶⣶⣶⣶⣶⣤⣤⣤⣤⣤⣤⣀⣀⣀⣀⣀⣀⡀ ⠙⢿⣷⣼⣿⣿
95
+ ⠈⠻⣿⣦⡀ ⠹⣿⣆⢸⣿⠇ ⣀⣠⣴⣾⡿⠟⠋⠁ ⠉⠉⠉⠉⠉⠉⠛⠛⣛⣛⣛⣻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⡿
96
+ ⠈⠻⢿⣷⣦⣄⣀⡀ ⢹⣿⣿⡟ ⢀⣀⣀⣤⣤⣶⣾⣿⣿⣿⣯⣥⣤⣤⣤⣤⣶⣶⣶⣶⣶⣶⣶⣾⣿⣿⣿⣿⠿⠿⠿⠿⠿⠿⠿⠟⠛⠛⠛⠛⠛⠛⠛⠉⠉⠉⠉⠉⠉
97
+ ⠉⠙⠛⠿⠿⠿⣿⣿⣿⣿⠿⠿⠿⠿⠿⠿⠿⠛⠛⠛⠛⠛⠛⠛⠋⠉⠉⠉⠉⠉⠉⠉
60
98
  TYPE: UNICODE
61
99
  ⣀⣤⣴⣾⣿⣿⣿⡛⠛⠛⠛⠛⣻⣿⠿⠛⠛⠶⣤⡀
62
100
  ⣀⣴⠾⠛⠉⠁ ⠙⣿⣶⣤⣶⣟⣉ ⠈⠻⣦
@@ -100,7 +100,7 @@ module IRB
100
100
  Source.new(file, line)
101
101
  elsif method
102
102
  # Method defined with eval, probably in IRB session
103
- source = RubyVM::AbstractSyntaxTree.of(method)&.source rescue nil
103
+ source = RubyVM::InstructionSequence.of(method)&.script_lines&.join rescue nil
104
104
  Source.new(file, line, source)
105
105
  end
106
106
  rescue EvaluationError
@@ -125,9 +125,8 @@ module IRB
125
125
  end
126
126
 
127
127
  def eval_receiver_or_owner(code)
128
- context_binding = @irb_context.workspace.binding
129
- eval(code, context_binding)
130
- rescue NameError
128
+ @irb_context.workspace.binding.eval(code)
129
+ rescue Exception
131
130
  raise EvaluationError
132
131
  end
133
132
 
data/lib/irb/version.rb CHANGED
@@ -5,7 +5,7 @@
5
5
  #
6
6
 
7
7
  module IRB # :nodoc:
8
- VERSION = "1.14.0"
8
+ VERSION = "1.14.2"
9
9
  @RELEASE_VERSION = VERSION
10
- @LAST_UPDATE_DATE = "2024-07-06"
10
+ @LAST_UPDATE_DATE = "2024-12-12"
11
11
  end
data/lib/irb/workspace.rb CHANGED
@@ -4,8 +4,6 @@
4
4
  # by Keiju ISHITSUKA(keiju@ruby-lang.org)
5
5
  #
6
6
 
7
- require "delegate"
8
-
9
7
  require_relative "helper_method"
10
8
 
11
9
  IRB::TOPLEVEL_BINDING = binding
@@ -16,7 +14,7 @@ module IRB # :nodoc:
16
14
  # set self to main if specified, otherwise
17
15
  # inherit main from TOPLEVEL_BINDING.
18
16
  def initialize(*main)
19
- if main[0].kind_of?(Binding)
17
+ if Binding === main[0]
20
18
  @binding = main.shift
21
19
  elsif IRB.conf[:SINGLE_IRB]
22
20
  @binding = TOPLEVEL_BINDING
@@ -70,37 +68,16 @@ EOF
70
68
  unless main.empty?
71
69
  case @main
72
70
  when Module
73
- @binding = eval("IRB.conf[:__MAIN__].module_eval('binding', __FILE__, __LINE__)", @binding, __FILE__, __LINE__)
71
+ @binding = eval("::IRB.conf[:__MAIN__].module_eval('::Kernel.binding', __FILE__, __LINE__)", @binding, __FILE__, __LINE__)
74
72
  else
75
73
  begin
76
- @binding = eval("IRB.conf[:__MAIN__].instance_eval('binding', __FILE__, __LINE__)", @binding, __FILE__, __LINE__)
74
+ @binding = eval("::IRB.conf[:__MAIN__].instance_eval('::Kernel.binding', __FILE__, __LINE__)", @binding, __FILE__, __LINE__)
77
75
  rescue TypeError
78
76
  fail CantChangeBinding, @main.inspect
79
77
  end
80
78
  end
81
79
  end
82
80
 
83
- case @main
84
- when Object
85
- use_delegator = @main.frozen?
86
- else
87
- use_delegator = true
88
- end
89
-
90
- if use_delegator
91
- @main = SimpleDelegator.new(@main)
92
- IRB.conf[:__MAIN__] = @main
93
- @main.singleton_class.class_eval do
94
- private
95
- define_method(:binding, Kernel.instance_method(:binding))
96
- define_method(:local_variables, Kernel.instance_method(:local_variables))
97
- # Define empty method to avoid delegator warning, will be overridden.
98
- define_method(:exit) {|*a, &b| }
99
- define_method(:exit!) {|*a, &b| }
100
- end
101
- @binding = eval("IRB.conf[:__MAIN__].instance_eval('binding', __FILE__, __LINE__)", @binding, *@binding.source_location)
102
- end
103
-
104
81
  @binding.local_variable_set(:_, nil)
105
82
  end
106
83
 
@@ -111,6 +88,9 @@ EOF
111
88
  attr_reader :main
112
89
 
113
90
  def load_helper_methods_to_main
91
+ # Do not load helper methods to frozen objects and BasicObject
92
+ return unless Object === @main && !@main.frozen?
93
+
114
94
  ancestors = class<<main;ancestors;end
115
95
  main.extend ExtendCommandBundle if !ancestors.include?(ExtendCommandBundle)
116
96
  main.extend HelpersContainer if !ancestors.include?(HelpersContainer)
@@ -176,11 +156,13 @@ EOF
176
156
  end
177
157
 
178
158
  module HelpersContainer
179
- def self.install_helper_methods
180
- HelperMethod.helper_methods.each do |name, helper_method_class|
181
- define_method name do |*args, **opts, &block|
182
- helper_method_class.instance.execute(*args, **opts, &block)
183
- end unless method_defined?(name)
159
+ class << self
160
+ def install_helper_methods
161
+ HelperMethod.helper_methods.each do |name, helper_method_class|
162
+ define_method name do |*args, **opts, &block|
163
+ helper_method_class.instance.execute(*args, **opts, &block)
164
+ end unless method_defined?(name)
165
+ end
184
166
  end
185
167
  end
186
168
 
data/lib/irb.rb CHANGED
@@ -14,6 +14,7 @@ require_relative "irb/default_commands"
14
14
 
15
15
  require_relative "irb/ruby-lex"
16
16
  require_relative "irb/statement"
17
+ require_relative "irb/history"
17
18
  require_relative "irb/input-method"
18
19
  require_relative "irb/locale"
19
20
  require_relative "irb/color"
@@ -220,11 +221,11 @@ require_relative "irb/pager"
220
221
  # *new_filepath*, which becomes the history file for the session.
221
222
  #
222
223
  # You can change the number of commands saved by adding to your configuration
223
- # file: `IRB.conf[:SAVE_HISTORY] = *n*`, wheHISTORY_FILEre *n* is one of:
224
+ # file: `IRB.conf[:SAVE_HISTORY] = *n*`, where *n* is one of:
224
225
  #
225
- # * Positive integer: the number of commands to be saved,
226
- # * Zero: all commands are to be saved.
227
- # * `nil`: no commands are to be saved,.
226
+ # * Positive integer: the number of commands to be saved.
227
+ # * Negative integer: all commands are to be saved.
228
+ # * Zero or `nil`: no commands are to be saved.
228
229
  #
229
230
  #
230
231
  # During the session, you can use methods `conf.save_history` or
@@ -880,40 +881,42 @@ module IRB
880
881
  # An exception raised by IRB.irb_abort
881
882
  class Abort < Exception;end
882
883
 
883
- # The current IRB::Context of the session, see IRB.conf
884
- #
885
- # irb
886
- # irb(main):001:0> IRB.CurrentContext.irb_name = "foo"
887
- # foo(main):002:0> IRB.conf[:MAIN_CONTEXT].irb_name #=> "foo"
888
- def IRB.CurrentContext # :nodoc:
889
- IRB.conf[:MAIN_CONTEXT]
890
- end
884
+ class << self
885
+ # The current IRB::Context of the session, see IRB.conf
886
+ #
887
+ # irb
888
+ # irb(main):001:0> IRB.CurrentContext.irb_name = "foo"
889
+ # foo(main):002:0> IRB.conf[:MAIN_CONTEXT].irb_name #=> "foo"
890
+ def CurrentContext # :nodoc:
891
+ conf[:MAIN_CONTEXT]
892
+ end
891
893
 
892
- # Initializes IRB and creates a new Irb.irb object at the `TOPLEVEL_BINDING`
893
- def IRB.start(ap_path = nil)
894
- STDOUT.sync = true
895
- $0 = File::basename(ap_path, ".rb") if ap_path
894
+ # Initializes IRB and creates a new Irb.irb object at the `TOPLEVEL_BINDING`
895
+ def start(ap_path = nil)
896
+ STDOUT.sync = true
897
+ $0 = File::basename(ap_path, ".rb") if ap_path
896
898
 
897
- IRB.setup(ap_path)
899
+ setup(ap_path)
898
900
 
899
- if @CONF[:SCRIPT]
900
- irb = Irb.new(nil, @CONF[:SCRIPT])
901
- else
902
- irb = Irb.new
901
+ if @CONF[:SCRIPT]
902
+ irb = Irb.new(nil, @CONF[:SCRIPT])
903
+ else
904
+ irb = Irb.new
905
+ end
906
+ irb.run(@CONF)
903
907
  end
904
- irb.run(@CONF)
905
- end
906
908
 
907
- # Quits irb
908
- def IRB.irb_exit(*) # :nodoc:
909
- throw :IRB_EXIT, false
910
- end
909
+ # Quits irb
910
+ def irb_exit(*) # :nodoc:
911
+ throw :IRB_EXIT, false
912
+ end
911
913
 
912
- # Aborts then interrupts irb.
913
- #
914
- # Will raise an Abort exception, or the given `exception`.
915
- def IRB.irb_abort(irb, exception = Abort) # :nodoc:
916
- irb.context.thread.raise exception, "abort then interrupt!"
914
+ # Aborts then interrupts irb.
915
+ #
916
+ # Will raise an Abort exception, or the given `exception`.
917
+ def irb_abort(irb, exception = Abort) # :nodoc:
918
+ irb.context.thread.raise exception, "abort then interrupt!"
919
+ end
917
920
  end
918
921
 
919
922
  class Irb
@@ -970,7 +973,7 @@ module IRB
970
973
  # debugger.
971
974
  input = nil
972
975
  forced_exit = catch(:IRB_EXIT) do
973
- if IRB.conf[:SAVE_HISTORY] && context.io.support_history_saving?
976
+ if History.save_history? && context.io.support_history_saving?
974
977
  # Previous IRB session's history has been saved when `Irb#run` is exited We need
975
978
  # to make sure the saved history is not saved again by resetting the counter
976
979
  context.io.reset_history_counter
@@ -1001,9 +1004,10 @@ module IRB
1001
1004
  prev_context = conf[:MAIN_CONTEXT]
1002
1005
  conf[:MAIN_CONTEXT] = context
1003
1006
 
1004
- save_history = !in_nested_session && conf[:SAVE_HISTORY] && context.io.support_history_saving?
1007
+ load_history = !in_nested_session && context.io.support_history_saving?
1008
+ save_history = load_history && History.save_history?
1005
1009
 
1006
- if save_history
1010
+ if load_history
1007
1011
  context.io.load_history
1008
1012
  end
1009
1013
 
@@ -1128,8 +1132,8 @@ module IRB
1128
1132
  return Statement::EmptyInput.new
1129
1133
  end
1130
1134
 
1131
- code.force_encoding(@context.io.encoding)
1132
- if (command, arg = parse_command(code))
1135
+ code = code.dup.force_encoding(@context.io.encoding)
1136
+ if (command, arg = @context.parse_command(code))
1133
1137
  command_class = Command.load_command(command)
1134
1138
  Statement::Command.new(code, command_class, arg)
1135
1139
  else
@@ -1138,35 +1142,8 @@ module IRB
1138
1142
  end
1139
1143
  end
1140
1144
 
1141
- ASSIGN_OPERATORS_REGEXP = Regexp.union(%w[= += -= *= /= %= **= &= |= &&= ||= ^= <<= >>=])
1142
-
1143
- def parse_command(code)
1144
- command_name, arg = code.strip.split(/\s+/, 2)
1145
- return unless code.lines.size == 1 && command_name
1146
-
1147
- arg ||= ''
1148
- command = command_name.to_sym
1149
- # Command aliases are always command. example: $, @
1150
- if (alias_name = @context.command_aliases[command])
1151
- return [alias_name, arg]
1152
- end
1153
-
1154
- # Assignment-like expression is not a command
1155
- return if arg.start_with?(ASSIGN_OPERATORS_REGEXP) && !arg.start_with?(/==|=~/)
1156
-
1157
- # Local variable have precedence over command
1158
- return if @context.local_variables.include?(command)
1159
-
1160
- # Check visibility
1161
- public_method = !!Kernel.instance_method(:public_method).bind_call(@context.main, command) rescue false
1162
- private_method = !public_method && !!Kernel.instance_method(:method).bind_call(@context.main, command) rescue false
1163
- if Command.execute_as_command?(command, public_method: public_method, private_method: private_method)
1164
- [command, arg]
1165
- end
1166
- end
1167
-
1168
1145
  def command?(code)
1169
- !!parse_command(code)
1146
+ !!@context.parse_command(code)
1170
1147
  end
1171
1148
 
1172
1149
  def configure_io
@@ -1492,10 +1469,10 @@ module IRB
1492
1469
  when "N"
1493
1470
  @context.irb_name
1494
1471
  when "m"
1495
- main_str = @context.main.to_s rescue "!#{$!.class}"
1472
+ main_str = @context.safe_method_call_on_main(:to_s) rescue "!#{$!.class}"
1496
1473
  truncate_prompt_main(main_str)
1497
1474
  when "M"
1498
- main_str = @context.main.inspect rescue "!#{$!.class}"
1475
+ main_str = @context.safe_method_call_on_main(:inspect) rescue "!#{$!.class}"
1499
1476
  truncate_prompt_main(main_str)
1500
1477
  when "l"
1501
1478
  ltype
data/man/irb.1 CHANGED
@@ -180,7 +180,7 @@ The default value is 16.
180
180
  .El
181
181
  .Pp
182
182
  .Sh ENVIRONMENT
183
- .Bl -tag -compact -width "XDG_CONFIG_HOME"
183
+ .Bl -tag -compact -width "IRB_USE_AUTOCOMPLETE"
184
184
  .It Ev IRB_LANG
185
185
  The locale used for
186
186
  .Nm .
@@ -190,10 +190,43 @@ The path to the personal initialization file.
190
190
  .Pp
191
191
  .It Ev XDG_CONFIG_HOME
192
192
  .Nm
193
- respects XDG_CONFIG_HOME. If this is set, load
193
+ respects XDG_CONFIG_HOME. If it is set and
194
+ .Ev IRBRC
195
+ is unset, load
194
196
  .Pa $XDG_CONFIG_HOME/irb/irbrc
195
197
  as a personal initialization file.
196
198
  .Pp
199
+ .It Ev RI_PAGER
200
+ The command specified would be used as a pager.
201
+ .Pp
202
+ .It Ev PAGER
203
+ The command specified would be used as a pager if
204
+ .Ev RI_PAGER
205
+ is unset.
206
+ .Pp
207
+ .It Ev VISUAL
208
+ Its value would be used to open files by the edit command.
209
+ .Pp
210
+ .It Ev EDITOR
211
+ Its value would be used to open files by the edit command if
212
+ .Ev VISUAL
213
+ is unset.
214
+ .Pp
215
+ .It Ev NO_COLOR
216
+ Assigning a value to it disables colorization.
217
+ .Pp
218
+ .It Ev IRB_USE_AUTOCOMPLETE
219
+ Assigning
220
+ .Sy false
221
+ to it disables autocompletion.
222
+ .Pp
223
+ .It Ev IRB_COMPLETOR
224
+ Autocompletion behavior. Allowed values are
225
+ .Sy regexp
226
+ or
227
+ .Sy type
228
+ .
229
+ .Pp
197
230
  .El
198
231
  .Pp
199
232
  Also
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.14.0
4
+ version: 1.14.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: 2024-07-06 00:00:00.000000000 Z
12
+ date: 2024-12-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: reline