Sha256: c8bb73374fc8bfa7a16f1ecd37d9aaa20e084e5f17ee1e8e88d99a5062f5c1a6
Contents?: true
Size: 1.41 KB
Versions: 3
Compression:
Stored size: 1.41 KB
Contents
class TraceTree class PointsMarkdownTable HEADERS = [:event, :defined_class, :method_id, :frame_env, :path, :lineno, :thread, :return_value] COL_SEPERATOR = '|' HEADER_BOTTOM = '-' NEWLINE = "\n" RETURN = /return/ LT_RAW = /</ LT_ESC = '<' GT_RAW= />/ GT_ESC = '>' COL_RAW = '|' COL_ESC = '|' def initialize(points) @points = points end def to_s @buffer = [] generate_headers generate_rows @buffer.join end def generate_headers HEADERS.each{ |h| @buffer << COL_SEPERATOR << h } @buffer << COL_SEPERATOR @buffer << NEWLINE HEADERS.each{ |h| @buffer << COL_SEPERATOR << HEADER_BOTTOM } end_row end def generate_rows @points.each do |point| point_to_row(point.event) point_to_row(point.defined_class) point_to_row(point.method_id) point_to_row(point.thread? ? nil : point.frame_env) point_to_row(point.path) point_to_row(point.lineno) point_to_row(point.thread) point_to_row(point.event =~ RETURN ? point.return_value : nil) end_row end end def end_row @buffer << COL_SEPERATOR << NEWLINE end def point_to_row(info) info = info.to_s.gsub(LT_RAW, LT_ESC) info.gsub!(GT_RAW, GT_ESC) info.gsub!(COL_RAW, COL_ESC) @buffer << COL_SEPERATOR << info end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
trace_tree-0.3.6 | lib/trace_tree/points_markdown_table.rb |
trace_tree-0.3.5 | lib/trace_tree/points_markdown_table.rb |
trace_tree-0.3.4 | lib/trace_tree/points_markdown_table.rb |