Skip to content
Browse files

fix editor option

  • Loading branch information...
1 parent d6701ad commit 76bee45a3004ec4ecd4e9ffc580b00345867c7fb @quozd quozd committed Feb 1, 2014
Showing with 11 additions and 8 deletions.
  1. +10 −7 lib/rubygems/commands/open_command.rb
  2. +1 −1 test/rubygems/test_gem_commands_open_command.rb
View
17 lib/rubygems/commands/open_command.rb
@@ -12,11 +12,7 @@ def initialize
add_option('-e', '--editor EDITOR', String,
"Opens gem sources in EDITOR") do |editor, options|
- options[:editor] = editor ||
- ENV['GEM_EDITOR'] ||
- ENV['VISUAL'] ||
- ENV['EDITOR'] ||
- 'vi'
+ options[:editor] = editor || get_env_editor
end
end
@@ -25,7 +21,7 @@ def arguments # :nodoc:
end
def defaults_str # :nodoc:
- "-e $EDITOR"
+ "-e #{get_env_editor}"
end
def description # :nodoc:
@@ -40,9 +36,16 @@ def usage # :nodoc:
"#{program_name} GEMNAME [-e EDITOR]"
end
+ def get_env_editor
+ ENV['GEM_EDITOR'] ||
+ ENV['VISUAL'] ||
+ ENV['EDITOR'] ||
+ 'vi'
+ end
+
def execute
@version = options[:version] || Gem::Requirement.default
- @editor = options[:editor]
+ @editor = options[:editor] || get_env_editor
found = open_gem(get_one_gem_name)
View
2 test/rubygems/test_gem_commands_open_command.rb
@@ -18,7 +18,7 @@ def gem name
end
def test_execute
- @cmd.options[:editor] = 'notepad'
+ # @cmd.options[:editor] = 'notepad'
@cmd.options[:args] = %w[foo]
gem 'foo'

0 comments on commit 76bee45

Please sign in to comment.
Something went wrong with that request. Please try again.