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
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_scoreObject



26
27
28
# File 'lib/lighthouse/audit_service.rb', line 26

def measured_score
  category['score'] * 100
end

#passing_score?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/lighthouse/audit_service.rb', line 22

def passing_score?
  measured_score >= @score
end

#resultsObject



34
35
36
# File 'lib/lighthouse/audit_service.rb', line 34

def results
  @results ||= JSON.parse(output)
end

#run_warningsObject



30
31
32
# File 'lib/lighthouse/audit_service.rb', line 30

def run_warnings
  results['runWarnings']
end