Sha256: a9b8c1768fcd05a91a445055a3cdc2de4bc1c56aa412bab7ed04841ba8936697

Contents?: true

Size: 1.21 KB

Versions: 2

Compression:

Stored size: 1.21 KB

Contents

require 'hashie'

require 'raven/interfaces'

module Raven

  class StacktraceInterface < Interface

    name 'sentry.interfaces.Stacktrace'
    property :frames, :default => []

    def to_hash
      data = super
      data['frames'] = data['frames'].map{|frame| frame.to_hash}
      data
    end

    def frame(attributes=nil, &block)
      Frame.new(attributes, &block)
    end

    # Not actually an interface, but I want to use the same style
    class Frame < Interface
      property :abs_path
      property :filename, :required => true
      property :function
      property :vars, :default => {}
      property :pre_context, :default => []
      property :post_context, :default => []
      property :context_line
      property :lineno, :required => true

      def to_hash
        data = super
        data.delete('vars') unless self.vars && !self.vars.empty?
        data.delete('pre_context') unless self.pre_context && !self.pre_context.empty?
        data.delete('post_context') unless self.post_context && !self.post_context.empty?
        data.delete('context_line') unless self.context_line && !self.context_line.empty?
        data
      end
    end

  end

  register_interface :stack_trace => StacktraceInterface

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sentry-raven-0.2 lib/raven/interfaces/stack_trace.rb
sentry-raven-0.1 lib/raven/interfaces/stack_trace.rb