Class: GitHubPages::HealthCheck::Site

Inherits:
Checkable
  • Object
show all
Defined in:
lib/github-pages-health-check/site.rb

Constant Summary

Constants inherited from Checkable

Checkable::HASH_METHODS

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#domainObject (readonly)

Returns the value of attribute domain.



6
7
8
# File 'lib/github-pages-health-check/site.rb', line 6

def domain
  @domain
end

#repositoryObject (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_hashObject 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