Class: GitHubPages::HealthCheck::CAA

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, nameservers: nil) ⇒ CAA

Returns a new instance of CAA.

Raises:

  • (ArgumentError)


12
13
14
15
16
17
# File 'lib/github-pages-health-check/caa.rb', line 12

def initialize(host, nameservers: nil)
  raise ArgumentError, "host cannot be nil" if host.nil?

  @host = host
  @nameservers = nameservers
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



10
11
12
# File 'lib/github-pages-health-check/caa.rb', line 10

def error
  @error
end

#hostObject (readonly)

Returns the value of attribute host.



10
11
12
# File 'lib/github-pages-health-check/caa.rb', line 10

def host
  @host
end

#nameserversObject (readonly)

Returns the value of attribute nameservers.



10
11
12
# File 'lib/github-pages-health-check/caa.rb', line 10

def nameservers
  @nameservers
end

Instance Method Details

#errored?Boolean

Returns:

  • (Boolean)


19
20
21
22
# File 'lib/github-pages-health-check/caa.rb', line 19

def errored?
  records # load the records first
  !error.nil?
end

#lets_encrypt_allowed?Boolean

Returns:

  • (Boolean)


24
25
26
27
28
# File 'lib/github-pages-health-check/caa.rb', line 24

def lets_encrypt_allowed?
  return false if errored?
  return true unless records_present?
  records.any? { |r| r.property_value == "letsencrypt.org" }
end

#recordsObject



35
36
37
38
39
# File 'lib/github-pages-health-check/caa.rb', line 35

def records
  @records ||= begin
    get_caa_records(host) | get_caa_records(host.split(".").drop(1).join("."))
  end
end

#records_present?Boolean

Returns:

  • (Boolean)


30
31
32
33
# File 'lib/github-pages-health-check/caa.rb', line 30

def records_present?
  return false if errored?
  records && !records.empty?
end