Class: Maximus::Statistic

Inherits:
Object
  • Object
show all
Includes:
Helper
Defined in:
lib/maximus/statistic.rb

Overview

Parent class for all statistics (inherited by children)

Since:

  • 0.1.0

Direct Known Subclasses

Phantomas, Stylestats, Wraith

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#initialize(opts = {}) ⇒ void

Gather info about how the code performs

All defined statistics require a “result” method

end

Inherits settings from Config#initialize

Examples:

the result method in the child class

def result
  @path ||= 'path/or/**/glob/to/files''
  stat_data = JSON.parse(`some-command-line-stat-runner`)
  @output

Parameters:

  • opts (Hash) (defaults to: {})

    ({}) options passed directly to statistic

  • file_paths (Hash)

    a customizable set of options

Options Hash (opts):

  • :config (Config object)

    custom Maximus::Config object

See Also:

Since:

  • 0.1.0



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/maximus/statistic.rb', line 31

def initialize(opts = {})

  @config = opts[:config] || Maximus::Config.new(opts)
  @settings = @config.settings

  @path = opts[:file_paths] || @settings[:file_paths]

  @output = {}

  # This is different from lints
  #   A new stat is run per file or URL, so they should be stored in a child
  #   A lint just has one execution, so it's data can be stored directly in @output
  @output[:statistics] = {}
end

Instance Attribute Details

#outputObject

Since:

  • 0.1.0



7
8
9
# File 'lib/maximus/statistic.rb', line 7

def output
  @output
end