Class: AuditService

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(url, audit, score) ⇒ AuditService

Returns a new instance of AuditService.



10
11
12
13
14
15
16
17
18
# 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
end

Instance Method Details

#measured_scoreObject



24
25
26
# File 'lib/lighthouse/audit_service.rb', line 24

def measured_score
  category['score'] * 100
end

#passing_score?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/lighthouse/audit_service.rb', line 20

def passing_score?
  measured_score >= @score
end

#run_warningsObject



28
29
30
# File 'lib/lighthouse/audit_service.rb', line 28

def run_warnings
  results['runWarnings']
end