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.
8 9 10 11 12 13 14 |
# File 'lib/github-pages-health-check/site.rb', line 8 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.redundant(repository_or_domain) end |
Instance Attribute Details
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
6 7 8 |
# File 'lib/github-pages-health-check/site.rb', line 6 def domain @domain end |
#repository ⇒ Object (readonly)
Returns the value of attribute repository.
6 7 8 |
# File 'lib/github-pages-health-check/site.rb', line 6 def repository @repository end |
Instance Method Details
#check! ⇒ Object
16 17 18 19 |
# File 'lib/github-pages-health-check/site.rb', line 16 def check! [domain, repository].compact.each(&:check!) true end |
#to_hash ⇒ Object Also known as: to_h, as_json
21 22 23 24 25 26 27 |
# File 'lib/github-pages-health-check/site.rb', line 21 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 |