Class: Minitest::Heat::Map

Inherits:
Object
  • Object
show all
Defined in:
lib/minitest/heat/map.rb

Overview

Structured approach to collecting the locations of issues for generating a heat map

Constant Summary collapse

MAXIMUM_FILES_TO_SHOW =
5

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMap

Returns a new instance of Map.



11
12
13
# File 'lib/minitest/heat/map.rb', line 11

def initialize
  @hits = {}
end

Instance Attribute Details

#hitsObject (readonly)

Returns the value of attribute hits.



9
10
11
# File 'lib/minitest/heat/map.rb', line 9

def hits
  @hits
end

Instance Method Details

#add(pathname, line_number, type, backtrace: []) ⇒ void

This method returns an undefined value.

Records a hit to the list of files and issue types

Parameters:

  • filename (String)

    the unique path and file name for recordings hits

  • line_number (Integer)

    the line number where the issue was encountered

  • type (Symbol)

    the type of issue that was encountered (i.e. :failure, :error, etc.)



21
22
23
24
# File 'lib/minitest/heat/map.rb', line 21

def add(pathname, line_number, type, backtrace: [])
  @hits[pathname.to_s] ||= Hit.new(pathname)
  @hits[pathname.to_s].log(type.to_sym, line_number, backtrace: backtrace)
end

#file_hitsArray

Returns a subset of affected files to keep the list from being overwhelming

Returns:

  • (Array)

    the list of files and the line numbers for each encountered issue type



29
30
31
# File 'lib/minitest/heat/map.rb', line 29

def file_hits
  hot_files.take(MAXIMUM_FILES_TO_SHOW)
end