class Gitable::ScpURI

Public Class Methods

parse(uri) click to toggle source

Deprecated: This serves no purpose. Just use Gitable::URI.parse.

# File lib/gitable/scp_uri.rb, line 16
def self.parse(uri)
  $stderr.puts "DEPRECATED: Gitable::ScpURI.parse just runs Gitable::URI.parse. Please use this directly."
  Gitable::URI.parse(uri)
end
scp?(uri) click to toggle source

Deprecated: This serves no purpose. You might as well just parse the URI.

# File lib/gitable/scp_uri.rb, line 9
def self.scp?(uri)
  $stderr.puts "DEPRECATED: Gitable::ScpURI.scp?. You're better off parsing the URI and checking #scp?."
  Gitable::URI.parse(uri).scp?
end

Public Instance Methods

inferred_scheme() click to toggle source

Return the actual scheme even though we don't show it

@return [String] always 'ssh' for scp style URIs

# File lib/gitable/scp_uri.rb, line 62
def inferred_scheme
  'ssh'
end
path=(new_path) click to toggle source

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.

Calls superclass method
# File lib/gitable/scp_uri.rb, line 32
def path=(new_path)
  super
  if new_path[0..0] != '/' # addressable adds a / but scp-style uris are altered by this behavior
    @path = path.sub(%r|^/+|,'')
    @normalized_path = nil
    validate
  end
  path
end
scp?() click to toggle source

Is this an scp formatted uri? (Yes, always)

@return [true] always scp formatted uri

# File lib/gitable/scp_uri.rb, line 76
def scp?
  true
end
ssh?() click to toggle source

Scp style URIs are always ssh

@return [true] always ssh

# File lib/gitable/scp_uri.rb, line 69
def ssh?
  true
end
to_s() click to toggle source

Get the URI as a string in the same form it was input.

Taken from Addressable::URI.

@return [String] The URI as a string.

# File lib/gitable/scp_uri.rb, line 47
def to_s
  @uri_string ||=
    begin
      uri_string = "#{normalized_authority}:#{normalized_path}"
      if uri_string.respond_to?(:force_encoding)
        uri_string.force_encoding(Encoding::UTF_8)
      end
      uri_string
    end
end
Also aliased as: to_str
to_str()
Alias for: to_s

Protected Instance Methods

invalid!(reason) click to toggle source
# File lib/gitable/scp_uri.rb, line 104
def invalid!(reason)
  raise InvalidURIError, "#{reason}: '#{to_s}'"
end
validate() click to toggle source
# File lib/gitable/scp_uri.rb, line 82
def validate
  return if @validation_deferred

  if host.to_s.empty?
    invalid! "Hostname segment missing"
  end

  if !scheme.to_s.empty?
    invalid! "Scp style URI must not have a scheme"
  end

  if !port.to_s.empty?
    invalid! "Scp style URI cannot have a port"
  end

  if path.to_s.empty?
    invalid! "Absolute URI missing hierarchical segment"
  end

  nil
end