Class: Maximus::Phantomas

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

Overview

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

#check_default_config_path, #edit_yaml, #file_count, #file_list, #is_rails?, #lines_added_to_range, #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

Phantomas evaluates page performance with phantomjs and node

See Also:

Since:

  • 0.1.0


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# 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}"
  @path.is_a?(Hash) ? @path.each { |label, url| phantomas_by_url(url, phantomas_cli) } : phantomas_by_url(@path, phantomas_cli)
  @@config.destroy_temp('phantomas')
  @output
end