irb 1.8.3 → 1.13.1

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.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/.document +1 -1
  3. data/Gemfile +9 -1
  4. data/README.md +149 -25
  5. data/Rakefile +13 -3
  6. data/irb.gemspec +2 -2
  7. data/lib/irb/cmd/nop.rb +3 -52
  8. data/lib/irb/color.rb +2 -2
  9. data/lib/irb/command/backtrace.rb +17 -0
  10. data/lib/irb/command/base.rb +62 -0
  11. data/lib/irb/command/break.rb +17 -0
  12. data/lib/irb/command/catch.rb +17 -0
  13. data/lib/irb/command/chws.rb +40 -0
  14. data/lib/irb/command/context.rb +16 -0
  15. data/lib/irb/{cmd → command}/continue.rb +3 -3
  16. data/lib/irb/{cmd → command}/debug.rb +11 -20
  17. data/lib/irb/{cmd → command}/delete.rb +3 -3
  18. data/lib/irb/command/disable_irb.rb +19 -0
  19. data/lib/irb/command/edit.rb +63 -0
  20. data/lib/irb/command/exit.rb +18 -0
  21. data/lib/irb/{cmd → command}/finish.rb +3 -3
  22. data/lib/irb/command/force_exit.rb +18 -0
  23. data/lib/irb/command/help.rb +83 -0
  24. data/lib/irb/command/history.rb +45 -0
  25. data/lib/irb/command/info.rb +17 -0
  26. data/lib/irb/command/internal_helpers.rb +27 -0
  27. data/lib/irb/{cmd → command}/irb_info.rb +7 -7
  28. data/lib/irb/{cmd → command}/load.rb +23 -8
  29. data/lib/irb/{cmd → command}/ls.rb +30 -14
  30. data/lib/irb/{cmd → command}/measure.rb +18 -17
  31. data/lib/irb/{cmd → command}/next.rb +3 -3
  32. data/lib/irb/command/pushws.rb +65 -0
  33. data/lib/irb/command/show_doc.rb +51 -0
  34. data/lib/irb/command/show_source.rb +74 -0
  35. data/lib/irb/{cmd → command}/step.rb +3 -3
  36. data/lib/irb/{cmd → command}/subirb.rb +31 -17
  37. data/lib/irb/{cmd → command}/whereami.rb +3 -5
  38. data/lib/irb/command.rb +23 -0
  39. data/lib/irb/completion.rb +74 -31
  40. data/lib/irb/context.rb +144 -57
  41. data/lib/irb/debug.rb +18 -0
  42. data/lib/irb/default_commands.rb +260 -0
  43. data/lib/irb/easter-egg.rb +16 -6
  44. data/lib/irb/ext/change-ws.rb +6 -8
  45. data/lib/irb/ext/eval_history.rb +3 -3
  46. data/lib/irb/ext/loader.rb +4 -4
  47. data/lib/irb/ext/multi-irb.rb +5 -5
  48. data/lib/irb/ext/tracer.rb +12 -51
  49. data/lib/irb/ext/use-loader.rb +6 -8
  50. data/lib/irb/ext/workspaces.rb +10 -34
  51. data/lib/irb/frame.rb +1 -1
  52. data/lib/irb/help.rb +3 -3
  53. data/lib/irb/helper_method/base.rb +16 -0
  54. data/lib/irb/helper_method/conf.rb +11 -0
  55. data/lib/irb/helper_method.rb +29 -0
  56. data/lib/irb/history.rb +15 -4
  57. data/lib/irb/init.rb +119 -52
  58. data/lib/irb/input-method.rb +77 -27
  59. data/lib/irb/inspector.rb +3 -3
  60. data/lib/irb/lc/error.rb +1 -11
  61. data/lib/irb/lc/help-message +4 -0
  62. data/lib/irb/lc/ja/error.rb +1 -11
  63. data/lib/irb/lc/ja/help-message +13 -0
  64. data/lib/irb/locale.rb +2 -2
  65. data/lib/irb/nesting_parser.rb +13 -3
  66. data/lib/irb/notifier.rb +1 -1
  67. data/lib/irb/output-method.rb +2 -8
  68. data/lib/irb/pager.rb +16 -11
  69. data/lib/irb/ruby-lex.rb +2 -2
  70. data/lib/irb/ruby_logo.aa +43 -0
  71. data/lib/irb/source_finder.rb +112 -37
  72. data/lib/irb/statement.rb +24 -24
  73. data/lib/irb/version.rb +3 -3
  74. data/lib/irb/workspace.rb +22 -6
  75. data/lib/irb/ws-for-case-2.rb +1 -1
  76. data/lib/irb/xmp.rb +3 -3
  77. data/lib/irb.rb +1071 -556
  78. data/man/irb.1 +7 -0
  79. metadata +41 -31
  80. data/lib/irb/cmd/backtrace.rb +0 -21
  81. data/lib/irb/cmd/break.rb +0 -21
  82. data/lib/irb/cmd/catch.rb +0 -21
  83. data/lib/irb/cmd/chws.rb +0 -36
  84. data/lib/irb/cmd/edit.rb +0 -60
  85. data/lib/irb/cmd/help.rb +0 -23
  86. data/lib/irb/cmd/info.rb +0 -21
  87. data/lib/irb/cmd/pushws.rb +0 -45
  88. data/lib/irb/cmd/show_cmds.rb +0 -53
  89. data/lib/irb/cmd/show_doc.rb +0 -48
  90. data/lib/irb/cmd/show_source.rb +0 -61
  91. data/lib/irb/extend-command.rb +0 -354
