Skip to content

Commit

Permalink
Add gitlab? (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinemde committed Dec 15, 2023
1 parent 471dbc7 commit 323e230
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/gitable/uri.rb
Expand Up @@ -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
Expand All @@ -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?
Expand Down
10 changes: 10 additions & 0 deletions spec/gitable_spec.rb
Expand Up @@ -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"),
})
Expand Down Expand Up @@ -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"),
})
Expand Down Expand Up @@ -632,6 +634,7 @@
:ssh? => false,
:scp? => false,
:github? => true,
:gitlab? => false,
:bitbucket? => false,
:authenticated? => true,
:interactive_authenticated? => true,
Expand Down Expand Up @@ -662,6 +665,7 @@
:ssh? => false,
:scp? => false,
:github? => true,
:gitlab? => false,
:bitbucket? => false,
:authenticated? => false,
:interactive_authenticated? => false,
Expand Down Expand Up @@ -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"),
})
Expand Down Expand Up @@ -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"),
})
Expand Down Expand Up @@ -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"),
})
Expand Down Expand Up @@ -782,6 +789,7 @@
:ssh? => false,
:scp? => false,
:github? => false,
:gitlab? => false,
:bitbucket? => true,
:authenticated? => true,
:interactive_authenticated? => true,
Expand Down Expand Up @@ -812,6 +820,7 @@
:ssh? => false,
:scp? => false,
:github? => false,
:gitlab? => false,
:bitbucket? => true,
:authenticated? => false,
:interactive_authenticated? => false,
Expand Down Expand Up @@ -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"),
})
Expand Down

0 comments on commit 323e230

Please sign in to comment.