class GemsComparator::GithubRepository
Public Class Methods
new(url)
click to toggle source
# File lib/gems_comparator/github_repository.rb, line 14 def initialize(url) @repo = Octokit::Repository.from_url(url) end
repo?(url)
click to toggle source
# File lib/gems_comparator/github_repository.rb, line 5 def self.repo?(url) return false unless url.include?('github.com') Octokit::Repository.from_url(url) true rescue StandardError false end
Public Instance Methods
compare(base, head)
click to toggle source
# File lib/gems_comparator/github_repository.rb, line 18 def compare(base, head) base_tag = find_tag(base) head_tag = find_tag(head) if base_tag && head_tag "#{@repo.url}/compare/#{base_tag}...#{head_tag}" elsif base_tag "#{@repo.url}/compare/#{base_tag}...master" end end
Private Instance Methods
client()
click to toggle source
# File lib/gems_comparator/github_repository.rb, line 41 def client GemsComparator.config.client end
find_tag(name)
click to toggle source
# File lib/gems_comparator/github_repository.rb, line 35 def find_tag(name) return if name.empty? tag_names.find { |tag_name| tag_name.include?(name) } end
tag_names()
click to toggle source
# File lib/gems_comparator/github_repository.rb, line 31 def tag_names @tag_names ||= client.tags(@repo).map(&:name) end