Class: Maximus::Statistic

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

Overview

Since:

  • 0.1.0

Direct Known Subclasses

Phantomas, Stylestats, Wraith

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#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

Since:

  • 0.1.0


26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/maximus/statistic.rb', line 26

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


5
6
7
# File 'lib/maximus/statistic.rb', line 5

def output
  @output
end