Class: Gitable::ScpURI
- Defined in:
- lib/gitable/scp_uri.rb
Constant Summary
Constants inherited from URI
URI::SCP_REGEXP, URI::URIREGEX
Class Method Summary collapse
-
.parse(uri) ⇒ Object
Deprecated: This serves no purpose.
-
.scp?(uri) ⇒ Boolean
Deprecated: This serves no purpose.
Instance Method Summary collapse
-
#inferred_scheme ⇒ String
Return the actual scheme even though we don’t show it.
-
#path=(new_path) ⇒ String
Keep URIs like this as they were input:.
-
#scp? ⇒ true
Is this an scp formatted uri? (Yes, always).
-
#ssh? ⇒ true
Scp style URIs are always ssh.
-
#to_s ⇒ String
(also: #to_str)
Get the URI as a string in the same form it was input.
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.
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_scheme ⇒ String
Return the actual scheme even though we don’t show it
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
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)
76 77 78 |
# File 'lib/gitable/scp_uri.rb', line 76 def scp? true end |
#ssh? ⇒ true
Scp style URIs are always ssh
69 70 71 |
# File 'lib/gitable/scp_uri.rb', line 69 def ssh? true end |
#to_s ⇒ String Also known as: to_str
Get the URI as a string in the same form it was input.
Taken from Addressable::URI.
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_path}" if uri_string.respond_to?(:force_encoding) uri_string.force_encoding(Encoding::UTF_8) end uri_string end end |