irb 1.10.1 → 1.11.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ce85a9eb69af7fbbb8cb41a6d34029502d2b6712d916b7a3823176e2769cdcf8
4
- data.tar.gz: 711b52081eb0a97eee4901844b33e8cf9657316c8dde29c9eeb41d3a6998f78e
3
+ metadata.gz: 8029dc02923cbb80a77625adad559929050e1e699ef613a2de18cfdc998aef48
4
+ data.tar.gz: 4b4165fdd602583745cadd66ad9229eab74e473cf613f25c54a8446a2d9b1589
5
5
  SHA512:
6
- metadata.gz: 300f29f4e769be7ede8371fc7f667fb543eb7d8dd9249b062993074c2bdbb5808a3322cb4bb6a0ff58bd79c2d6e82a3bbac0f78b6a117e0095c63fbfe9431fb8
7
- data.tar.gz: 997b64b19a2902c6a9bc47ee4aff909b133f13e829456cc4fe4cf33b6ca425c8619f58ffda7be71bdd3dde1b91e2d23ba24bad9e9045b612fc190e6ac3fa42e7
6
+ metadata.gz: 1a93cf1c63baba6feba0e9b093ce9f0c200556657cab25760acef18370f1e23d3094865c9c1a8f66d6b1544f3715928f9d8d1212f629e6cec83d0f87ab8eb18c
7
+ data.tar.gz: 0171eda936e605d6ea83f9d0a98381f93f441bee435748c41839a04b2b672cae0fa9ab4ee3c276141df3e3ab40141581e3e7167ad710accf2790de664f5e7b34
data/.document CHANGED
@@ -1,4 +1,4 @@
1
1
  LICENSE.txt
2
2
  README.md
3
- doc
3
+ doc/irb/indexes.md
4
4
  lib/**/*.rb
data/lib/irb/cmd/debug.rb CHANGED
@@ -31,7 +31,7 @@ module IRB
31
31
  # 4. Exit the current Irb#run call via `throw :IRB_EXIT`.
32
32
  # 5. `Irb#debug_break` will be called and trigger the breakpoint, which will run the intended command.
33
33
  unless binding_irb?
34
- puts "`debug` command is only available when IRB is started with binding.irb"
34
+ puts "Debugging commands are only available when IRB is started with binding.irb"
35
35
  return
36
36
  end
37
37
 
@@ -12,32 +12,29 @@ module IRB
12
12
  super(*args)
13
13
  end
14
14
 
15
- def execute(type = nil, arg = nil, &block)
15
+ def execute(type = nil, arg = nil)
16
16
  # Please check IRB.init_config in lib/irb/init.rb that sets
17
17
  # IRB.conf[:MEASURE_PROC] to register default "measure" methods,
18
18
  # "measure :time" (abbreviated as "measure") and "measure :stackprof".
19
+
20
+ if block_given?
21
+ warn 'Configure IRB.conf[:MEASURE_PROC] to add custom measure methods.'
22
+ return
23
+ end
24
+
19
25
  case type
20
26
  when :off
21
- IRB.conf[:MEASURE] = nil
22
27
  IRB.unset_measure_callback(arg)
23
28
  when :list
24
29
  IRB.conf[:MEASURE_CALLBACKS].each do |type_name, _, arg_val|
25
30
  puts "- #{type_name}" + (arg_val ? "(#{arg_val.inspect})" : '')
26
31
  end
27
32
  when :on
28
- IRB.conf[:MEASURE] = true
29
- added = IRB.set_measure_callback(type, arg)
33
+ added = IRB.set_measure_callback(arg)
30
34
  puts "#{added[0]} is added." if added
31
35
  else
32
- if block_given?
33
- IRB.conf[:MEASURE] = true
34
- added = IRB.set_measure_callback(&block)
35
- puts "#{added[0]} is added." if added
36
- else
37
- IRB.conf[:MEASURE] = true
38
- added = IRB.set_measure_callback(type, arg)
39
- puts "#{added[0]} is added." if added
40
- end
36
+ added = IRB.set_measure_callback(type, arg)
37
+ puts "#{added[0]} is added." if added
41
38
  end
42
39
  nil
43
40
  end
@@ -27,17 +27,14 @@ module IRB
27
27
  puts "Error: Expected a string but got #{str.inspect}"
28
28
  return
29
29
  end
