module Lighthouse::Preferences

Attributes

chrome_flags[W]
lighthouse_cli[W]
lighthouse_options[W]
remote_debugging_port[RW]
runner[W]

Public Class Methods

chrome_flags() click to toggle source
# File lib/lighthouse/preferences.rb, line 27
def chrome_flags
  return unless @chrome_flags
  return @chrome_flags unless @chrome_flags.is_a?(Array)

  @chrome_flags.map { |f| "--#{f}" }.join(' ')
end
lighthouse_cli() click to toggle source
# File lib/lighthouse/preferences.rb, line 12
def lighthouse_cli
  @lighthouse_cli ||= get_lighthouse_cli
end
lighthouse_options() click to toggle source
# File lib/lighthouse/preferences.rb, line 20
def lighthouse_options
  return unless @lighthouse_options
  return @lighthouse_options unless @lighthouse_options.is_a?(Array)

  @lighthouse_options.map { |f| "--#{f}" }.join(' ')
end
runner() click to toggle source
# File lib/lighthouse/preferences.rb, line 16
def runner
  @runner ||= proc { |cmd| `#{cmd}` }
end

Private Class Methods

get_lighthouse_cli() click to toggle source
# File lib/lighthouse/preferences.rb, line 36
def get_lighthouse_cli
  system("npm install -g lighthouse") unless File.exist?(lighthouse_bin_locator)
  lighthouse_bin_locator
end
lighthouse_bin_locator() click to toggle source
# File lib/lighthouse/preferences.rb, line 41
def lighthouse_bin_locator
  `which lighthouse`.chomp("\n")
end