data/lib/irb/init.rb CHANGED
@@ -1,10 +1,50 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #
3
3
  # irb/init.rb - irb initialize module
4
4
  # by Keiju ISHITSUKA(keiju@ruby-lang.org)
5
5
  #
6
6
 
7
7
  module IRB # :nodoc:
8
+ @CONF = {}
9
+ @INITIALIZED = false
10
+ # Displays current configuration.
11
+ #
12
+ # Modifying the configuration is achieved by sending a message to IRB.conf.
13
+ #
14
+ # See IRB@Configuration for more information.
15
+ def IRB.conf
16
+ @CONF
17
+ end
18
+
19
+ def @CONF.inspect
20
+ array = []
21
+ for k, v in sort{|a1, a2| a1[0].id2name <=> a2[0].id2name}
22
+ case k
23
+ when :MAIN_CONTEXT, :__TMP__EHV__
24
+ array.push format("CONF[:%s]=...myself...", k.id2name)
25
+ when :PROMPT
26
+ s = v.collect{
27
+ |kk, vv|
28
+ ss = vv.collect{|kkk, vvv| ":#{kkk.id2name}=>#{vvv.inspect}"}
29
+ format(":%s=>{%s}", kk.id2name, ss.join(", "))
30
+ }
31
+ array.push format("CONF[:%s]={%s}", k.id2name, s.join(", "))
32
+ else
33
+ array.push format("CONF[:%s]=%s", k.id2name, v.inspect)
34
+ end
35
+ end
36
+ array.join("\n")
37
+ end
38
+
39
+ # Returns the current version of IRB, including release version and last
40
+ # updated date.
41
+ def IRB.version
42
+ format("irb %s (%s)", @RELEASE_VERSION, @LAST_UPDATE_DATE)
43
+ end
44
+
45
+ def IRB.initialized?
46
+ !!@INITIALIZED
47
+ end
8
48
 
9
49
  # initialize config
10
50
  def IRB.setup(ap_path, argv: ::ARGV)
@@ -17,17 +57,16 @@ module IRB # :nodoc:
17
57
  unless @CONF[:PROMPT][@CONF[:PROMPT_MODE]]
18
58
  fail UndefinedPromptMode, @CONF[:PROMPT_MODE]
19
59
  end
60
+ @INITIALIZED = true
20
61
  end
21
62
 
22
63
  # @CONF default setting
23
64
  def IRB.init_config(ap_path)
24
- # class instance variables
25
- @TRACER_INITIALIZED = false
26
-
27
65
  # default configurations
28
66
  unless ap_path and @CONF[:AP_NAME]
29
67
  ap_path = File.join(File.dirname(File.dirname(__FILE__)), "irb.rb")
30
68
  end
69
+ @CONF[:VERSION] = version
31
70
  @CONF[:AP_NAME] = File::basename(ap_path, ".rb")
32
71
 
33
72
  @CONF[:IRB_NAME] = "irb"
@@ -40,11 +79,13 @@ module IRB # :nodoc:
40
79
  @CONF[:USE_SINGLELINE] = false unless defined?(ReadlineInputMethod)
41
80
  @CONF[:USE_COLORIZE] = (nc = ENV['NO_COLOR']).nil? || nc.empty?
