def show_rdoc_for_pattern(pattern, res)
found_gems = Dir.glob("#{@gem_dir}/doc/#{pattern}").select {|path|
File.exist? File.join(path, 'rdoc/index.html')
}
case found_gems.length
when 0
return false
when 1
new_path = File.basename(found_gems[0])
res.status = 302
res['Location'] = "/doc_root/#{new_path}/rdoc/index.html"
return true
else
doc_items = []
found_gems.each do |file_name|
base_name = File.basename(file_name)
doc_items << {
:name => base_name,
:url => "/doc_root/#{base_name}/rdoc/index.html",
:summary => ''
}
end
template = ERB.new(RDOC_SEARCH_TEMPLATE)
res['content-type'] = 'text/html'
result = template.result binding
res.body = result
return true
end
end