30
- if str.include? " -s"
31
- str, esses = str.split(" -")
32
- s_count = esses.count("^s").zero? ? esses.size : 1
33
- source = SourceFinder.new(@irb_context).find_source(str, s_count)
34
- else
35
- source = SourceFinder.new(@irb_context).find_source(str)
36
- end
30
+
31
+ str, esses = str.split(" -")
32
+ super_level = esses ? esses.count("s") : 0
33
+ source = SourceFinder.new(@irb_context).find_source(str, super_level)
37
34
 
38
35
  if source
39
36
  show_source(source)
40
- elsif s_count
37
+ elsif super_level > 0
41
38
  puts "Error: Couldn't locate a super definition for #{str}"
42
39
  else
43
40
  puts "Error: Couldn't locate a definition for #{str}"
data/lib/irb/context.rb CHANGED
@@ -264,15 +264,15 @@ module IRB
264
264
  attr_reader :prompt_mode
265
265
  # Standard IRB prompt.
266
266
  #
267
- # See IRB@Customizing+the+IRB+Prompt for more information.
267
+ # See {Custom Prompts}[rdoc-ref:IRB@Custom+Prompts] for more information.
268
268
  attr_accessor :prompt_i
269
269
  # IRB prompt for continuated strings.
270
270
  #
271
- # See IRB@Customizing+the+IRB+Prompt for more information.
271
+ # See {Custom Prompts}[rdoc-ref:IRB@Custom+Prompts] for more information.
272
272
  attr_accessor :prompt_s
273
273
  # IRB prompt for continuated statement. (e.g. immediately after an +if+)
274
274
  #
275
- # See IRB@Customizing+the+IRB+Prompt for more information.
275
+ # See {Custom Prompts}[rdoc-ref:IRB@Custom+Prompts] for more information.
276
276
  attr_accessor :prompt_c
277
277
 
278
278
  # TODO: Remove this when developing v2.0
@@ -394,8 +394,6 @@ module IRB
394
394
  # The default value is 16.
395
395
  #
396
396
  # Can also be set using the +--back-trace-limit+ command line option.
397
- #
398
- # See IRB@Command+line+options for more command line options.
399
397
  attr_accessor :back_trace_limit
400
398
 
401
399
  # User-defined IRB command aliases
@@ -463,7 +461,7 @@ module IRB
463
461
 
464
462
  # Sets the +mode+ of the prompt in this context.
465
463
  #
466
- # See IRB@Customizing+the+IRB+Prompt for more information.
464
+ # See {Custom Prompts}[rdoc-ref:IRB@Custom+Prompts] for more information.
467
465
  def prompt_mode=(mode)
468
466
  @prompt_mode = mode
469
467
  pconf = IRB.conf[:PROMPT][mode]
@@ -501,8 +499,6 @@ module IRB
501
499
  #
502
500
  # Can also be set using the +--inspect+ and +--noinspect+ command line
503
501
  # options.
504
- #
505
- # See IRB@Command+line+options for more command line options.
506
502
  def inspect_mode=(opt)
507
503
 
508
504
  if i = Inspector::INSPECTORS[opt]
data/lib/irb/help.rb CHANGED
@@ -5,7 +5,7 @@
5
5
  #
6
6
 
7
7
  module IRB
8
- # Outputs the irb help message, see IRB@Command+line+options.
8
+ # Outputs the irb help message, see IRB@Command-Line+Options.
9
9
  def IRB.print_usage
10
10
  lc = IRB.conf[:LC_MESSAGES]
11
11
  path = lc.find("irb/help-message")
data/lib/irb/init.rb CHANGED
@@ -215,6 +215,7 @@ module IRB # :nodoc:
215
215
  added = [:TIME, IRB.conf[:MEASURE_PROC][:TIME], arg]
216
216
  end
217
217
  if added
218
+ IRB.conf[:MEASURE] = true
218
219
  found = IRB.conf[:MEASURE_CALLBACKS].find{ |m| m[0] == added[0] && m[2] == added[2] }
219
220
  if found
220
221
  # already added
@@ -235,6 +236,7 @@ module IRB # :nodoc:
235
236
  type_sym = type.upcase.to_sym
236
237
  IRB.conf[:MEASURE_CALLBACKS].reject!{ |t, | t == type_sym }
237
238
  end
239
+ IRB.conf[:MEASURE] = nil if IRB.conf[:MEASURE_CALLBACKS].empty?
238
240
  end
239
241
 
240
242
  def IRB.init_error
@@ -387,18 +389,16 @@ module IRB # :nodoc:
387
389
  $LOAD_PATH.unshift(*load_path)
388
390
  end
389
391
 
390
- # running config
392
+ # Run the config file
391
393
  def IRB.run_config