42
81
  @CONF[:USE_AUTOCOMPLETE] = ENV.fetch("IRB_USE_AUTOCOMPLETE", "true") != "false"
82
+ @CONF[:COMPLETOR] = ENV.fetch("IRB_COMPLETOR", "regexp").to_sym
43
83
  @CONF[:INSPECT_MODE] = true
44
84
  @CONF[:USE_TRACER] = false
45
85
  @CONF[:USE_LOADER] = false
46
86
  @CONF[:IGNORE_SIGINT] = true
47
87
  @CONF[:IGNORE_EOF] = false
88
+ @CONF[:USE_PAGER] = true
48
89
  @CONF[:EXTRA_DOC_DIRS] = []
49
90
  @CONF[:ECHO] = nil
50
91
  @CONF[:ECHO_ON_ASSIGNMENT] = nil
@@ -151,10 +192,6 @@ module IRB # :nodoc:
151
192
  # Symbol aliases
152
193
  :'$' => :show_source,
153
194
  :'@' => :whereami,
154
- # Keyword aliases
155
- :break => :irb_break,
156
- :catch => :irb_catch,
157
- :next => :irb_next,
158
195
  }
159
196
  end
160
197
 
@@ -181,6 +218,7 @@ module IRB # :nodoc:
181
218
  added = [:TIME, IRB.conf[:MEASURE_PROC][:TIME], arg]
182
219
  end
183
220
  if added
221
+ IRB.conf[:MEASURE] = true
184
222
  found = IRB.conf[:MEASURE_CALLBACKS].find{ |m| m[0] == added[0] && m[2] == added[2] }
185
223
  if found
186
224
  # already added
@@ -201,6 +239,7 @@ module IRB # :nodoc:
201
239
  type_sym = type.upcase.to_sym
202
240
  IRB.conf[:MEASURE_CALLBACKS].reject!{ |t, | t == type_sym }
203
241
  end
242
+ IRB.conf[:MEASURE] = nil if IRB.conf[:MEASURE_CALLBACKS].empty?
204
243
  end
205
244
 
206
245
  def IRB.init_error
@@ -248,6 +287,8 @@ module IRB # :nodoc:
248
287
  end
249
288
  when "--noinspect"
250
289
  @CONF[:INSPECT_MODE] = false
290
+ when "--no-pager"
291
+ @CONF[:USE_PAGER] = false
251
292
  when "--singleline", "--readline", "--legacy"
252
293
  @CONF[:USE_SINGLELINE] = true
253
294
  when "--nosingleline", "--noreadline"
@@ -293,6 +334,10 @@ module IRB # :nodoc:
293
334
  @CONF[:USE_AUTOCOMPLETE] = true
294
335
  when "--noautocomplete"
295
336
  @CONF[:USE_AUTOCOMPLETE] = false
337
+ when "--regexp-completor"
338
+ @CONF[:COMPLETOR] = :regexp
339
+ when "--type-completor"
340
+ @CONF[:COMPLETOR] = :type
296
341
  when /^--prompt-mode(?:=(.+))?/, /^--prompt(?:=(.+))?/
297
342
  opt = $1 || argv.shift
298
343
  prompt_mode = opt.upcase.tr("-", "_").intern
@@ -347,61 +392,39 @@ module IRB # :nodoc:
347
392
  $LOAD_PATH.unshift(*load_path)
348
393
  end
349
394
 
350
- # running config
395
+ # Run the config file
351
396
  def IRB.run_config
352
397
  if @CONF[:RC]
353
- begin
354
- load rc_file
355
- rescue LoadError, Errno::ENOENT
356
- rescue # StandardError, ScriptError
357
- print "load error: #{rc_file}\n"
358
- print $!.class, ": ", $!, "\n"
359
- for err in $@[0, $@.size - 2]
360
- print "\t", err, "\n"
361
- end
398
+ irbrc_files.each do |rc|
399
+ load rc
400
+ rescue StandardError, ScriptError => e
401
+ warn "Error loading RC file '#{rc}':\n#{e.full_message(highlight: false)}"
362
402
  end
363
403
  end
364
404
  end
365
405
 
366
406
  IRBRC_EXT = "rc"
