Sha256: 91996453ad7bd228a48242d81067ad3d7cd1a80c3d7fe63dea8a18966bd83ed3

Contents?: true

Size: 863 Bytes

Versions: 6

Compression:

Stored size: 863 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.new(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

6 entries across 6 versions & 1 rubygems

Version Path
github-pages-health-check-1.9.0 lib/github-pages-health-check/site.rb
github-pages-health-check-1.8.1 lib/github-pages-health-check/site.rb
github-pages-health-check-1.8.0 lib/github-pages-health-check/site.rb
github-pages-health-check-1.7.4 lib/github-pages-health-check/site.rb
github-pages-health-check-1.7.3 lib/github-pages-health-check/site.rb
github-pages-health-check-1.7.2 lib/github-pages-health-check/site.rb