392
394
  if @CONF[:RC]
393
395
  begin
394
- load rc_file
395
- rescue LoadError, Errno::ENOENT
396
- rescue # StandardError, ScriptError
397
- print "load error: #{rc_file}\n"
398
- print $!.class, ": ", $!, "\n"
399
- for err in $@[0, $@.size - 2]
400
- print "\t", err, "\n"
401
- end
396
+ file = rc_file
397
+ # Because rc_file always returns `HOME/.irbrc` even if no rc file is present, we can't warn users about missing rc files.
398
+ # Otherwise, it'd be very noisy.
399
+ load file if File.exist?(file)
400
+ rescue StandardError, ScriptError => e
401
+ warn "Error loading RC file '#{file}':\n#{e.full_message(highlight: false)}"
402
402
  end
403
403
  end
404
404
  end
@@ -416,7 +416,7 @@ module IRB # :nodoc:
416
416
  end
417
417
  case rc_file = @CONF[:RC_NAME_GENERATOR].call(ext)
418
418
  when String
419
- return rc_file
419
+ rc_file
420
420
  else
421
421
  fail IllegalRCNameGenerator
422
422
  end
@@ -16,7 +16,7 @@ module IRB
16
16
  @irb_context = irb_context
17
17
  end
18
18
 
19
- def find_source(signature, s_count = nil)
19
+ def find_source(signature, super_level = 0)
20
20
  context_binding = @irb_context.workspace.binding
21
21
  case signature
22
22
  when /\A[A-Z]\w*(::[A-Z]\w*)*\z/ # Const::Name
@@ -27,12 +27,12 @@ module IRB
27
27
  owner = eval(Regexp.last_match[:owner], context_binding)
28
28
  method = Regexp.last_match[:method]
29
29
  return unless owner.respond_to?(:instance_method)
30
- file, line = method_target(owner, s_count, method, "owner")
30
+ file, line = method_target(owner, super_level, method, "owner")
31
31
  when /\A((?<receiver>.+)(\.|::))?(?<method>[^ :.]+)\z/ # method, receiver.method, receiver::method
32
32
  receiver = eval(Regexp.last_match[:receiver] || 'self', context_binding)
33
33
  method = Regexp.last_match[:method]
34
34
  return unless receiver.respond_to?(method, true)
35
- file, line = method_target(receiver, s_count, method, "receiver")
35
+ file, line = method_target(receiver, super_level, method, "receiver")
36
36
  end
37
37
  if file && line && File.exist?(file)
38
38
  Source.new(file: file, first_line: line, last_line: find_end(file, line))
@@ -60,20 +60,14 @@ module IRB
60
60
  first_line
61
61
  end
62
62
 
63
- def method_target(owner_receiver, s_count, method, type)
63
+ def method_target(owner_receiver, super_level, method, type)
64
64
  case type
65
65
  when "owner"
66
66
  target_method = owner_receiver.instance_method(method)
67
- return target_method.source_location unless s_count
68
67
  when "receiver"
69
- if s_count
70
- target_method = owner_receiver.class.instance_method(method)
71
- else
72
- target_method = method
73
- return owner_receiver.method(method).source_location
74
- end
68
+ target_method = owner_receiver.method(method)
75
69
  end
76
- s_count.times do |s|
70
+ super_level.times do |s|
77
71
  target_method = target_method.super_method if target_method
78
72
  end
79
73
  target_method.nil? ? nil : target_method.source_location
data/lib/irb/version.rb CHANGED
@@ -5,7 +5,7 @@
5
5
  #
6
6
 
7
7
  module IRB # :nodoc:
8
- VERSION = "1.10.1"
8
+ VERSION = "1.11.0"
9
9
  @RELEASE_VERSION = VERSION
10
- @LAST_UPDATE_DATE = "2023-12-05"
10
+ @LAST_UPDATE_DATE = "2023-12-19"
11
11
  end
data/lib/irb/xmp.rb CHANGED
@@ -44,8 +44,8 @@ class XMP
44
44
  # The top-level binding or, optional +bind+ parameter will be used when
45
45
  # creating the workspace. See WorkSpace.new for more information.
46
46
  #
47
- # This uses the +:XMP+ prompt mode, see IRB@Customizing+the+IRB+Prompt for
48
- # full detail.
47
+ # This uses the +:XMP+ prompt mode.
48
+ # See {Custom Prompts}[rdoc-ref:IRB@Custom+Prompts] for more information.
49
49
  def initialize(bind = nil)
50
50
  IRB.init_config(nil)
51
51