367
- def IRB.rc_file(ext = IRBRC_EXT)
368
- if !@CONF[:RC_NAME_GENERATOR]
369
- rc_file_generators do |rcgen|
370
- @CONF[:RC_NAME_GENERATOR] ||= rcgen
371
- if File.exist?(rcgen.call(IRBRC_EXT))
372
- @CONF[:RC_NAME_GENERATOR] = rcgen
373
- break
374
- end
375
- end
407
+
408
+ def IRB.rc_file(ext)
409
+ prepare_irbrc_name_generators
410
+
411
+ # When irbrc exist in default location
412
+ if (rcgen = @existing_rc_name_generators.first)
413
+ return rcgen.call(ext)
376
414
  end
377
- case rc_file = @CONF[:RC_NAME_GENERATOR].call(ext)
378
- when String
379
- return rc_file
380
- else
381
- fail IllegalRCNameGenerator
415
+
416
+ # When irbrc does not exist in default location
417
+ rc_file_generators do |rcgen|
418
+ return rcgen.call(ext)
382
419
  end
420
+
421
+ # When HOME and XDG_CONFIG_HOME are not available
422
+ nil
383
423
  end
384
424
 
385
- # enumerate possible rc-file base name generators
386
- def IRB.rc_file_generators
387
- if irbrc = ENV["IRBRC"]
388
- yield proc{|rc| rc == "rc" ? irbrc : irbrc+rc}
389
- end
390
- if xdg_config_home = ENV["XDG_CONFIG_HOME"]
391
- irb_home = File.join(xdg_config_home, "irb")
392
- if File.directory?(irb_home)
393
- yield proc{|rc| irb_home + "/irb#{rc}"}
394
- end
395
- end
396
- if home = ENV["HOME"]
397
- yield proc{|rc| home+"/.irb#{rc}"}
398
- yield proc{|rc| home+"/.config/irb/irb#{rc}"}
399
- end
400
- current_dir = Dir.pwd
401
- yield proc{|rc| current_dir+"/.irb#{rc}"}
402
- yield proc{|rc| current_dir+"/irb#{rc.sub(/\A_?/, '.')}"}
403
- yield proc{|rc| current_dir+"/_irb#{rc}"}
404
- yield proc{|rc| current_dir+"/$irb#{rc}"}
425
+ def IRB.irbrc_files
426
+ prepare_irbrc_name_generators
427
+ @irbrc_files
405
428
  end
406
429
 
407
430
  # loading modules
@@ -417,6 +440,50 @@ module IRB # :nodoc:
417
440
 
418
441
  class << IRB
419
442
  private
443
+
444
+ def prepare_irbrc_name_generators
445
+ return if @existing_rc_name_generators
446
+
447
+ @existing_rc_name_generators = []
448
+ @irbrc_files = []
449
+ rc_file_generators do |rcgen|
450
+ irbrc = rcgen.call(IRBRC_EXT)
451
+ if File.exist?(irbrc)
452
+ @irbrc_files << irbrc
453
+ @existing_rc_name_generators << rcgen
454
+ end
455
+ end
456
+ generate_current_dir_irbrc_files.each do |irbrc|
457
+ @irbrc_files << irbrc if File.exist?(irbrc)
458
+ end
459
+ @irbrc_files.uniq!
460
+ end
461
+
462
+ # enumerate possible rc-file base name generators
463
+ def rc_file_generators
464
+ if irbrc = ENV["IRBRC"]
465
+ yield proc{|rc| rc == "rc" ? irbrc : irbrc+rc}
466
+ end
467
+ if xdg_config_home = ENV["XDG_CONFIG_HOME"]
468
+ irb_home = File.join(xdg_config_home, "irb")
469
+ if File.directory?(irb_home)
470
+ yield proc{|rc| irb_home + "/irb#{rc}"}
471
+ end
472
+ end
473
+ if home = ENV["HOME"]
474
+ yield proc{|rc| home+"/.irb#{rc}"}
475
+ if xdg_config_home.nil? || xdg_config_home.empty?
476
+ yield proc{|rc| home+"/.config/irb/irb#{rc}"}
477
+ end
478
+ end
479
+ end
480
+
481
+ # possible irbrc files in current directory
482
+ def generate_current_dir_irbrc_files
483
+ current_dir = Dir.pwd
484
+ %w[.irbrc irbrc _irbrc $irbrc].map { |file| "#{current_dir}/#{file}" }
485
+ end
486
+
420
487
  def set_encoding(extern, intern = nil, override: true)
421
488
  verbose, $VERBOSE = $VERBOSE, nil
422
489
  Encoding.default_external = extern unless extern.nil? || extern.empty?
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #
3
3
  # irb/input-method.rb - input methods used irb
