lib/irb/command/edit.rb in irb-1.12.0 vs lib/irb/command/edit.rb in irb-1.13.0
- old
+ new
@@ -1,14 +1,17 @@
require 'shellwords'
+require_relative "../color"
require_relative "../source_finder"
module IRB
# :stopdoc:
module Command
class Edit < Base
+ include RubyArgsExtractor
+
category "Misc"
description 'Open a file or source location.'
help_message <<~HELP_MESSAGE
Usage: edit [FILE or constant or method signature]
@@ -24,22 +27,12 @@
edit foo.rb
edit Foo
edit Foo#bar
HELP_MESSAGE
- class << self
- def transform_args(args)
- # Return a string literal as is for backward compatibility
- if args.nil? || args.empty? || string_literal?(args)
- args
- else # Otherwise, consider the input as a String for convenience
- args.strip.dump
- end
- end
- end
-
- def execute(*args)
- path = args.first
+ def execute(arg)
+ # Accept string literal for backward compatibility
+ path = unwrap_string_literal(arg)
if path.nil?
path = @irb_context.irb_path
elsif !File.exist?(path)
source = SourceFinder.new(@irb_context).find_source(path)