Class: GitHubPages::HealthCheck::Site
- Defined in:
- lib/github-pages-health-check/site.rb
Constant Summary
Constants inherited from Checkable
Instance Attribute Summary collapse
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#repository ⇒ Object
readonly
Returns the value of attribute repository.
Instance Method Summary collapse
- #check! ⇒ Object
-
#initialize(repository_or_domain, access_token: nil) ⇒ Site
constructor
A new instance of Site.
- #to_hash ⇒ Object (also: #to_h, #as_json)
Methods inherited from Checkable
#reason, #to_json, #to_s, #to_s_pretty, #valid?
Constructor Details
#initialize(repository_or_domain, access_token: nil) ⇒ Site
Returns a new instance of Site.
7 8 9 10 11 12 13 |
# File 'lib/github-pages-health-check/site.rb', line 7 def initialize(repository_or_domain, access_token: nil) @repository = Repository.new(repository_or_domain, access_token: access_token) @domain = @repository.domain rescue GitHubPages::HealthCheck::Errors::InvalidRepositoryError @repository = nil @domain = Domain.new(repository_or_domain) end |
Instance Attribute Details
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
5 6 7 |
# File 'lib/github-pages-health-check/site.rb', line 5 def domain @domain end |
#repository ⇒ Object (readonly)
Returns the value of attribute repository.
5 6 7 |
# File 'lib/github-pages-health-check/site.rb', line 5 def repository @repository end |
Instance Method Details
#check! ⇒ Object
15 16 17 18 |
# File 'lib/github-pages-health-check/site.rb', line 15 def check! [domain, repository].each { |check| check.check! unless check.nil? } true end |
#to_hash ⇒ Object Also known as: to_h, as_json
20 21 22 23 24 25 26 |
# File 'lib/github-pages-health-check/site.rb', line 20 def to_hash hash = (domain || {}).to_hash.dup hash = hash.merge(repository.to_hash) unless repository.nil? hash[:valid?] = valid? hash[:reason] = reason hash end |