4
4
  # by Keiju ISHITSUKA(keiju@ruby-lang.org)
@@ -20,7 +20,7 @@ module IRB
20
20
  #
21
21
  # See IO#gets for more information.
22
22
  def gets
23
- fail NotImplementedError, "gets"
23
+ fail NotImplementedError
24
24
  end
25
25
  public :gets
26
26
 
@@ -44,6 +44,10 @@ module IRB
44
44
  false
45
45
  end
46
46
 
47
+ def prompting?
48
+ false
49
+ end
50
+
47
51
  # For debug message
48
52
  def inspect
49
53
  'Abstract InputMethod'
@@ -63,6 +67,7 @@ module IRB
63
67
  #
64
68
  # See IO#gets for more information.
65
69
  def gets
70
+ puts if @stdout.tty? # workaround for debug compatibility test
66
71
  print @prompt
67
72
  line = @stdin.gets
68
73
  @line[@line_no += 1] = line
@@ -91,6 +96,10 @@ module IRB
91
96
  true
92
97
  end
93
98
 
99
+ def prompting?
100
+ STDIN.tty?
101
+ end
102
+
94
103
  # Returns the current line number for #io.
95
104
  #
96
105
  # #line counts the number of times #gets is called.
@@ -193,6 +202,10 @@ module IRB
193
202
  }
194
203
  end
195
204
 
205
+ def completion_info
206
+ 'RegexpCompletor'
207
+ end
208
+
196
209
  # Reads the next line from this input method.
197
210
  #
198
211
  # See IO#gets for more information.
@@ -216,6 +229,10 @@ module IRB
216
229
  @eof
217
230
  end
218
231
 
232
+ def prompting?
233
+ true
234
+ end
235
+
219
236
  # For debug message
220
237
  def inspect
221
238
  readline_impl = (defined?(Reline) && Readline == Reline) ? 'Reline' : 'ext/readline'
@@ -230,13 +247,13 @@ module IRB
230
247
  HISTORY = Reline::HISTORY
231
248
  include HistorySavingAbility
232
249
  # Creates a new input method object using Reline
233
- def initialize
250
+ def initialize(completor)
234
251
  IRB.__send__(:set_encoding, Reline.encoding_system_needs.name, override: false)
235
252
 
236
- super
253
+ super()
237
254
 
238
255
  @eof = false
239
- @completor = RegexpCompletor.new
256
+ @completor = completor
240
257
 
241
258
  Reline.basic_word_break_characters = BASIC_WORD_BREAK_CHARACTERS
242
259
  Reline.completion_append_character = nil
@@ -270,6 +287,11 @@ module IRB
270
287
  end
271
288
  end
272
289
 
290
+ def completion_info
291
+ autocomplete_message = Reline.autocompletion ? 'Autocomplete' : 'Tab Complete'
292
+ "#{autocomplete_message}, #{@completor.inspect}"
293
+ end
294
+
273
295
  def check_termination(&block)
274
296
  @check_termination_proc = block
275
297
  end
@@ -282,11 +304,27 @@ module IRB
282
304
  @auto_indent_proc = block
283
305
  end
284
306
 
307
+ def retrieve_doc_namespace(matched)
308
+ preposing, _target, postposing, bind = @completion_params
309
+ @completor.doc_namespace(preposing, matched, postposing, bind: bind)
310
+ end
311
+
312
+ def rdoc_ri_driver
313
+ return @rdoc_ri_driver if defined?(@rdoc_ri_driver)
314
+
315
+ begin
316
+ require 'rdoc'
317
+ rescue LoadError
318
+ @rdoc_ri_driver = nil
319
+ else
320
+ options = {}
321
+ options[:extra_doc_dirs] = IRB.conf[:EXTRA_DOC_DIRS] unless IRB.conf[:EXTRA_DOC_DIRS].empty?
322
+ @rdoc_ri_driver = RDoc::RI::Driver.new(options)
323
+ end
324
+ end
325
+
285
326
  def show_doc_dialog_proc
