irb 1.6.2 → 1.6.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,13 +1,8 @@
1
1
  # frozen_string_literal: false
2
+ #
2
3
  # save-history.rb -
3
- # $Release Version: 0.9.6$
4
- # $Revision$
5
4
  # by Keiju ISHITSUKA(keiju@ruby-lang.org)
6
5
  #
7
- # --
8
- #
9
- #
10
- #
11
6
 
12
7
  module IRB
13
8
  module HistorySavingAbility # :nodoc:
@@ -1,20 +1,14 @@
1
1
  # frozen_string_literal: false
2
2
  #
3
3
  # irb/lib/tracer.rb -
4
- # $Release Version: 0.9.6$
5
- # $Revision$
6
4
  # by Keiju ISHITSUKA(keiju@ruby-lang.org)
7
5
  #
8
- # --
9
- #
10
- #
11
- #
6
+
12
7
  begin
13
8
  require "tracer"
14
9
  rescue LoadError
15
10
  $stderr.puts "Tracer extension of IRB is enabled but tracer gem doesn't found."
16
11
  module IRB
17
- TracerLoadError = true
18
12
  class Context
19
13
  def use_tracer=(opt)
20
14
  # do nothing
@@ -70,12 +64,12 @@ module IRB
70
64
  if context.use_tracer? && file != nil && line != nil
71
65
  Tracer.on
72
66
  begin
73
- __evaluate__(context, statements, file, line)
67
+ __evaluate__(statements, file, line)
74
68
  ensure
75
69
  Tracer.off
76
70
  end
77
71
  else
78
- __evaluate__(context, statements, file || __FILE__, line || __LINE__)
72
+ __evaluate__(statements, file || __FILE__, line || __LINE__)
79
73
  end
80
74
  end
81
75
  end
@@ -1,14 +1,8 @@
1
1
  # frozen_string_literal: false
2
2
  #
3
3
  # use-loader.rb -
4
- # $Release Version: 0.9.6$
5
- # $Revision$
6
4
  # by Keiju ISHITSUKA(keiju@ruby-lang.org)
7
5
  #
8
- # --
9
- #
10
- #
11
- #
12
6
 
13
7
  require_relative "../cmd/load"
14
8
  require_relative "loader"
@@ -1,14 +1,8 @@
1
1
  # frozen_string_literal: false
2
2
  #
3
3
  # push-ws.rb -
4
- # $Release Version: 0.9.6$
5
- # $Revision$
6
4
  # by Keiju ISHITSUKA(keiju@ruby-lang.org)
7
5
  #
8
- # --
9
- #
10
- #
11
- #
12
6
 
13
7
  module IRB # :nodoc:
14
8
  class Context
@@ -1,14 +1,9 @@
1
1
  # frozen_string_literal: false
2
2
  #
3
3
  # irb/extend-command.rb - irb extend command
4
- # $Release Version: 0.9.6$
5
- # $Revision$
6
4
  # by Keiju ISHITSUKA(keiju@ruby-lang.org)
7
5
  #
8
- # --
9
- #
10
- #
11
- #
6
+
12
7
  module IRB # :nodoc:
13
8
  # Installs the default irb extensions command bundle.
14
9
  module ExtendCommandBundle
@@ -251,7 +246,7 @@ module IRB # :nodoc:
251
246
  #
252
247
  # The optional +load_file+ parameter will be required within the method
253
248
  # definition.
254
- def self.def_extend_command(cmd_name, cmd_class, load_file = nil, *aliases)
249
+ def self.def_extend_command(cmd_name, cmd_class, load_file, *aliases)
255
250
  case cmd_class
256
251
  when Symbol
257
252
  cmd_class = cmd_class.id2name
@@ -260,34 +255,12 @@ module IRB # :nodoc:
260
255
  cmd_class = cmd_class.name
261
256
  end
262
257
 
