class Blab::Printer

Constants

DEFAULT_CLASS_NAME_WIDTH
DEFAULT_CODE_LINES_WIDTH
DEFAULT_EVENT_WIDTH
DEFAULT_FILE_LINES_WIDTH
DEFAULT_METHOD_NAME_WIDTH
DEFAULT_RU_MAXSS_WIDTH
DEFAULT_TIME_WIDTH

Attributes

config[R]
logger[R]

Public Class Methods

new(config, logger) click to toggle source
# File lib/blab/printer.rb, line 22
def initialize(config, logger)
  @config = config
  @logger = logger
end

Public Instance Methods

code_lines(options= {}) click to toggle source
# File lib/blab/printer.rb, line 50
def code_lines(options= {})
  file  = options[:file]
  line  = options[:line]
  width = options[:width] || DEFAULT_CODE_LINES_WIDTH
  [source_line(file, line).scan(/.{#{width}}|.+/), width]
end
file_lines(options = {}) click to toggle source
# File lib/blab/printer.rb, line 43
def file_lines(options = {})
  file  = options[:file]
  line  = options[:line]
  width = options[:width] || DEFAULT_FILE_LINES_WIDTH
  ["#{file}:#{line}".scan(/.{#{width}}|.+/), width]
end
files_map() click to toggle source
# File lib/blab/printer.rb, line 69
def files_map
  @files_map ||= Hash.new do |h, f|
    h[f] = File.readlines(f)
  end
end
print(options = {}) click to toggle source
reset_files() click to toggle source
# File lib/blab/printer.rb, line 65
def reset_files
  @files_map && @files_map.keys.each { |key| @files_map.delete(key) }
end
source_line(file, line) click to toggle source

TODO: show all relevant file-lines

# File lib/blab/printer.rb, line 76
def source_line(file, line)
  begin
    files_map[file][line - 1]
  rescue
    "source is unavailable"
  end
end