class GitMaintain::CI
Public Class Methods
load(repo)
click to toggle source
# File lib/ci.rb, line 4 def self.load(repo) repo_name = File.basename(repo.path) return GitMaintain::loadClass(CI, repo_name, repo) end
new(repo)
click to toggle source
# File lib/ci.rb, line 9 def initialize(repo) GitMaintain::checkDirectConstructor(self.class) @repo = repo @cachedJson={} end
Public Instance Methods
checkStableState(br, sha1)
click to toggle source
# File lib/ci.rb, line 71 def checkStableState(br, sha1) raise("Unimplemented") end
checkValidState(br, sha1)
click to toggle source
# File lib/ci.rb, line 58 def checkValidState(br, sha1) raise("Unimplemented") end
emptyCache()
click to toggle source
# File lib/ci.rb, line 80 def emptyCache() @cachedJson={} end
getStableLog(br, sha1)
click to toggle source
# File lib/ci.rb, line 74 def getStableLog(br, sha1) raise("Unimplemented") end
getStableState(br, sha1)
click to toggle source
# File lib/ci.rb, line 68 def getStableState(br, sha1) raise("Unimplemented") end
getStableTS(br, sha1)
click to toggle source
# File lib/ci.rb, line 77 def getStableTS(br, sha1) raise("Unimplemented") end
getValidLog(br, sha1)
click to toggle source
# File lib/ci.rb, line 61 def getValidLog(br, sha1) raise("Unimplemented") end
getValidState(br, sha1)
click to toggle source
# File lib/ci.rb, line 55 def getValidState(br, sha1) raise("Unimplemented") end
getValidTS(br, sha1)
click to toggle source
# File lib/ci.rb, line 64 def getValidTS(br, sha1) raise("Unimplemented") end
isErrored(br, status)
click to toggle source
# File lib/ci.rb, line 84 def isErrored(br, status) raise("Unimplemented") end
Private Instance Methods
fetch(uri_str, limit = 10)
click to toggle source
# File lib/ci.rb, line 21 def fetch(uri_str, limit = 10) # You should choose a better exception. raise ArgumentError, 'too many HTTP redirects' if limit == 0 response = Net::HTTP.get_response(URI(uri_str)) case response when Net::HTTPSuccess then response when Net::HTTPRedirection then location = response['location'] fetch(location, limit - 1) else response.value end end
getJson(base_url, query_label, query, json=true)
click to toggle source
# File lib/ci.rb, line 37 def getJson(base_url, query_label, query, json=true) return @cachedJson[query_label] if @cachedJson[query_label] != nil url = base_url + query uri = URI(url) log(:INFO, "Querying CI...") log(:DEBUG_CI, url) response = fetch(uri) raise("CI request failed '#{url}'") if response.code.to_s() != '200' if json == true @cachedJson[query_label] = JSON.parse(response.body) else @cachedJson[query_label] = response.body end return @cachedJson[query_label] end
log(lvl, str)
click to toggle source
# File lib/ci.rb, line 17 def log(lvl, str) GitMaintain::log(lvl, str) end