Class: Gitable::ScpURI

Inherits:
URI
  • Object
show all
Defined in:
lib/gitable/scp_uri.rb

Constant Summary

Constants inherited from URI

URI::SCP_REGEXP, URI::URIREGEX

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from URI

#authenticated?, #basename, #basename=, #bitbucket?, #equivalent?, #extname=, #github?, heuristic_parse, #inspect, #interactive_authenticated?, #local?, #org_project, parse_when_valid, #project_name, #set_git_extname, #to_web_uri

Class Method Details

.parse(uri) ⇒ Object

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



16
17
18
19
# 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) ⇒ Boolean

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

Returns:

  • (Boolean)


9
10
11
12
# 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

Instance Method Details

#inferred_schemeString

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

Returns:

  • (String)

    always ‘ssh’ for scp style URIs



62
63
64
# File 'lib/gitable/scp_uri.rb', line 62

def inferred_scheme
  'ssh'
end

#path=(new_path) ⇒ String

Keep URIs like this as they were input:

git@github.com:martinemde/gitable.git

Without breaking URIs like these:

[email protected]:/home/martinemde/gitable.git

Parameters:

  • new_path (String)

    The new path to be set.

Returns:

  • (String)

    The same path passed in.



32
33
34
35
36
37
38
39
40
# 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?true

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

Returns:

  • (true)

    always scp formatted uri



76
77
78
# File 'lib/gitable/scp_uri.rb', line 76

def scp?
  true
end

#ssh?true

Scp style URIs are always ssh

Returns:

  • (true)

    always ssh



69
70
71
# File 'lib/gitable/scp_uri.rb', line 69

def ssh?
  true
end

#to_sString Also known as: to_str

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

Taken from Addressable::URI.

Returns:

  • (String)

    The URI as a string.



47
48
49
50
51
52
53
54
55
56
# 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