summaryrefslogtreecommitdiff
path: root/lib/rubygems/commands/open_command.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rubygems/commands/open_command.rb')
-rw-r--r--lib/rubygems/commands/open_command.rb23
1 files changed, 11 insertions, 12 deletions
diff --git a/lib/rubygems/commands/open_command.rb b/lib/rubygems/commands/open_command.rb
index 1e616fd68f..0fe90dc8b8 100644
--- a/lib/rubygems/commands/open_command.rb
+++ b/lib/rubygems/commands/open_command.rb
@@ -1,18 +1,19 @@
# frozen_string_literal: true
-require_relative '../command'
-require_relative '../version_option'
+
+require_relative "../command"
+require_relative "../version_option"
class Gem::Commands::OpenCommand < Gem::Command
include Gem::VersionOption
def initialize
- super 'open', 'Open gem sources in editor'
+ super "open", "Open gem sources in editor"
- add_option('-e', '--editor COMMAND', String,
+ add_option("-e", "--editor COMMAND", String,
"Prepends COMMAND to gem path. Could be used to specify editor.") do |command, options|
options[:editor] = command || get_env_editor
end
- add_option('-v', '--version VERSION', String,
+ add_option("-v", "--version VERSION", String,
"Opens specific gem version") do |version|
options[:version] = version
end
@@ -40,10 +41,10 @@ class Gem::Commands::OpenCommand < Gem::Command
end
def get_env_editor
- ENV['GEM_EDITOR'] ||
- ENV['VISUAL'] ||
- ENV['EDITOR'] ||
- 'vi'
+ ENV["GEM_EDITOR"] ||
+ ENV["VISUAL"] ||
+ ENV["EDITOR"] ||
+ "vi"
end
def execute
@@ -69,9 +70,7 @@ class Gem::Commands::OpenCommand < Gem::Command
end
def open_editor(path)
- Dir.chdir(path) do
- system(*@editor.split(/\s+/) + [path])
- end
+ system(*@editor.split(/\s+/) + [path], { chdir: path })
end
def spec_for(name)