require 'uri' module URI # # Returns the +basename+ of the specified _uri_, unless the +basename+ is # +'trunk'+ then the +basename+ of the parent directory within the _uri_ # is returned. # # URI.repo_name('http://www.today.com/is/now') # => "now" # # URI.repo_name('svn://svn.repo.com/var/svn/awesome/trunk') # => # "awesome" # def URI.repo_name(uri) uri = URI.parse(uri) name = File.basename(uri.path) if name.empty? || name==File::SEPARATOR name = uri.host elsif name=='trunk' name = File.basename(File.dirname(uri.path)) end return name end end