286
- doc_namespace = ->(matched) {
287
- preposing, _target, postposing, bind = @completion_params
288
- @completor.doc_namespace(preposing, matched, postposing, bind: bind)
289
- }
327
+ input_method = self # self is changed in the lambda below.
290
328
  ->() {
291
329
  dialog.trap_key = nil
292
330
  alt_d = [
@@ -302,16 +340,22 @@ module IRB
302
340
  cursor_pos_to_render, result, pointer, autocomplete_dialog = context.pop(4)
303
341
  return nil if result.nil? or pointer.nil? or pointer < 0
304
342
 
305
- name = doc_namespace.call(result[pointer])
343
+ name = input_method.retrieve_doc_namespace(result[pointer])
344
+ # Use first one because document dialog does not support multiple namespaces.
345
+ name = name.first if name.is_a?(Array)
306
346
 
307
- options = {}
308
- options[:extra_doc_dirs] = IRB.conf[:EXTRA_DOC_DIRS] unless IRB.conf[:EXTRA_DOC_DIRS].empty?
309
- driver = RDoc::RI::Driver.new(options)
347
+ show_easter_egg = name&.match?(/\ARubyVM/) && !ENV['RUBY_YES_I_AM_NOT_A_NORMAL_USER']
348
+
349
+ driver = input_method.rdoc_ri_driver
310
350
 
311
351
  if key.match?(dialog.name)
312
- begin
313
- driver.display_names([name])
314
- rescue RDoc::RI::Driver::NotFoundError
352
+ if show_easter_egg
353
+ IRB.__send__(:easter_egg)
354
+ else
355
+ begin
356
+ driver.display_names([name])
357
+ rescue RDoc::RI::Driver::NotFoundError
358
+ end
315
359
  end
316
360
  end
317
361
 
@@ -374,8 +418,15 @@ module IRB
374
418
  formatter.width = width
375
419
  dialog.trap_key = alt_d
376
420
  mod_key = RUBY_PLATFORM.match?(/darwin/) ? "Option" : "Alt"
377
- message = "Press #{mod_key}+d to read the full document"
378
- contents = [message] + doc.accept(formatter).split("\n")
421
+ if show_easter_egg
422
+ type = STDOUT.external_encoding == Encoding::UTF_8 ? :unicode : :ascii
423
+ contents = IRB.send(:easter_egg_logo, type).split("\n")
424
+ message = "Press #{mod_key}+d to see more"
425
+ contents[0][0, message.size] = message
426
+ else
427
+ message = "Press #{mod_key}+d to read the full document"
428
+ contents = [message] + doc.accept(formatter).split("\n")
429
+ end
379
430
  contents = contents.take(preferred_dialog_height)
380
431
 
381
432
  y = cursor_pos_to_render.y
@@ -383,23 +434,18 @@ module IRB
383
434
  }
384
435
  end
385
436
 
386
- def display_document(matched, driver: nil)
387
- begin
388
- require 'rdoc'
389
- rescue LoadError
390
- return
391
- end
437
+ def display_document(matched)
438
+ driver = rdoc_ri_driver
439
+ return unless driver
392
440
 
393
441
  if matched =~ /\A(?:::)?RubyVM/ and not ENV['RUBY_YES_I_AM_NOT_A_NORMAL_USER']
394
442
  IRB.__send__(:easter_egg)
395
443
  return
396
444
  end
397
445
 
398
- _target, preposing, postposing, bind = @completion_params
399
- namespace = @completor.doc_namespace(preposing, matched, postposing, bind: bind)
446
+ namespace = retrieve_doc_namespace(matched)
400
447
  return unless namespace
401
448
 
402
- driver ||= RDoc::RI::Driver.new
403
449
  if namespace.is_a?(Array)
404
450
  out = RDoc::Markup::Document.new
405
451
  namespace.each do |m|
@@ -442,6 +488,10 @@ module IRB
442
488
  @eof
443
489
  end
444
490
 
491
+ def prompting?
492
+ true
493
+ end
494
+
445
495
  # For debug message
446
496
  def inspect
447
497
  config = Reline::Config.new
data/lib/irb/inspector.rb CHANGED
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #
3
3
  # irb/inspector.rb - inspect methods
4
4
  # by Keiju ISHITSUKA(keiju@ruby-lang.org)
@@ -46,7 +46,7 @@ module IRB # :nodoc:
46
46
  # Determines the inspector to use where +inspector+ is one of the keys passed
47
47
  # during inspector definition.
48
48
  def self.keys_with_inspector(inspector)
49
- INSPECTORS.select{|k,v| v == inspector}.collect{|k, v| k}
49
+ INSPECTORS.select{|k, v| v == inspector}.collect{|k, v| k}
50
50
  end
51
51
 
52
52
  # Example
@@ -113,7 +113,7 @@ module IRB # :nodoc:
113
113
  Color.colorize_code(v.inspect, colorable: Color.colorable? && Color.inspect_colorable?(v))
114
114
  }
