Class: SiteHealth::Configuration
- Inherits:
-
Object
- Object
- SiteHealth::Configuration
- Defined in:
- lib/site_health/configuration/configuration.rb
Overview
Holds configuration data
Defined Under Namespace
Classes: InvalidCheckerError
Instance Attribute Summary collapse
-
#checkers ⇒ Object
Returns the value of attribute checkers.
-
#google_page_speed_api_key ⇒ Object
readonly
Returns the value of attribute google_page_speed_api_key.
-
#locale ⇒ Object
readonly
Returns the value of attribute locale.
-
#logger ⇒ Object
Returns the value of attribute logger.
Instance Method Summary collapse
-
#default_checkers ⇒ Array<Checker>
Array of default checkers to run.
-
#html_proofer {|the| ... } ⇒ HTMLProoferConfiguration
The current configuration.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#register_checker(checker) ⇒ Checker
The registered checker.
-
#w3c {|the| ... } ⇒ W3CValidatorsConfiguration
The current configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
15 16 17 18 19 20 21 22 |
# 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 |
Instance Attribute Details
#checkers ⇒ Object
Returns the value of attribute checkers.
13 14 15 |
# File 'lib/site_health/configuration/configuration.rb', line 13 def checkers @checkers end |
#google_page_speed_api_key ⇒ Object (readonly)
Returns the value of attribute google_page_speed_api_key.
13 14 15 |
# File 'lib/site_health/configuration/configuration.rb', line 13 def google_page_speed_api_key @google_page_speed_api_key end |
#locale ⇒ Object (readonly)
Returns the value of attribute locale.
13 14 15 |
# File 'lib/site_health/configuration/configuration.rb', line 13 def locale @locale end |
#logger ⇒ Object
Returns the value of attribute logger.
13 14 15 |
# File 'lib/site_health/configuration/configuration.rb', line 13 def logger @logger end |
Instance Method Details
#default_checkers ⇒ Array<Checker>
Returns array of default checkers to run.
72 73 74 75 76 77 78 79 80 81 82 |
# 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 {|the| ... } ⇒ HTMLProoferConfiguration
Returns the current configuration.
35 36 37 38 39 |
# 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 |
#register_checker(checker) ⇒ Checker
Returns the registered checker.
58 59 60 61 62 63 64 65 66 67 68 69 |
# 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 {|the| ... } ⇒ W3CValidatorsConfiguration
Returns the current configuration.
43 44 45 46 47 |
# File 'lib/site_health/configuration/configuration.rb', line 43 def w3c @w3c ||= W3CValidatorsConfiguration.new yield(@w3c) if block_given? @w3c end |