irb 1.6.2 → 1.6.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +13 -10
- data/README.md +56 -16
- data/exe/irb +0 -2
- data/irb.gemspec +6 -1
- data/lib/irb/cmd/chws.rb +0 -6
- data/lib/irb/cmd/fork.rb +0 -6
- data/lib/irb/cmd/help.rb +0 -6
- data/lib/irb/cmd/load.rb +0 -6
- data/lib/irb/cmd/ls.rb +20 -7
- data/lib/irb/cmd/nop.rb +6 -20
- data/lib/irb/cmd/pushws.rb +0 -6
- data/lib/irb/cmd/show_source.rb +4 -4
- data/lib/irb/cmd/subirb.rb +1 -6
- data/lib/irb/color.rb +4 -10
- data/lib/irb/color_printer.rb +6 -1
- data/lib/irb/completion.rb +9 -48
- data/lib/irb/context.rb +2 -7
- data/lib/irb/ext/change-ws.rb +0 -6
- data/lib/irb/ext/history.rb +2 -8
- data/lib/irb/ext/loader.rb +1 -31
- data/lib/irb/ext/multi-irb.rb +0 -6
- data/lib/irb/ext/save-history.rb +1 -6
- data/lib/irb/ext/tracer.rb +3 -9
- data/lib/irb/ext/use-loader.rb +0 -6
- data/lib/irb/ext/workspaces.rb +0 -6
- data/lib/irb/extend-command.rb +8 -89
- data/lib/irb/frame.rb +0 -6
- data/lib/irb/help.rb +0 -6
- data/lib/irb/init.rb +1 -9
- data/lib/irb/input-method.rb +1 -6
- data/lib/irb/inspector.rb +12 -10
- data/lib/irb/lc/error.rb +0 -6
- data/lib/irb/lc/help-message +2 -2
- data/lib/irb/lc/ja/error.rb +1 -7
- data/lib/irb/locale.rb +1 -6
- data/lib/irb/notifier.rb +0 -6
- data/lib/irb/output-method.rb +0 -6
- data/lib/irb/ruby-lex.rb +45 -64
- data/lib/irb/version.rb +2 -8
- data/lib/irb/workspace.rb +4 -15
- data/lib/irb/ws-for-case-2.rb +0 -6
- data/lib/irb/xmp.rb +0 -6
- data/lib/irb.rb +20 -23
- metadata +9 -5
data/lib/irb/ext/save-history.rb
CHANGED
data/lib/irb/ext/tracer.rb
CHANGED
@@ -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__(
|
67
|
+
__evaluate__(statements, file, line)
|
74
68
|
ensure
|
75
69
|
Tracer.off
|
76
70
|
end
|
77
71
|
else
|
78
|
-
__evaluate__(
|
72
|
+
__evaluate__(statements, file || __FILE__, line || __LINE__)
|
79
73
|
end
|
80
74
|
end
|
81
75
|
end
|
data/lib/irb/ext/use-loader.rb
CHANGED
data/lib/irb/ext/workspaces.rb
CHANGED
data/lib/irb/extend-command.rb
CHANGED
@@ -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
|
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
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
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
data/lib/irb/help.rb
CHANGED
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)
|
data/lib/irb/input-method.rb
CHANGED
@@ -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 "
|
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
data/lib/irb/lc/help-message
CHANGED
@@ -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
|
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).
|
data/lib/irb/lc/ja/error.rb
CHANGED
data/lib/irb/locale.rb
CHANGED
data/lib/irb/notifier.rb
CHANGED
data/lib/irb/output-method.rb
CHANGED
@@ -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
|