Class: LgPodPlugin::LURI
- Inherits:
-
Object
- Object
- LgPodPlugin::LURI
- Defined in:
- lib/lg_pod_plugin/net/l_uri.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#hostname ⇒ Object
readonly
Returns the value of attribute hostname.
-
#ip ⇒ Object
readonly
Returns the value of attribute ip.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#scheme ⇒ Object
readonly
Returns the value of attribute scheme.
Instance Method Summary collapse
-
#initialize(git) ⇒ LURI
constructor
A new instance of LURI.
- #to_s ⇒ Object
Constructor Details
#initialize(git) ⇒ LURI
Returns a new instance of LURI.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/lg_pod_plugin/net/l_uri.rb', line 16 def initialize(git) begin uri = URI(git) rescue => exception if git.include?("git@") && git.include?(":") match = %r{(?<=git@).*?(?=:)}.match(git) host = match ? match[0] : "" base_url = LUtils.get_gitlab_base_url(git) path = base_url.split(":").last uri = URI("http://#{host}/#{path}") else LgPodPlugin.log_red exception uri = nil end end return unless uri ip_address = getaddress(uri) return unless ip_address if git.include?("ssh") || git.include?("git@gitlab") || git.include?("git@") @uri = URI("http://#{ip_address}#{uri.path}") else @uri = URI("#{uri.scheme}://#{ip_address}#{uri.path}") end @ip = ip_address @host = @uri.host ||= "" @path = @uri.path ||= "" @scheme = @uri.scheme ||= "" @hostname = @scheme + "://" + @host end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
10 11 12 |
# File 'lib/lg_pod_plugin/net/l_uri.rb', line 10 def host @host end |
#hostname ⇒ Object (readonly)
Returns the value of attribute hostname.
12 13 14 |
# File 'lib/lg_pod_plugin/net/l_uri.rb', line 12 def hostname @hostname end |
#ip ⇒ Object (readonly)
Returns the value of attribute ip.
8 9 10 |
# File 'lib/lg_pod_plugin/net/l_uri.rb', line 8 def ip @ip end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
9 10 11 |
# File 'lib/lg_pod_plugin/net/l_uri.rb', line 9 def path @path end |
#scheme ⇒ Object (readonly)
Returns the value of attribute scheme.
11 12 13 |
# File 'lib/lg_pod_plugin/net/l_uri.rb', line 11 def scheme @scheme end |
Instance Method Details
#to_s ⇒ Object
79 80 81 82 |
# File 'lib/lg_pod_plugin/net/l_uri.rb', line 79 public def to_s return "" unless @uri @uri.to_s end |