Class: AuditService
- Inherits:
-
Object
- Object
- AuditService
- Defined in:
- lib/lighthouse/audit_service.rb
Overview
Compares a url’s actual score to the expected score.
Defined Under Namespace
Classes: Error
Instance Method Summary collapse
-
#initialize(url, audit, score) ⇒ AuditService
constructor
A new instance of AuditService.
- #measured_score ⇒ Object
- #passing_score? ⇒ Boolean
- #results ⇒ Object
- #run_warnings ⇒ Object
Constructor Details
#initialize(url, audit, score) ⇒ AuditService
Returns a new instance of AuditService.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/lighthouse/audit_service.rb', line 10 def initialize(url, audit, score) @url = url @audit = audit @score = score @port = Lighthouse::Matchers.remote_debugging_port @runner = Lighthouse::Matchers.runner @cmd = Lighthouse::Matchers.lighthouse_cli @chrome_flags = Lighthouse::Matchers.chrome_flags @preset = Lighthouse::Matchers.preset @form_factor = Lighthouse::Matchers.form_factor end |
Instance Method Details
#measured_score ⇒ Object
26 27 28 |
# File 'lib/lighthouse/audit_service.rb', line 26 def measured_score category['score'] * 100 end |
#passing_score? ⇒ Boolean
22 23 24 |
# File 'lib/lighthouse/audit_service.rb', line 22 def passing_score? measured_score >= @score end |
#results ⇒ Object
34 35 36 |
# File 'lib/lighthouse/audit_service.rb', line 34 def results @results ||= JSON.parse(output) end |
#run_warnings ⇒ Object
30 31 32 |
# File 'lib/lighthouse/audit_service.rb', line 30 def run_warnings results['runWarnings'] end |