Sha256: 9997dd44b75cb7c0735b6a1ee6948a4fb07ffd09926c7c26ee079366ef2c669e

Contents?: true

Size: 607 Bytes

Versions: 2

Compression:

Stored size: 607 Bytes

Contents

module Captivus
  class Backtrace
    class Line
      PATTERN = /^(.+?):(\d+)(?::in `([^']+)')?$/

      def initialize(raw_line)
        if match_data = PATTERN.match(raw_line)
          @file = match_data[1]
          @number = match_data[2].to_i
          @method = match_data[3]
        else
          raise ArgumentError, "Unrecognized format: #{raw_line.inspect}"
        end
      end

      def as_json(*)
        hash = {'file' => file, 'number' => number}
        hash['method'] = method if method
        hash
      end

      private

      attr_reader :file, :number, :method
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
captivus-0.0.6 lib/captivus/backtrace/line.rb
captivus-0.0.5 lib/captivus/backtrace/line.rb