Skip to content

Commit 7de0234

Browse files
st0012Morriar
andauthored
Remove dead code (#554)
* Remove unused ATTR_TTY and ATTR_PLAIN constants They were added in d7d26b5 But the references were removed in 1c76845 Co-authored-by: Alexandre Terrasa <alexandre.terrasa@shopify.com> * Remove unused MethodExtender module It was added in 6cc5d71 but it's not used anywhere. Co-authored-by: Alexandre Terrasa <alexandre.terrasa@shopify.com> * Remove unused IRB.irb_at_exit It's not used after aaf4eb4 Co-authored-by: Alexandre Terrasa <alexandre.terrasa@shopify.com> * Remove unused InputCompletor.ignored_modules It was added in 88311ce but the reference was removed in 78c74d2 * Remove unused TracerLoadError constant This constant was added in cb50fa3 but never referenced. --------- Co-authored-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
1 parent 2517039 commit 7de0234

4 files changed

Lines changed: 0 additions & 90 deletions

File tree

lib/irb.rb

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -416,11 +416,6 @@ def IRB.start(ap_path = nil)
416416
irb.run(@CONF)
417417
end
418418

419-
# Calls each event hook of <code>IRB.conf[:AT_EXIT]</code> when the current session quits.
420-
def IRB.irb_at_exit
421-
@CONF[:AT_EXIT].each{|hook| hook.call}
422-
end
423-
424419
# Quits irb
425420
def IRB.irb_exit(irb, ret)
426421
throw :IRB_EXIT, ret
@@ -897,11 +892,6 @@ def assignment_expression?(line)
897892
ensure
898893
$VERBOSE = verbose
899894
end
900-
901-
ATTR_TTY = "\e[%sm"
902-
def ATTR_TTY.[](*a) self % a.join(";"); end
903-
ATTR_PLAIN = ""
904-
def ATTR_PLAIN.[](*) self; end
905895
end
906896

907897
def @CONF.inspect

lib/irb/completion.rb

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -450,30 +450,5 @@ def self.select_message(receiver, message, candidates, sep = ".")
450450
end
451451
end
452452
end
453-
454-
def self.ignored_modules
455-
# We could cache the result, but this is very fast already.
456-
# By using this approach, we avoid Module#name calls, which are
457-
# relatively slow when there are a lot of anonymous modules defined.
458-
s = {}
459-
460-
scanner = lambda do |m|
461-
next if s.include?(m) # IRB::ExtendCommandBundle::EXCB recurses.
462-
s[m] = true
463-
m.constants(false).each do |c|
464-
value = m.const_get(c)
465-
scanner.call(value) if value.is_a?(Module)
466-
end
467-
end
468-
469-
%i(IRB RubyLex).each do |sym|
470-
next unless Object.const_defined?(sym)
471-
scanner.call(Object.const_get(sym))
472-
end
473-
474-
s.delete(IRB::Context) if defined?(IRB::Context)
475-
476-
s
477-
end
478453
end
479454
end

lib/irb/ext/tracer.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
rescue LoadError
1010
$stderr.puts "Tracer extension of IRB is enabled but tracer gem doesn't found."
1111
module IRB
12-
TracerLoadError = true
1312
class Context
1413
def use_tracer=(opt)
1514
# do nothing

lib/irb/extend-command.rb

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -371,58 +371,4 @@ def #{cmd_name}(*opts, &b)
371371

372372
CE.install_extend_commands
373373
end
374-
375-
# A convenience module for extending Ruby methods.
376-
module MethodExtender
377-
# Extends the given +base_method+ with a prefix call to the given
378-
# +extend_method+.
379-
def def_pre_proc(base_method, extend_method)
380-
base_method = base_method.to_s
381-
extend_method = extend_method.to_s
382-
383-
alias_name = new_alias_name(base_method)
384-
module_eval %[
385-
alias_method alias_name, base_method
386-
def #{base_method}(*opts)
387-
__send__ :#{extend_method}, *opts
388-
__send__ :#{alias_name}, *opts
389-
end
390-
]
391-
end
392-
393-
# Extends the given +base_method+ with a postfix call to the given
394-
# +extend_method+.
395-
def def_post_proc(base_method, extend_method)
396-
base_method = base_method.to_s
397-
extend_method = extend_method.to_s
398-
399-
alias_name = new_alias_name(base_method)
400-
module_eval %[
401-
alias_method alias_name, base_method
402-
def #{base_method}(*opts)
403-
__send__ :#{alias_name}, *opts
404-
__send__ :#{extend_method}, *opts
405-
end
406-
]
407-
end
408-
409-
# Returns a unique method name to use as an alias for the given +name+.
410-
#
411-
# Usually returns <code>#{prefix}#{name}#{postfix}<num></code>, example:
412-
#
413-
# new_alias_name('foo') #=> __alias_of__foo__
414-
# def bar; end
415-
# new_alias_name('bar') #=> __alias_of__bar__2
416-
def new_alias_name(name, prefix = "__alias_of__", postfix = "__")
417-
base_name = "#{prefix}#{name}#{postfix}"
418-
all_methods = instance_methods(true) + private_instance_methods(true)
419-
same_methods = all_methods.grep(/^#{Regexp.quote(base_name)}[0-9]*$/)
420-
return base_name if same_methods.empty?
421-
no = same_methods.size
422-
while !same_methods.include?(alias_name = base_name + no)
423-
no += 1
424-
end
425-
alias_name
426-
end
427-
end
428374
end

0 commit comments

Comments
 (0)