Sha256: 8bcab80b6c95d013a8e3531eafac7438672783f010bdd26f207877f569a10eb3

Contents?: true

Size: 771 Bytes

Versions: 1

Compression:

Stored size: 771 Bytes

Contents

# The Warner class implements a very simple interface. It simply formats
# a warning, so it is more than just the message itself. This default
# warner uses a format comparable to warnings emitted by rb_warn including
# the place where the "thing that caused the warning" resides.
class StructuredWarnings::Warner
  #  Warner.new.format(StructuredWarning::DeprecationWarning, "more info..", caller)
  #     # => "demo.rb:5 : more info.. (StructuredWarning::DeprecationWarning)"
  def format(warning, message, stack)
    frame = stack.shift
    # This file contains the backwards compatibility code for Ruby 2.3 and
    # lower, let's skip it
    frame = stack.shift if frame.include? 'lib/structured_warnings/kernel.rb'
    "#{frame} : #{message} (#{warning})"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
structured_warnings-0.3.0 lib/structured_warnings/warner.rb