115
115
  Inspector.def_inspector([true, :pp, :pretty_inspect], proc{require_relative "color_printer"}){|v|
116
- IRB::ColorPrinter.pp(v, '').chomp
116
+ IRB::ColorPrinter.pp(v, +'').chomp
117
117
  }
118
118
  Inspector.def_inspector([:yaml, :YAML], proc{require "yaml"}){|v|
119
119
  begin
data/lib/irb/lc/error.rb CHANGED
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #
3
3
  # irb/lc/error.rb -
4
4
  # by Keiju ISHITSUKA(keiju@ruby-lang.org)
@@ -12,11 +12,6 @@ module IRB
12
12
  super("Unrecognized switch: #{val}")
13
13
  end
14
14
  end
15
- class NotImplementedError < StandardError
16
- def initialize(val)
17
- super("Need to define `#{val}'")
18
- end
19
- end
20
15
  class CantReturnToNormalMode < StandardError
21
16
  def initialize
22
17
  super("Can't return to normal mode.")
@@ -52,11 +47,6 @@ module IRB
52
47
  super("Undefined prompt mode(#{val}).")
53
48
  end
54
49
  end
55
- class IllegalRCGenerator < StandardError
56
- def initialize
57
- super("Define illegal RC_NAME_GENERATOR.")
58
- end
59
- end
60
50
 
61
51
  # :startdoc:
62
52
  end
@@ -22,6 +22,7 @@ Usage: irb.rb [options] [programfile] [arguments]
22
22
  Show truncated result on assignment (default).
23
23
  --inspect Use 'inspect' for output.
24
24
  --noinspect Don't use 'inspect' for output.
25
+ --no-pager Don't use pager.
25
26
  --multiline Use multiline editor module (default).
26
27
  --nomultiline Don't use multiline editor module.
27
28
  --singleline Use single line editor module.
@@ -30,6 +31,9 @@ Usage: irb.rb [options] [programfile] [arguments]
30
31
  --nocolorize Don't use color-highlighting.
31
32
  --autocomplete Use auto-completion (default).
32
33
  --noautocomplete Don't use auto-completion.
34
+ --regexp-completor
35
+ Use regexp based completion (default).
36
+ --type-completor Use type based completion.
33
37
  --prompt prompt-mode, --prompt-mode prompt-mode
34
38
  Set prompt mode. Pre-defined prompt modes are:
35
39
  'default', 'classic', 'simple', 'inf-ruby', 'xmp', 'null'.
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #
3
3
  # irb/lc/ja/error.rb -
4
4
  # by Keiju ISHITSUKA(keiju@ruby-lang.org)
@@ -12,11 +12,6 @@ module IRB
12
12
  super("スイッチ(#{val})が分りません")
13
13
  end
14
14
  end
15
- class NotImplementedError < StandardError
16
- def initialize(val)
17
- super("`#{val}'の定義が必要です")
18
- end
19
- end
20
15
  class CantReturnToNormalMode < StandardError
21
16
  def initialize
22
17
  super("Normalモードに戻れません.")
@@ -52,11 +47,6 @@ module IRB
52
47
  super("プロンプトモード(#{val})は定義されていません.")
53
48
  end
54
49
  end
55
- class IllegalRCGenerator < StandardError
56
- def initialize
57
- super("RC_NAME_GENERATORが正しく定義されていません.")
58
- end
59
- end
60
50
 
61
51
  # :startdoc:
62
52
  end
@@ -9,10 +9,18 @@ Usage: irb.rb [options] [programfile] [arguments]
9
9
  -W[level=2] ruby -W と同じ.
10
10
  --context-mode n 新しいワークスペースを作成した時に関連する Binding
11
11
  オブジェクトの作成方法を 0 から 3 のいずれかに設定する.
12
+ --extra-doc-dir 指定したディレクトリのドキュメントを追加で読み込む.
12
13
  --echo 実行結果を表示する(デフォルト).
13
14
  --noecho 実行結果を表示しない.
15
+ --echo-on-assignment
16
+ 代入結果を表示する.
17
+ --noecho-on-assignment
18
+ 代入結果を表示しない.
19
+ --truncate-echo-on-assignment
20
+ truncateされた代入結果を表示する(デフォルト).
14
21
  --inspect 結果出力にinspectを用いる.
15
22
  --noinspect 結果出力にinspectを用いない.
23
+ --no-pager ページャを使用しない.
16
24
  --multiline マルチラインエディタを利用する.
17
25
  --nomultiline マルチラインエディタを利用しない.
18
26
  --singleline シングルラインエディタを利用する.
@@ -21,6 +29,9 @@ Usage: irb.rb [options] [programfile] [arguments]
21
29
  --nocolorize 色付けを利用しない.
22
30
  --autocomplete オートコンプリートを利用する.
23
31
  --noautocomplete オートコンプリートを利用しない.
32
+ --regexp-completor
33
+ 補完に正規表現を利用する.
34
+ --type-completor 補完に型情報を利用する.
24
35
  --prompt prompt-mode/--prompt-mode prompt-mode
25
36
  プロンプトモードを切替えます. 現在定義されているプ
26
37
  ロンプトモードは, default, simple, xmp, inf-rubyが
@@ -31,6 +42,8 @@ Usage: irb.rb [options] [programfile] [arguments]
31
42
  --sample-book-mode/--simple-prompt
32
43
  非常にシンプルなプロンプトを用いるモードです.
33
44
  --noprompt プロンプト表示を行なわない.
45
+ --script スクリプトモード(最初の引数をスクリプトファイルとして扱う、デフォルト)
46
+ --noscript 引数をargvとして扱う.
34
47
  --single-irb irb 中で self を実行して得られるオブジェクトをサ
35
48
  ブ irb と共有する.
36
49
  --tracer コマンド実行時にトレースを行なう.
data/lib/irb/locale.rb CHANGED
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #
3
3
  # irb/locale.rb - internationalization module
4
4
  # by Keiju ISHITSUKA(keiju@ruby-lang.org)
@@ -94,7 +94,7 @@ module IRB # :nodoc:
94
94
  end
95
95
  end
96
96
 
97
- def find(file , paths = $:)
97
+ def find(file, paths = $:)
98
98
  dir = File.dirname(file)
99
99
  dir = "" if dir == "."
100
100
  base = File.basename(file)
@@ -12,6 +12,8 @@ module IRB
12
12
  skip = false
13
13
  last_tok, state, args = opens.last
14
14
  case state
15
+ when :in_alias_undef
16
+ skip = t.event == :on_kw
15
17
  when :in_unquoted_symbol
16
18
  unless IGNORE_TOKENS.include?(t.event)
17
19
  opens.pop
@@ -61,17 +63,17 @@ module IRB
61
63
  if args.include?(:arg)
62
64
  case t.event
63
65
  when :on_nl, :on_semicolon
64
- # def recever.f;
66
+ # def receiver.f;
65
67
  body = :normal
66
68
  when :on_lparen
67
- # def recever.f()
69
+ # def receiver.f()
68
70
  next_args << :eq
69
71
  else
70
72
  if t.event == :on_op && t.tok == '='
71
73
  # def receiver.f =
72
74
  body = :oneliner
73
75
  else
74
- # def recever.f arg
76
+ # def receiver.f arg
75
77
  next_args << :arg_without_paren
76
78
  end
77
79
  end
@@ -130,6 +132,10 @@ module IRB
130
132
  opens.pop
131
133
  opens << [t, nil]
132
134
  end
135
+ when 'alias'
136
+ opens << [t, :in_alias_undef, 2]
137
+ when 'undef'
138
+ opens << [t, :in_alias_undef, 1]
133
139
  when 'elsif', 'else', 'when'
134
140
  opens.pop
135
141
  opens << [t, nil]
@@ -174,6 +180,10 @@ module IRB
174
180
  pending_heredocs.reverse_each { |t| opens << [t, nil] }
175
181
  pending_heredocs = []
176
182
  end
183
+ if opens.last && opens.last[1] == :in_alias_undef && !IGNORE_TOKENS.include?(t.event) && t.event != :on_heredoc_end
184
+ tok, state, arg = opens.pop
185
+ opens << [tok, state, arg - 1] if arg >= 1
186
+ end
177
187
  yield t, opens if block_given?
178
188
  end
179
189
  opens.map(&:first) + pending_heredocs.reverse
data/lib/irb/notifier.rb CHANGED
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #
3
3
  # notifier.rb - output methods used by irb
4
4
  # by Keiju ISHITSUKA(keiju@ruby-lang.org)