Sha256: 10773eb238c128a41e2f36d5713ed2b841147a78c58c8763841a27bfbfbfb397

Contents?: true

Size: 869 Bytes

Versions: 21

Compression:

Stored size: 869 Bytes

Contents

# frozen_string_literal: true

module GitHubPages
  module HealthCheck
    class Site < Checkable
      attr_reader :repository, :domain

      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

      def check!
        [domain, repository].compact.each(&:check!)
        true
      end

      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
      alias to_h to_hash
      alias as_json to_hash
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
github-pages-health-check-1.18.5 lib/github-pages-health-check/site.rb
github-pages-health-check-1.18.4 lib/github-pages-health-check/site.rb
github-pages-health-check-1.18.2 lib/github-pages-health-check/site.rb
github-pages-health-check-1.18.1 lib/github-pages-health-check/site.rb
github-pages-health-check-1.18.0 lib/github-pages-health-check/site.rb
github-pages-health-check-1.17.9 lib/github-pages-health-check/site.rb
github-pages-health-check-1.17.8 lib/github-pages-health-check/site.rb
github-pages-health-check-1.17.7 lib/github-pages-health-check/site.rb
github-pages-health-check-1.17.6 lib/github-pages-health-check/site.rb
github-pages-health-check-1.17.2 lib/github-pages-health-check/site.rb
github-pages-health-check-1.17.1 lib/github-pages-health-check/site.rb
github-pages-health-check-1.17.0 lib/github-pages-health-check/site.rb
github-pages-health-check-1.16.1 lib/github-pages-health-check/site.rb
github-pages-health-check-1.16.0 lib/github-pages-health-check/site.rb
github-pages-health-check-1.15.0 lib/github-pages-health-check/site.rb
github-pages-health-check-1.14.0 lib/github-pages-health-check/site.rb
github-pages-health-check-1.13.0 lib/github-pages-health-check/site.rb
github-pages-health-check-1.12.0 lib/github-pages-health-check/site.rb
github-pages-health-check-1.11.1 lib/github-pages-health-check/site.rb
github-pages-health-check-1.11.0 lib/github-pages-health-check/site.rb