class SiteHealth::Configuration

Holds configuration data

Attributes

checkers[R]
google_page_speed_api_key[R]
locale[R]
logger[R]

Public Class Methods

new() click to toggle source
# File lib/site_health/configuration/configuration.rb, line 15
def initialize
  @checkers = Set.new(default_checkers)
  @html_proofer = nil
  @w3c = nil
  @google_page_speed_api_key = nil
  @logger = NullLogger.new
  @locale = 'en'
end

Public Instance Methods

checkers=(checkers) click to toggle source

@return [Array<Checker>] array of checkers to run @param [Array<Checker>] checkers array of checkers to run

# File lib/site_health/configuration/configuration.rb, line 51
def checkers=(checkers)
  @checkers = Array(checkers).map! { |checker| register_checker(checker) }
end
default_checkers() click to toggle source

@return [Array<Checker>] array of default checkers to run

# File lib/site_health/configuration/configuration.rb, line 72
def default_checkers
  %i[
    facebook_share_link
    missing_title
    missing_description
    redirect
    xml
    json_syntax
    page_not_found
  ].map! { |name| SiteHealth.load_checker(name) }
end
html_proofer() { |html_proofer| ... } click to toggle source

@return [HTMLProoferConfiguration] the current configuration @yieldparam [HTMLProoferConfiguration] the current configuration

# File lib/site_health/configuration/configuration.rb, line 35
def html_proofer
  @html_proofer ||= HTMLProoferConfiguration.new
  yield(@html_proofer) if block_given?
  @html_proofer
end
logger=(logger) click to toggle source

Set logger @return [Object] the set logger @param [Object] logger an object than response to quacks like a Logger @example set a logger that prints to standard out (STDOUT)

SiteHealth.logger = Logger.new(STDOUT)
# File lib/site_health/configuration/configuration.rb, line 29
def logger=(logger)
  @logger = logger
end
register_checker(checker) click to toggle source

@param [Checker, String, Symbol] checker

additional checker to run can also be the name of an existing checker

@return [Checker] the registered checker

# File lib/site_health/configuration/configuration.rb, line 58
def register_checker(checker)
  if [String, Symbol].include?(checker.class)
    checker = SiteHealth.load_checker(checker)
  end

  unless checker.respond_to?(:check) || checker.instance_methods.include?(:check)
    raise(InvalidCheckerError, 'checker must implement #check')
  end

  @checkers << checker
  checker
end
w3c() { |w3c| ... } click to toggle source

@return [W3CValidatorsConfiguration] the current configuration @yieldparam [W3CValidatorsConfiguration] the current configuration

# File lib/site_health/configuration/configuration.rb, line 43
def w3c
  @w3c ||= W3CValidatorsConfiguration.new
  yield(@w3c) if block_given?
  @w3c
end