gem_directories_unique (FastRI::Util)

    # File lib/fastri/util.rb, line 49
      def gem_directories_unique
        return [] unless defined? Gem
        gemdirs = Gem.path.map{|p| Dir["#{p}/doc/*/ri"]}.flatten
        gems = Hash.new{|h,k| h[k] = []}
        gemdirs.each do |path|
          gemname, version = %r{/([^/]+)-([^-]*)/ri$}.match(path).captures
          if gemname.nil? # doesn't follow any conventions :(
            gems[path[%r{/([^/]+)/ri$}, 1]] << [nil, path]
          else
            gems[gemname] << [version, path]
          end
        end
        gems.sort_by{|name, _| name}.map do |name, versions|
          version, path = versions.sort.last
          [name, version, File.expand_path(path)]
        end
      end