def show_gems name, prerelease
req = Gem::Requirement.default
dep = Gem::Deprecate.skip_during { Gem::Dependency.new name, req }
dep.prerelease = prerelease
if local? then
if prerelease and not both? then
alert_warning "prereleases are always shown locally"
end
display_header 'LOCAL'
specs = Gem::Specification.find_all { |s|
s.name =~ name and req =~ s.version
}
spec_tuples = specs.map do |spec|
[spec.name_tuple, spec]
end
output_query_results spec_tuples
end
if remote? then
display_header 'REMOTE'
fetcher = Gem::SpecFetcher.fetcher
type = if options[:all]
if options[:prerelease]
:complete
else
:released
end
elsif options[:prerelease]
:prerelease
else
:latest
end
if name.respond_to?(:source) && name.source.empty?
spec_tuples = fetcher.detect(type) { true }
else
spec_tuples = fetcher.detect(type) do |name_tuple|
name === name_tuple.name
end
end
output_query_results spec_tuples
end
end