Class: Maximus::Phantomas

Inherits:
Statistic show all
Defined in:
lib/maximus/statistics/phantomas.rb

Overview

Evaluate page performance

Since:

  • 0.1.0

Instance Attribute Summary

Attributes inherited from Statistic

#output

Instance Method Summary collapse

Methods inherited from Statistic

#initialize

Methods included from Helper

#discover_path, #edit_yaml, #file_count, #file_list, #is_middleman?, #is_rails?, #node_module_exists, #path_exists?, #prompt, #reporter_path, #root_dir, #truthy?

Constructor Details

This class inherits a constructor from Maximus::Statistic

Instance Method Details

#resultObject

Run phantomas through the command line

See Also:

Since:

  • 0.1.0



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/maximus/statistics/phantomas.rb', line 8

def result

  return if @settings[:phantomas].blank?

  node_module_exists('phantomjs', 'brew install')
  node_module_exists('phantomas')

  @path = @settings[:paths] if @path.blank?
  @domain = @config.domain

  # Phantomas doesn't actually skip the skip-modules defined in the config BUT here's to hoping for future support
  phantomas_cli = "phantomas --config=#{@settings[:phantomas]} "
  phantomas_cli += @config.is_dev? ? '--colors' : '--reporter=json:no-skip'
  phantomas_cli << " --proxy=#{@domain}" if @domain.include?('localhost')
  @path.is_a?(Hash) ? @path.each { |label, url| phantomas_by_url(url, phantomas_cli) } : phantomas_by_url(@path, phantomas_cli)
  @output
end