Sha256: f65018d600f53cf667dfa8446da8645ce24f90d76a1764b42dacb48b1e89a314

Contents?: true

Size: 809 Bytes

Versions: 1

Compression:

Stored size: 809 Bytes

Contents

module StructuredWarnings
  module Kernel
    def warn(*args)
      first = args.shift
      if first.is_a? Class and first < Warning
        warning = first 
        message = args.shift

      elsif first.is_a? Warning
        warning = first.class
        message = first.message

      else
        warning = Warning
        message = first.to_s 
      end

      unless args.empty?
        raise ArgumentError, 
              "wrong number of arguments (#{args.size + 2} for 2)" 
      end

      if warning.active?
        output = Kernel.warner.format(warning, message, caller[1..-1])
        super(output) unless output.nil? or output.to_s.empty? 
      end
    end

    def self.warner
      Dynamic[:warner]
    end

  protected
    def structured_warn(warning, message)
      nil
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
structured_warnings-0.1.0 lib/structured_warnings/kernel.rb