Sha256: e0a81d93016adb79fee014e76ff5b403b4f911e99779ace183b93b56a9c73be8

Contents?: true

Size: 563 Bytes

Versions: 1

Compression:

Stored size: 563 Bytes

Contents

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)
    path = URI.parse(uri).path
    name = File.basename(path)

    if name=='trunk' || name.empty?
      name = File.basename(File.dirname(path))
    end

    return name
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
repertoire-0.1.0 lib/repertoire/extensions/uri.rb