Module: WhoCalledMe

Defined in:
lib/who_called_me/who_called_me.rb,
lib/who_called_me/who_called_me.rb,
lib/who_called_me/utils/file_utils.rb,
lib/who_called_me/utils/array_utils.rb,
lib/who_called_me/utils/trace_utils.rb,
lib/who_called_me/utils/colour_utils.rb,
lib/who_called_me/utils/string_utils.rb,
lib/who_called_me/utils/code_lines_utils.rb

Defined Under Namespace

Modules: StringUtils, Utils

Constant Summary collapse

@@_accumulator =
Accumulator.new
@@__disable_puts =
false

Class Method Summary collapse

Class Method Details

._recorded_calls_data(options = {}) ⇒ Object



60
61
62
63
64
# File 'lib/who_called_me/who_called_me.rb', line 60

def self._recorded_calls_data(options={})
  options[:only_top] ?
    accumulator.data_only_top :
    accumulator.data
end

.accumulatorObject



49
# File 'lib/who_called_me/who_called_me.rb', line 49

def self.accumulator  ; @@_accumulator           end

.disable_putsObject



51
# File 'lib/who_called_me/who_called_me.rb', line 51

def self.disable_puts ; @@__disable_puts = true  end

.enable_putsObject



52
# File 'lib/who_called_me/who_called_me.rb', line 52

def self.enable_puts  ; @@__disable_puts = false end

.puts_all_formatted_tracesObject



2
3
4
5
6
7
8
9
10
11
# File 'lib/who_called_me/who_called_me.rb', line 2

def self.puts_all_formatted_traces
  return if _recorded_calls_data.empty?
  return if @@__disable_puts
  @processed_first_lines = []
  _recorded_calls_data.keys.each do |key|
    _recorded_calls_data[key].each do |trace|
       puts formatted_trace(trace, @processed_first_lines).join("\n")
    end
  end
end

.record_i_was_called(key = :all, nof_internal_methods_to_skim = 1+1) ⇒ Object

this + _fulltrace



54
55
56
57
58
# File 'lib/who_called_me/who_called_me.rb', line 54

def self.record_i_was_called(key=:all, nof_internal_methods_to_skim=1+1) # this + _fulltrace
  trace = first_elements_with_common_prefix(fulltrace, 1)
  trace = trace[nof_internal_methods_to_skim..-1]
  accumulator.record_trace(key, trace)
end

.reset_accumulator_for_next_testObject



72
73
74
# File 'lib/who_called_me/who_called_me.rb', line 72

def self.reset_accumulator_for_next_test
  @@_accumulator ||= Accumulator.new
end

.reset_for_next_testObject

used by tests only



67
68
69
70
# File 'lib/who_called_me/who_called_me.rb', line 67

def self.reset_for_next_test
  reset_accumulator_for_next_test
  @@__disable_puts          = false
end