Module: Parlour::Debugging

Extended by:
T::Sig
Defined in:
lib/parlour/debugging.rb

Overview

Contains methods to enable debugging facilities for Parlour.

Defined Under Namespace

Classes: Tree

Class Method Summary collapse

Class Method Details

.debug_mode=(value) ⇒ Object



16
17
18
# File 'lib/parlour/debugging.rb', line 16

def self.debug_mode=(value)
  @debug_mode = value
end

.debug_mode?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/parlour/debugging.rb', line 24

def self.debug_mode?
  @debug_mode
end

.debug_puts(object, message) ⇒ Object



36
37
38
39
40
41
# File 'lib/parlour/debugging.rb', line 36

def self.debug_puts(object, message)
  return unless debug_mode?
  name = Rainbow("#{name_for_debug_caller(object)}: ").magenta.bright.bold
  prefix = Rainbow("Parlour debug: ").blue.bright.bold
  puts prefix + name + message
end

.name_for_debug_caller(object) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/parlour/debugging.rb', line 50

def self.name_for_debug_caller(object)
  case object
  when ConflictResolver
    "conflict resolver"
  when RbiGenerator
    "RBI generator"
  else
    if ((object < Plugin) rescue false)
      return "plugin #{object.name}"
    end
    object.class.name
  end
end