2012-11-14 00:17:30 -08:00
|
|
|
class Pry
|
2012-12-25 23:35:17 +02:00
|
|
|
class Command::GemOpen < Pry::ClassCommand
|
|
|
|
match 'gem-open'
|
2012-11-14 00:17:30 -08:00
|
|
|
group 'Gems'
|
2012-12-25 23:35:17 +02:00
|
|
|
description 'Opens the working directory of the gem in your editor'
|
2012-11-14 00:17:30 -08:00
|
|
|
command_options :argument_required => true
|
|
|
|
|
|
|
|
banner <<-BANNER
|
|
|
|
Usage: gem-open GEM_NAME
|
|
|
|
|
|
|
|
Change the current working directory to that in which the given gem is installed,
|
|
|
|
and then opens your text editor.
|
|
|
|
BANNER
|
|
|
|
|
|
|
|
def process(gem)
|
2012-11-14 00:35:12 -08:00
|
|
|
Dir.chdir(gem_spec(gem).full_gem_path) do
|
2012-12-29 23:34:59 +01:00
|
|
|
Pry::Editor.invoke_editor(".", 0, false)
|
2012-11-14 00:17:30 -08:00
|
|
|
end
|
|
|
|
end
|
2012-11-14 01:50:27 -08:00
|
|
|
|
|
|
|
def complete(str)
|
|
|
|
gem_complete(str)
|
|
|
|
end
|
2012-11-14 00:17:30 -08:00
|
|
|
end
|
2012-12-25 23:35:17 +02:00
|
|
|
|
|
|
|
Pry::Commands.add_command(Pry::Command::GemOpen)
|
2012-11-14 00:17:30 -08:00
|
|
|
end
|