Sha256: 073c66c5686c1c7a578e246e61a84cae0cb25634d1f74bb59f422a8e2c16027c

Contents?: true

Size: 1.98 KB

Versions: 3

Compression:

Stored size: 1.98 KB

Contents

# frozen_string_literal: true

require "dnsruby"
require "addressable/uri"
require "ipaddr"
require "public_suffix"
require "singleton"
require "net/http"
require "typhoeus"
require "resolv"
require "timeout"
require "octokit"
require_relative "github-pages-health-check/version"

if File.exist?(File.expand_path("../.env", File.dirname(__FILE__)))
  require "dotenv"
  Dotenv.load
end

module GitHubPages
  module HealthCheck
    autoload :CDN,        "github-pages-health-check/cdn"
    autoload :CloudFlare, "github-pages-health-check/cdns/cloudflare"
    autoload :Fastly,     "github-pages-health-check/cdns/fastly"
    autoload :Error,      "github-pages-health-check/error"
    autoload :Errors,     "github-pages-health-check/errors"
    autoload :CAA,        "github-pages-health-check/caa"
    autoload :Checkable,  "github-pages-health-check/checkable"
    autoload :Domain,     "github-pages-health-check/domain"
    autoload :Repository, "github-pages-health-check/repository"
    autoload :Resolver,   "github-pages-health-check/resolver"
    autoload :Site,       "github-pages-health-check/site"
    autoload :Printer,    "github-pages-health-check/printer"

    # DNS and HTTP timeout, in seconds
    TIMEOUT = 7

    HUMAN_NAME = "GitHub Pages Health Check".freeze
    URL = "https://github.com/github/pages-health-check".freeze
    USER_AGENT = "Mozilla/5.0 (compatible; #{HUMAN_NAME}/#{VERSION}; +#{URL})".freeze

    TYPHOEUS_OPTIONS = {
      :followlocation => true,
      :timeout => TIMEOUT,
      :accept_encoding => "gzip",
      :method => :head,
      :headers => {
        "User-Agent" => USER_AGENT
      }
    }.freeze

    # surpress warn-level feedback due to unsupported record types
    def self.without_warnings(&block)
      warn_level = $VERBOSE
      $VERBOSE = nil
      result = block.call
      $VERBOSE = warn_level
      result
    end

    def self.check(repository_or_domain, access_token: nil)
      Site.new repository_or_domain, :access_token => access_token
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
github-pages-health-check-1.9.0 lib/github-pages-health-check.rb
github-pages-health-check-1.8.1 lib/github-pages-health-check.rb
github-pages-health-check-1.8.0 lib/github-pages-health-check.rb