Sha256: 33ac03bf9c7685bfe529323da5561fb1920440f68b01cf29c5956d6d46671bbc
Contents?: true
Size: 1.38 KB
Versions: 1
Compression:
Stored size: 1.38 KB
Contents
require 'gitable/uri' module Gitable class ScpURI < Gitable::URI # Keep URIs like this as they were input: # # git@github.com:martinemde/gitable.git # # Without breaking URIs like these: # # git@host.com:/home/martinemde/gitable.git # # @param [String] new_path The new path to be set. # @return [String] The same path passed in. def path=(new_path) super @path = path.sub(%r|^/|,'') if new_path[0] != ?/ @path end # Get the URI as a string in the same form it was input. # # Taken from Addressable::URI. # # @return [String] The URI as a string. def to_s @uri_string ||= begin uri_string = "#{authority}:#{path}" if uri_string.respond_to?(:force_encoding) uri_string.force_encoding(Encoding::UTF_8) end uri_string end end protected def validate return if !!@validation_deferred if scheme != nil && (host == nil || host == "") && (path == nil || path == "") raise InvalidURIError, "Absolute URI missing hierarchical segment: '#{to_s}'" end if host == nil if port != nil || user != nil || password != nil raise InvalidURIError, "Hostname not supplied: '#{to_s}'" end end return nil end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gitable-0.0.3 | lib/gitable/scp_uri.rb |