class GitHubPages::HealthCheck::Repository

Constants

HASH_METHODS
REPO_REGEX

Attributes

name[R]
owner[R]

Public Class Methods

new(name_with_owner, access_token: nil) click to toggle source
# File lib/github-pages-health-check/repository.rb, line 14
def initialize(name_with_owner, access_token: nil)
  unless name_with_owner.match(REPO_REGEX)
    raise Errors::InvalidRepositoryError
  end

  parts = name_with_owner.split("/")
  @owner = parts.first
  @name  = parts.last
  @access_token = access_token || ENV["OCTOKIT_ACCESS_TOKEN"]
end

Public Instance Methods

build_duration() click to toggle source
# File lib/github-pages-health-check/repository.rb, line 49
def build_duration
  last_build&.duration
end
build_error() click to toggle source
# File lib/github-pages-health-check/repository.rb, line 44
def build_error
  last_build.error["message"] unless built?
end
Also aliased as: reason
built?() click to toggle source
# File lib/github-pages-health-check/repository.rb, line 40
def built?
  last_build && last_build.status == "built"
end
check!() click to toggle source
# File lib/github-pages-health-check/repository.rb, line 30
def check!
  raise Errors::BuildError.new(:repository => self), build_error unless built?

  true
end
domain() click to toggle source
# File lib/github-pages-health-check/repository.rb, line 57
def domain
  return if cname.nil?

  @domain ||= GitHubPages::HealthCheck::Domain.redundant(cname)
end
last_build() click to toggle source
# File lib/github-pages-health-check/repository.rb, line 36
def last_build
  @last_build ||= client.latest_pages_build(name_with_owner)
end
last_built() click to toggle source
# File lib/github-pages-health-check/repository.rb, line 53
def last_built
  last_build&.updated_at
end
name_with_owner() click to toggle source
# File lib/github-pages-health-check/repository.rb, line 25
def name_with_owner
  @name_with_owner ||= [owner, name].join("/")
end
Also aliased as: nwo
nwo()
Alias for: name_with_owner
reason()
Alias for: build_error

Private Instance Methods

client() click to toggle source
# File lib/github-pages-health-check/repository.rb, line 65
def client
  raise Errors::MissingAccessTokenError if @access_token.nil?

  @client ||= Octokit::Client.new(:access_token => @access_token)
end
cname() click to toggle source
# File lib/github-pages-health-check/repository.rb, line 75
def cname
  pages_info.cname
end
pages_info() click to toggle source
# File lib/github-pages-health-check/repository.rb, line 71
def pages_info
  @pages_info ||= client.pages(name_with_owner)
end