class TachikomaAi::Repository
Attributes
owner[R]
repo[R]
url[R]
Public Class Methods
new(url)
click to toggle source
# File lib/tachikoma_ai/repository.rb, line 8 def initialize(url) @url = url.gsub(/http:/, 'https:') @owner, @repo = URI.parse(@url).path.split('/').drop(1) end
Public Instance Methods
compare(start, endd)
click to toggle source
# File lib/tachikoma_ai/repository.rb, line 13 def compare(start, endd) s = find_tag(start) e = find_tag(endd) base = "https://github.com/#{owner}/#{repo}" if s.nil? && e.nil? "#{base} (tags not found)" elsif e.nil? "#{base}/compare/#{s}...master" else "#{base}/compare/#{s}...#{e}" end end
Private Instance Methods
fetch(uri_str, limit = 10)
click to toggle source
# File lib/tachikoma_ai/repository.rb, line 48 def fetch(uri_str, limit = 10) raise ArgumentError, 'HTTP redirect too deep' if limit.zero? response = Net::HTTP.get_response URI.parse(uri_str) if response.is_a? Net::HTTPRedirection fetch(response['location'], limit - 1) else response end end
find_tag(tag)
click to toggle source
# File lib/tachikoma_ai/repository.rb, line 32 def find_tag(tag) tags.find { |t| t == "v#{tag}" || t == tag } end