diff --git a/lib/gitable/uri.rb b/lib/gitable/uri.rb index 7232228..16cc21a 100644 --- a/lib/gitable/uri.rb +++ b/lib/gitable/uri.rb @@ -97,7 +97,7 @@ def self.heuristic_parse(uri) # Addressable::URI.heuristic_parse _does_ return the correct type :) gitable = super # boo inconsistency - if gitable.github? || gitable.bitbucket? + if gitable.github? || gitable.bitbucket? || gitable.gitlab? gitable.extname = "git" end gitable @@ -110,6 +110,13 @@ def github? !!normalized_host.to_s.match(/\.?github.com$/) end + # Is this uri a gitlab uri? + # + # @return [Boolean] gitlab.com is the host? + def gitlab? + !!normalized_host.to_s.match(/\.?gitlab.com$/) + end + # Is this uri a bitbucket uri? # # @return [Boolean] bitbucket.org is the host? diff --git a/spec/gitable_spec.rb b/spec/gitable_spec.rb index 90b04a0..40370d3 100644 --- a/spec/gitable_spec.rb +++ b/spec/gitable_spec.rb @@ -575,6 +575,7 @@ :authenticated? => true, :interactive_authenticated? => false, :github? => true, + :gitlab? => false, :bitbucket? => false, :to_web_uri => Addressable::URI.parse("https://github.com/martinemde/gitable"), }) @@ -603,6 +604,7 @@ :ssh? => false, :scp? => false, :github? => true, + :gitlab? => false, :bitbucket? => false, :to_web_uri => Addressable::URI.parse("https://github.com/martinemde/gitable"), }) @@ -632,6 +634,7 @@ :ssh? => false, :scp? => false, :github? => true, + :gitlab? => false, :bitbucket? => false, :authenticated? => true, :interactive_authenticated? => true, @@ -662,6 +665,7 @@ :ssh? => false, :scp? => false, :github? => true, + :gitlab? => false, :bitbucket? => false, :authenticated? => false, :interactive_authenticated? => false, @@ -695,6 +699,7 @@ :authenticated? => true, :interactive_authenticated? => false, :github? => true, + :gitlab? => false, :bitbucket? => false, :to_web_uri => Addressable::URI.parse("https://github.com/martinemde/gitable"), }) @@ -725,6 +730,7 @@ :authenticated? => true, :interactive_authenticated? => false, :github? => false, + :gitlab? => false, :bitbucket? => true, :to_web_uri => Addressable::URI.parse("https://bitbucket.org/martinemde/gitable"), }) @@ -753,6 +759,7 @@ :ssh? => false, :scp? => false, :github? => false, + :gitlab? => false, :bitbucket? => true, :to_web_uri => Addressable::URI.parse("https://bitbucket.org/martinemde/gitable"), }) @@ -782,6 +789,7 @@ :ssh? => false, :scp? => false, :github? => false, + :gitlab? => false, :bitbucket? => true, :authenticated? => true, :interactive_authenticated? => true, @@ -812,6 +820,7 @@ :ssh? => false, :scp? => false, :github? => false, + :gitlab? => false, :bitbucket? => true, :authenticated? => false, :interactive_authenticated? => false, @@ -845,6 +854,7 @@ :authenticated? => true, :interactive_authenticated? => false, :github? => false, + :gitlab? => false, :bitbucket? => true, :to_web_uri => Addressable::URI.parse("https://bitbucket.org/martinemde/gitable"), })