Sha256: 5c9aaa6842b4fc8ce6ef3c5ed5d44ea5e82b71af05b82812c825c9d9b8fc0011

Contents?: true

Size: 841 Bytes

Versions: 3

Compression:

Stored size: 841 Bytes

Contents

module Inspector
  class ExceptionHound
    attr_accessor :message

    def initialize(error)
      self.message = find_message error
    end

    def find_message(error)
      error.to_s
    end

    def query
      undefined
      simple_nil
      demangle_instances

      message
    end

    private

    def undefined
      self.message = message.gsub "undefined local variable or method", "undefined"
    end

    def simple_nil
      self.message = message.gsub "nil:NilClass", "nil"
    end

    def demangle_instances
      self.message = regex_replace(message, /(#<.*>)/, /#<(.*):/)
    end

    def regex_replace(string, find, replace)
      if string.match find
        full = string.match(find)[0]
        simple = string.match(replace)[1]
        string.gsub full, simple
      else
        string
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gh-issues-inspector-0.5.2 lib/exception_hound.rb
gh-issues-inspector-0.5.1 lib/exception_hound.rb
gh-issues-inspector-0.5.0 lib/exception_hound.rb