Sha256: ed34cdea0fa45be0ab53e08559c106b8a171e03ff7fbf51c2f7c7ca75f257bea

Contents?: true

Size: 585 Bytes

Versions: 26

Compression:

Stored size: 585 Bytes

Contents

module Kernel

  # Like #warn produces the current line number as well.
  #
  #   warn_with_line("You have been warned.")
  #
  # _produces_
  #
  #   3: Warning: You have been warned.
  #
  # Note that this method depends on the output of #caller.
  def warn_with_line(msg="", fulltrace=nil)
    trace = caller(1)
    where = trace[0].sub(/:in.*/,'')
    STDERR.puts "#{where}: Warning: #{msg}"
    STDERR.puts trace.map { |t| "\tfrom #{t}" } if fulltrace
  end

end


#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |_
#   |_|\___||___/\__|
#

# TODO

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
facets-0.9.0 lib/nano/kernel/warn_with_line.rb
facets-1.0.0 lib/facet/kernel/warn_with_line.rb
facets-1.0.3 packages/core/lib/facet/kernel/warn_with_line.rb
facets-1.2.1 lib/facets/core/kernel/warn_with_line.rb
facets-1.2.0 lib/facets/core/kernel/warn_with_line.rb
facets-1.3.0 lib/facets/core/kernel/warn_with_line.rb
facets-1.1.0 lib/facet/kernel/warn_with_line.rb
facets-1.3.2 lib/facets/core/kernel/warn_with_line.rb
facets-1.3.1 lib/facets/core/kernel/warn_with_line.rb
facets-1.3.3 lib/facets/core/kernel/warn_with_line.rb
facets-1.4.2 lib/facets/core/kernel/warn_with_line.rb
facets-1.4.0 lib/facets/core/kernel/warn_with_line.rb
facets-1.4.1 lib/facets/core/kernel/warn_with_line.rb
facets-1.4.3 lib/facets/core/kernel/warn_with_line.rb
facets-1.4.4 lib/facets/core/kernel/warn_with_line.rb
facets-1.4.5 lib/facets/core/kernel/warn_with_line.rb
facets-1.7.0 lib/facets/core/kernel/warn_with_line.rb
facets-1.7.30 lib/facets/core/kernel/warn_with_line.rb
facets-1.7.38 lib/facets/core/kernel/warn_with_line.rb
facets-1.7.46 lib/facets/core/kernel/warn_with_line.rb