lib/irb/command/show_source.rb in irb-1.12.0 vs lib/irb/command/show_source.rb in irb-1.13.0

- old
+ new

@@ -5,10 +5,12 @@ require_relative "../color" module IRB module Command class ShowSource < Base + include RubyArgsExtractor + category "Context" description "Show the source code of a given method, class/module, or constant." help_message <<~HELP_MESSAGE Usage: show_source [target] [-s] @@ -22,21 +24,12 @@ show_source Foo#bar -s show_source Foo.baz show_source Foo::BAR HELP_MESSAGE - class << self - def transform_args(args) - # Return a string literal as is for backward compatibility - if args.empty? || string_literal?(args) - args - else # Otherwise, consider the input as a String for convenience - args.strip.dump - end - end - end - - def execute(str = nil) + def execute(arg) + # Accept string literal for backward compatibility + str = unwrap_string_literal(arg) unless str.is_a?(String) puts "Error: Expected a string but got #{str.inspect}" return end