Skip to content
Permalink
Browse files

Mark default gems in `gem list -d`

  • Loading branch information...
drbrain committed Dec 19, 2012
1 parent 3fa3a7a commit e8a76fc457297c39492c298e194f595a0b6d78ba
Showing with 43 additions and 4 deletions.
  1. +5 −4 lib/rubygems/commands/query_command.rb
  2. +38 −0 test/rubygems/test_gem_commands_query_command.rb
@@ -255,13 +255,14 @@ def output_query_results(spec_tuples)

if spec.loaded_from then
if matching_tuples.length == 1 then
loaded_from = File.dirname File.dirname(spec.loaded_from)
entry << "\n" << " Installed at: #{loaded_from}"
default = spec.default_gem? ? ' (default)' : nil
entry << "\n" << " Installed at#{default}: #{spec.base_dir}"
else
label = 'Installed at'
matching_tuples.each do |n,s|
loaded_from = File.dirname File.dirname(s.loaded_from)
entry << "\n" << " #{label} (#{n.version}): #{loaded_from}"
version = n.version.to_s
version << ', default' if s.default_gem?
entry << "\n" << " #{label} (#{version}): #{s.base_dir}"
label = ' ' * label.length
end
end
@@ -400,5 +400,43 @@ def test_execute_local_details
assert_match expected, @ui.output
end

def test_execute_default_details
default_gem_dir = Gem::Specification.default_specifications_dir
@a1.loaded_from =
File.join default_gem_dir, @a1.spec_name

@cmd.handle_options %w[-l -d]

use_ui @ui do
@cmd.execute
end

str = @ui.output

expected = <<-EOF
*** LOCAL GEMS ***
a (3.a, 2, 1)
Author: A User
Homepage: http://example.com
Installed at (3.a): #{@gemhome}
(2): #{@gemhome}
(1, default): #{@a1.base_dir}
this is a summary
pl \(1\)
Platform: i386-linux
Author: A User
Homepage: http://example.com
Installed at: #{@gemhome}
this is a summary
EOF

assert_equal expected, @ui.output
end

end

0 comments on commit e8a76fc

Please sign in to comment.
You can’t perform that action at this time.