Permalink
Browse files

fix indentation to 2 spaces

  • Loading branch information...
1 parent 0c9f972 commit bf2127ca0312c7974360f7b06c13f490ec867e3f @quozd quozd committed Feb 1, 2014
Showing with 78 additions and 78 deletions.
  1. +51 −51 lib/rubygems/commands/open_command.rb
  2. +27 −27 test/rubygems/test_gem_commands_open_command.rb
@@ -5,76 +5,76 @@
class Gem::Commands::OpenCommand < Gem::Command
- include Gem::VersionOption
+ include Gem::VersionOption
- def initialize
- super 'open', 'Open gem sources in editor'
+ def initialize
+ super 'open', 'Open gem sources in editor'
- add_option('-e', '--editor EDITOR', String,
- "Opens gem sources in EDITOR") do |editor, options|
- options[:editor] = editor || get_env_editor
- end
+ add_option('-e', '--editor EDITOR', String,
+ "Opens gem sources in EDITOR") do |editor, options|
+ options[:editor] = editor || get_env_editor
end
+ end
- def arguments # :nodoc:
- "GEMNAME name of gem to open in editor"
- end
+ def arguments # :nodoc:
+ "GEMNAME name of gem to open in editor"
+ end
- def defaults_str # :nodoc:
- "-e #{get_env_editor}"
- end
+ def defaults_str # :nodoc:
+ "-e #{get_env_editor}"
+ end
- def description # :nodoc:
- <<-EOF
+ def description # :nodoc:
+ <<-EOF
The open command opens gem in editor and changes current path
to gem's source directory. Editor can be specified, otherwise
$EDITOR would be invoked.
- EOF
- end
+ EOF
+ end
- def usage # :nodoc:
- "#{program_name} GEMNAME [-e EDITOR]"
- end
+ def usage # :nodoc:
+ "#{program_name} GEMNAME [-e EDITOR]"
+ end
- def get_env_editor
- ENV['GEM_EDITOR'] ||
- ENV['VISUAL'] ||
- ENV['EDITOR'] ||
- 'vi'
- 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] || get_env_editor
+ def execute
+ @version = options[:version] || Gem::Requirement.default
+ @editor = options[:editor] || get_env_editor
- found = open_gem(get_one_gem_name)
+ found = open_gem(get_one_gem_name)
- terminate_interaction 1 unless found
- end
+ terminate_interaction 1 unless found
+ end
- def open_gem name
- spec = spec_for name
- return false unless spec
+ def open_gem name
+ spec = spec_for name
+ return false unless spec
- open_editor(spec.full_gem_path)
- end
+ open_editor(spec.full_gem_path)
+ end
- def open_editor path
- Dir.chdir(path) do
- pid = spawn(@editor, path)
- Process.detach(pid)
- end
- #unless Gem::Util.silent_system(@editor, path)
- # say "Unable to open #{@editor}"
- # terminate_interaction 1
- #end
+ def open_editor path
+ Dir.chdir(path) do
+ pid = spawn(@editor, path)
+ Process.detach(pid)
end
+ #unless Gem::Util.silent_system(@editor, path)
+ # say "Unable to open #{@editor}"
+ # terminate_interaction 1
+ #end
+ end
- def spec_for name
- spec = Gem::Specification.find_all_by_name(name, @version).last
+ def spec_for name
+ spec = Gem::Specification.find_all_by_name(name, @version).last
- return spec if spec
+ return spec if spec
- say "Unable to find gem '#{name}'"
- end
+ say "Unable to find gem '#{name}'"
+ end
end
@@ -3,43 +3,43 @@
class TestGemCommandsOpenCommand < Gem::TestCase
- def setup
- super
+ def setup
+ super
- @cmd = Gem::Commands::OpenCommand.new
- end
+ @cmd = Gem::Commands::OpenCommand.new
+ end
- def gem name
- spec = quick_gem name do |gem|
- gem.files = %W[lib/#{name}.rb Rakefile]
- end
- write_file File.join(*%W[gems #{spec.full_name} lib #{name}.rb])
- write_file File.join(*%W[gems #{spec.full_name} Rakefile])
+ def gem name
+ spec = quick_gem name do |gem|
+ gem.files = %W[lib/#{name}.rb Rakefile]
end
+ write_file File.join(*%W[gems #{spec.full_name} lib #{name}.rb])
+ write_file File.join(*%W[gems #{spec.full_name} Rakefile])
+ end
- def test_execute
- @cmd.options[:args] = %w[foo]
-
- gem 'foo'
+ def test_execute
+ @cmd.options[:args] = %w[foo]
- use_ui @ui do
- @cmd.execute
- end
+ gem 'foo'
- assert_equal "", @ui.error
+ use_ui @ui do
+ @cmd.execute
end
- def test_execute_bad_gem
- @cmd.options[:args] = %w[foo]
+ assert_equal "", @ui.error
+ end
- assert_raises Gem::MockGemUi::TermError do
- use_ui @ui do
- @cmd.execute
- end
- end
+ def test_execute_bad_gem
+ @cmd.options[:args] = %w[foo]
- assert_match %r|Unable to find gem 'foo'|, @ui.output
- assert_equal "", @ui.error
+ assert_raises Gem::MockGemUi::TermError do
+ use_ui @ui do
+ @cmd.execute
+ end
end
+ assert_match %r|Unable to find gem 'foo'|, @ui.output
+ assert_equal "", @ui.error
+ end
+
end

0 comments on commit bf2127c

Please sign in to comment.