Class: GitHubPages::HealthCheck::Repository
- Inherits:
-
Checkable
- Object
- Checkable
- GitHubPages::HealthCheck::Repository
show all
- Defined in:
- lib/github-pages-health-check/repository.rb
Constant Summary
collapse
- REPO_REGEX =
%r{\A[a-z0-9_\-]+/[a-z0-9_\-\.]+\z}i
- HASH_METHODS =
%i[
name_with_owner built? last_built build_duration build_error
].freeze
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Checkable
#to_hash, #to_json, #to_s, #to_s_pretty, #valid?
Constructor Details
#initialize(name_with_owner, access_token: nil) ⇒ Repository
Returns a new instance of Repository.
14
15
16
17
18
19
20
21
22
|
# 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
|
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
6
7
8
|
# File 'lib/github-pages-health-check/repository.rb', line 6
def name
@name
end
|
#owner ⇒ Object
Returns the value of attribute owner.
6
7
8
|
# File 'lib/github-pages-health-check/repository.rb', line 6
def owner
@owner
end
|
Instance Method Details
#build_duration ⇒ Object
47
48
49
|
# File 'lib/github-pages-health-check/repository.rb', line 47
def build_duration
last_build && last_build.duration
end
|
#build_error ⇒ Object
Also known as:
reason
42
43
44
|
# File 'lib/github-pages-health-check/repository.rb', line 42
def build_error
last_build.error["message"] unless built?
end
|
#built? ⇒ Boolean
38
39
40
|
# File 'lib/github-pages-health-check/repository.rb', line 38
def built?
last_build && last_build.status == "built"
end
|
#check! ⇒ Object
29
30
31
32
|
# File 'lib/github-pages-health-check/repository.rb', line 29
def check!
raise Errors::BuildError.new(:repository => self), build_error unless built?
true
end
|
#domain ⇒ Object
55
56
57
58
|
# File 'lib/github-pages-health-check/repository.rb', line 55
def domain
return if cname.nil?
@domain ||= GitHubPages::HealthCheck::Domain.new(cname)
end
|
#last_build ⇒ Object
34
35
36
|
# File 'lib/github-pages-health-check/repository.rb', line 34
def last_build
@last_build ||= client.latest_pages_build(name_with_owner)
end
|
#last_built ⇒ Object
51
52
53
|
# File 'lib/github-pages-health-check/repository.rb', line 51
def last_built
last_build && last_build.updated_at
end
|
#name_with_owner ⇒ Object
Also known as:
nwo
24
25
26
|
# File 'lib/github-pages-health-check/repository.rb', line 24
def name_with_owner
@name_with_owner ||= [owner, name].join("/")
end
|