Module: NanDoc::SpecDoc::ParseTrace

Included in:
GenericAgent, TestCaseAgent
Defined in:
lib/nandoc/spec-doc/parse-trace.rb

Instance Method Summary collapse

Instance Method Details

#parse_traceRegexp

Returns enhanced regex that parses a stack trace line.

Returns:

  • (Regexp)

    enhanced regex that parses a stack trace line



8
9
10
11
12
13
14
15
# File 'lib/nandoc/spec-doc/parse-trace.rb', line 8

def parse_trace
  @parse_trace_re ||= begin
    NanDoc::Regexp.new(
      /\A(.*):(\d+)(?::in `([^']+)')?\Z/,
      :file, :line, :method
    )
  end
end

#parse_trace_assert(line) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/nandoc/spec-doc/parse-trace.rb', line 16

def parse_trace_assert line
  md = parse_trace.match(line) or
    fail("couldn't parse trace line: #{line}")
  h = md.to_hash
  /\A\d+\Z/ =~ h[:line] or fail("not line: #{h[:line]}.inspect")
  h[:line] = h[:line].to_i
  h
end