263
- if load_file
264
- kwargs = ", **kwargs" if RUBY_ENGINE == "ruby" && RUBY_VERSION >= "2.7.0"
265
- line = __LINE__; eval %[
266
- def #{cmd_name}(*opts#{kwargs}, &b)
267
- require_relative "#{load_file}"
268
- arity = ExtendCommand::#{cmd_class}.instance_method(:execute).arity
269
- args = (1..(arity < 0 ? ~arity : arity)).map {|i| "arg" + i.to_s }
270
- args << "*opts#{kwargs}" if arity < 0
271
- args << "&block"
272
- args = args.join(", ")
273
- line = __LINE__; eval %[
274
- unless singleton_class.class_variable_defined?(:@@#{cmd_name}_)
275
- singleton_class.class_variable_set(:@@#{cmd_name}_, true)
276
- def self.#{cmd_name}_(\#{args})
277
- ExtendCommand::#{cmd_class}.execute(irb_context, \#{args})
278
- end
279
- end
280
- ], nil, __FILE__, line
281
- __send__ :#{cmd_name}_, *opts#{kwargs}, &b
282
- end
283
- ], nil, __FILE__, line
284
- else
285
- line = __LINE__; eval %[
286
- def #{cmd_name}(*opts, &b)
287
- ExtendCommand::#{cmd_class}.execute(irb_context, *opts, &b)
288
- end
289
- ], nil, __FILE__, line
290
- end
258
+ line = __LINE__; eval %[
259
+ def #{cmd_name}(*opts, **kwargs, &b)
260
+ Kernel.require_relative "#{load_file}"
261
+ ::IRB::ExtendCommand::#{cmd_class}.execute(irb_context, *opts, **kwargs, &b)
262
+ end
263
+ ], nil, __FILE__, line
291
264
 
292
265
  for ali, flag in aliases
293
266
  @ALIASES.push [ali, cmd_name, flag]
@@ -376,58 +349,4 @@ module IRB # :nodoc:
376
349
 
377
350
  CE.install_extend_commands
378
351
  end
379
-
380
- # A convenience module for extending Ruby methods.
381
- module MethodExtender
382
- # Extends the given +base_method+ with a prefix call to the given
383
- # +extend_method+.
384
- def def_pre_proc(base_method, extend_method)
385
- base_method = base_method.to_s
386
- extend_method = extend_method.to_s
387
-
388
- alias_name = new_alias_name(base_method)
389
- module_eval %[
390
- alias_method alias_name, base_method
391
- def #{base_method}(*opts)
392
- __send__ :#{extend_method}, *opts
393
- __send__ :#{alias_name}, *opts
394
- end
395
- ]
396
- end
397
-
398
- # Extends the given +base_method+ with a postfix call to the given
399
- # +extend_method+.
400
- def def_post_proc(base_method, extend_method)
401
- base_method = base_method.to_s
402
- extend_method = extend_method.to_s
403
-
404
- alias_name = new_alias_name(base_method)
405
- module_eval %[
406
- alias_method alias_name, base_method
407
- def #{base_method}(*opts)
408
- __send__ :#{alias_name}, *opts
409
- __send__ :#{extend_method}, *opts
410
- end
411
- ]
412
- end
413
-
414
- # Returns a unique method name to use as an alias for the given +name+.
415
- #
416
- # Usually returns <code>#{prefix}#{name}#{postfix}<num></code>, example:
417
- #
418
- # new_alias_name('foo') #=> __alias_of__foo__
419
- # def bar; end
420
- # new_alias_name('bar') #=> __alias_of__bar__2
421
- def new_alias_name(name, prefix = "__alias_of__", postfix = "__")
422
- base_name = "#{prefix}#{name}#{postfix}"
423
- all_methods = instance_methods(true) + private_instance_methods(true)
424
- same_methods = all_methods.grep(/^#{Regexp.quote(base_name)}[0-9]*$/)
425
- return base_name if same_methods.empty?
426
- no = same_methods.size
427
- while !same_methods.include?(alias_name = base_name + no)
428
- no += 1
429
- end
430
- alias_name
431
- end
432
- end
433
352
  end
data/lib/irb/frame.rb CHANGED
@@ -1,14 +1,8 @@
1
1
  # frozen_string_literal: false
2
2
  #
3
3
  # frame.rb -
4
- # $Release Version: 0.9$
5
- # $Revision$
6
4
  # by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
7
5
  #
8
- # --
9
- #
10
- #
11
- #
12
6
 
13
7
  module IRB
14
8
  class Frame
data/lib/irb/help.rb CHANGED
@@ -1,14 +1,8 @@
1
1
  # frozen_string_literal: false
2
2
  #
3
3
  # irb/help.rb - print usage module
4
- # $Release Version: 0.9.6$
5
- # $Revision$
6
4
  # by Keiju ISHITSUKA(keiju@ishitsuka.com)
7
5
  #
8
- # --
9
- #
10
- #
11
- #
12
6
 
13
7
  require_relative 'magic-file'
14
8
 
data/lib/irb/init.rb CHANGED
@@ -1,14 +1,8 @@
1
1
  # frozen_string_literal: false
2
2
  #
3
3
  # irb/init.rb - irb initialize module
4
- # $Release Version: 0.9.6$
5
- # $Revision$
6
4
  # by Keiju ISHITSUKA(keiju@ruby-lang.org)
7
5
  #
8
- # --
9
- #
10
- #
11
- #
12
6
 
13
7
  module IRB # :nodoc:
14
8
 
@@ -407,9 +401,9 @@ module IRB # :nodoc:
407
401
  end
408
402
  if home = ENV["HOME"]
409
403
  yield proc{|rc| home+"/.irb#{rc}"}
404
+ yield proc{|rc| home+"/.config/irb/irb#{rc}"}
410
405
  end
411
406
  current_dir = Dir.pwd
412
- yield proc{|rc| current_dir+"/.config/irb/irb#{rc}"}
413
407
  yield proc{|rc| current_dir+"/.irb#{rc}"}
414
408
  yield proc{|rc| current_dir+"/irb#{rc.sub(/\A_?/, '.')}"}
415
409
  yield proc{|rc| current_dir+"/_irb#{rc}"}
@@ -427,8 +421,6 @@ module IRB # :nodoc:
427
421
  end
428
422
  end
429
423
 
430
-
431
- DefaultEncodings = Struct.new(:external, :internal)
432
424
  class << IRB
433
425
  private
434
426
  def set_encoding(extern, intern = nil, override: true)
@@ -1,14 +1,9 @@
1
1
  # frozen_string_literal: false
2
2
  #
3
3
  # irb/input-method.rb - input methods used irb
4
- # $Release Version: 0.9.6$
5
- # $Revision$
6
4
  # by Keiju ISHITSUKA(keiju@ruby-lang.org)
7
5
  #
8
- # --
9
- #
10
- #
11
- #
6
+
12
7
  require_relative 'src_encoding'
13
8
  require_relative 'magic-file'
14
9
  require_relative 'completion'
data/lib/irb/inspector.rb CHANGED
@@ -1,15 +1,8 @@
1
1
  # frozen_string_literal: false
2
2
  #
3
3
  # irb/inspector.rb - inspect methods
4
- # $Release Version: 0.9.6$
5
- # $Revision: 1.19 $
6
- # $Date: 2002/06/11 07:51:31 $
7
4
  # by Keiju ISHITSUKA(keiju@ruby-lang.org)
8
5
  #
9
- # --
10
- #
11
- #
12
- #
13
6
 
14
7
  module IRB # :nodoc:
15
8
 
@@ -42,6 +35,7 @@ module IRB # :nodoc:
42
35
  # irb(main):001:0> "what?" #=> omg! what?
43
36
  #
44
37
  class Inspector
38
+ KERNEL_INSPECT = Object.instance_method(:inspect)
45
39
  # Default inspectors available to irb, this includes:
46
40
  #
47
41
  # +:pp+:: Using Kernel#pretty_inspect
@@ -100,9 +94,17 @@ module IRB # :nodoc:
100
94
  # Proc to call when the input is evaluated and output in irb.
101
95
  def inspect_value(v)
102
96
  @inspect.call(v)
103
- rescue
104
- puts "(Object doesn't support #inspect)"
105
- ''
97
+ rescue => e
98
+ puts "An error occurred when inspecting the object: #{e.inspect}"
99
+
100
+ begin
101
+ puts "Result of Kernel#inspect: #{KERNEL_INSPECT.bind_call(v)}"
102
+ ''
103
+ rescue => e
104
+ puts "An error occurred when running Kernel#inspect: #{e.inspect}"
105
+ puts e.backtrace.join("\n")
106
+ ''
107
+ end
106
108
  end
107
109
  end
108
110
 
data/lib/irb/lc/error.rb CHANGED
@@ -1,14 +1,8 @@
1
1
  # frozen_string_literal: false
2
2
  #
3
3
  # irb/lc/error.rb -
4
- # $Release Version: 0.9.6$
5
- # $Revision$
6
4
  # by Keiju ISHITSUKA(keiju@ruby-lang.org)
7
5
  #
8
- # --
9
- #
10
- #
11
- #
12
6
 
13
7
  module IRB
14
8
  # :stopdoc:
@@ -22,8 +22,8 @@ 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
- --multiline Use multiline editor module.
26
- --nomultiline Don't use multiline editor module (default).
25
+ --multiline Use multiline editor module (default).
26
+ --nomultiline Don't use multiline editor module.
27
27
  --singleline Use single line editor module.
28
28
  --nosingleline Don't use single line editor module (default).
29
29
  --colorize Use color-highlighting (default).
@@ -1,14 +1,8 @@
1
- # -*- coding: utf-8 -*-
2
1
  # frozen_string_literal: false
2
+ #
3
3
  # irb/lc/ja/error.rb -
4
- # $Release Version: 0.9.6$
5
- # $Revision$
6
4
  # by Keiju ISHITSUKA(keiju@ruby-lang.org)
7
5
  #
8
- # --
9
- #
10
- #
11
- #
12
6
 
13
7
  module IRB
14
8
  # :stopdoc:
data/lib/irb/locale.rb CHANGED
@@ -1,14 +1,9 @@
1
1
  # frozen_string_literal: false
2
2
  #
3
3
  # irb/locale.rb - internationalization module
4
- # $Release Version: 0.9.6$
5
- # $Revision$
6
4
  # by Keiju ISHITSUKA(keiju@ruby-lang.org)
7
5
  #
8
- # --
9
- #
10
- #
11
- #
6
+
12
7
  module IRB # :nodoc:
13
8
  class Locale
14
9
 
data/lib/irb/notifier.rb CHANGED
@@ -1,14 +1,8 @@
1
1
  # frozen_string_literal: false
2
2
  #
3
3
  # notifier.rb - output methods used by irb
4
- # $Release Version: 0.9.6$
5
- # $Revision$
6
4
  # by Keiju ISHITSUKA(keiju@ruby-lang.org)
7
5
  #
8
- # --
9
- #
10
- #
11
- #
12
6
 
13
7
  require_relative "output-method"
14
8
 
@@ -1,14 +1,8 @@
1
1
  # frozen_string_literal: false
2
2
  #
3
3
  # output-method.rb - output methods used by irb
4
- # $Release Version: 0.9.6$
5
- # $Revision$
6
4
  # by Keiju ISHITSUKA(keiju@ruby-lang.org)
7
5
  #
8
- # --
9
- #
10
- #
11
- #
12
6
 
13
7
  module IRB
14
8
  # An abstract output class for IO in irb. This is mainly used internally by