Color definitions for pretty printing Defined here because we need Global scope but makes sense to have them in the printer.rb file at least
Gllobal flag to turn OFF debugging across all files
Global flag to turn ON debugging across all files
Perform system check to see if we are able to use unix less for printing
# File lib/watson.rb, line 63 def check_less # Check if system has less (so we can print out to it to allow scrolling) # [todo] - Implement this scrolling thing inside watson with ncurses return system("which less > /dev/null 2>&1") end
Global debug print that prints based on local file DEBUG flag as well as GLOBAL debug flag
# File lib/watson.rb, line 45 def debug_print(msg) # [todo] - If input msg is a Hash, use pp to dump it # Print only if DEBUG flag of calling class is true OR # GLOBAL_DEBUG_ON of Watson module (defined above) is true # AND GLOBAL_DEBUG_OFF of Watson module (Defined above) is false # Sometimes we call debug_print from a static method (class << self) # and other times from a class method, and ::DEBUG is accessed differently # from a class vs object, so lets take care of that _DEBUG = (self.is_a? Class) ? self::DEBUG : self.class::DEBUG print "=> #{msg}" if ( (_DEBUG == true || GLOBAL_DEBUG_ON == true) && (GLOBAL_DEBUG_OFF == false)) end