Sha256: 716921b6b945f8aaa731ae25713c597e65a391940ddc0e87d13853acb4f6f1dc

Contents?: true

Size: 1007 Bytes

Versions: 20

Compression:

Stored size: 1007 Bytes

Contents

# frozen_string_literal: true

module GitHubPages
  module HealthCheck
    class RedundantCheck
      extend Forwardable

      TIMEOUT = 5 # seconds

      attr_reader :domain

      def initialize(domain)
        @domain = domain
      end

      def check
        @check ||= (checks.find(&:valid?) || check_with_default_nameservers)
      end

      def_delegator :check, :reason, :reason
      def_delegator :check, :valid?, :valid?

      def https_eligible?
        checks.any?(&:https_eligible?)
      end

      private

      def checks
        @checks ||= %i[default authoritative public].map do |ns|
          GitHubPages::HealthCheck::Domain.new(domain, :nameservers => ns)
        end
      end

      def check_with_default_nameservers
        @check_with_default_nameservers ||= checks.find { |c| c.nameservers == :default }
      end

      def check_with_public_nameservers
        @check_with_public_nameservers ||= checks.find { |c| c.nameservers == :public }
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

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