class Schmersion::Hosts::GitHub
Constants
- HTTP_REGEXP
- SSH_REGEXP
Public Class Methods
new(url)
click to toggle source
Calls superclass method
Schmersion::Host::new
# 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
suitable?(url)
click to toggle source
# File lib/schmersion/hosts/github.rb, line 14 def suitable?(url) !!(url.match(SSH_REGEXP) || url.match(HTTP_REGEXP)) end
Public Instance Methods
url_for_commit(ref)
click to toggle source
# File lib/schmersion/hosts/github.rb, line 26 def url_for_commit(ref) "#{@base_url}/commit/#{ref}" end
url_for_comparison(ref1, ref2)
click to toggle source
# File lib/schmersion/hosts/github.rb, line 30 def url_for_comparison(ref1, ref2) "#{@base_url}/compare/#{ref1}..#{ref2}" end
Private Instance Methods
get_user_and_repo(url)
click to toggle source
# File lib/schmersion/hosts/github.rb, line 36 def get_user_and_repo(url) if m = url.match(SSH_REGEXP) @user = m[1] @repo = m[2] elsif m = url.match(HTTP_REGEXP) @user = m[1] @repo = m[2] else raise Error, 'Could not determine appropriate details for repository from URL' end end