Class: Schmersion::Hosts::GitHub

Inherits:
Schmersion::Host show all
Defined in:
lib/schmersion/hosts/github.rb

Constant Summary collapse

SSH_REGEXP =
/\Agit@github\.com:([\w-]+)\/([\w-]+)(\.git)?\z/.freeze
HTTP_REGEXP =
/\Ahttps:\/\/github\.com\/([\w-]+)\/([\w-]+)(\.git)?\z/.freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ GitHub

Returns a new instance of GitHub.



20
21
22
23
24
# File 'lib/schmersion/hosts/github.rb', line 20

def initialize(url)
  super
  get_user_and_repo(url)
  @base_url = "https://github.com/#{@user}/#{@repo}"
end

Class Method Details

.suitable?(url) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/schmersion/hosts/github.rb', line 14

def suitable?(url)
  !!(url.match(SSH_REGEXP) || url.match(HTTP_REGEXP))
end

Instance Method Details

#url_for_commit(ref) ⇒ Object



26
27
28
# File 'lib/schmersion/hosts/github.rb', line 26

def url_for_commit(ref)
  "#{@base_url}/commit/#{ref}"
end

#url_for_comparison(ref1, ref2) ⇒ Object



30
31
32
# File 'lib/schmersion/hosts/github.rb', line 30

def url_for_comparison(ref1, ref2)
  "#{@base_url}/compare/#{ref1}..#{ref2}"
end