Sha256: 163d85d784fb63745fb40e0721affa3afe384113849e347843c0b5bf8215d5aa

Contents?: true

Size: 1.12 KB

Versions: 8

Compression:

Stored size: 1.12 KB

Contents

module Lighthouse
  module Preferences
    class Error < StandardError; end
    class << self
      attr_writer :remote_debugging_port,
                  :lighthouse_cli,
                  :runner,
                  :lighthouse_options,
                  :chrome_flags
      attr_reader :remote_debugging_port

      def lighthouse_cli
        @lighthouse_cli ||= get_lighthouse_cli
      end

      def runner
        @runner ||= proc { |cmd| `#{cmd}` }
      end

      def lighthouse_options
        return unless @lighthouse_options
        return @lighthouse_options unless @lighthouse_options.is_a?(Array)

        @lighthouse_options.map { |f| "--#{f}" }.join(' ')
      end

      def chrome_flags
        return unless @chrome_flags
        return @chrome_flags unless @chrome_flags.is_a?(Array)

        @chrome_flags.map { |f| "--#{f}" }.join(' ')
      end

      private

      def get_lighthouse_cli
        system("npm install -g lighthouse") unless File.exist?(lighthouse_bin_locator)
        lighthouse_bin_locator
      end

      def lighthouse_bin_locator
        `which lighthouse`.chomp("\n")
      end

    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
lighthouse-ruby-0.1.8 lib/lighthouse/preferences.rb
lighthouse-ruby-0.1.6 lib/lighthouse/preferences.rb
lighthouse-ruby-0.1.5 lib/lighthouse/preferences.rb
lighthouse-ruby-0.1.4 lib/lighthouse/preferences.rb
lighthouse-ruby-0.1.3 lib/lighthouse/preferences.rb
lighthouse-ruby-0.1.2 lib/lighthouse/preferences.rb
lighthouse-ruby-0.1.1 lib/lighthouse/preferences.rb
lighthouse-ruby-0.1.0 lib/lighthouse/preferences.rb