Sha256: 2c376099ef6cdf86cdde851ae46486f820828843b7cdda835800b352f8b3eece

Contents?: true

Size: 833 Bytes

Versions: 9

Compression:

Stored size: 833 Bytes

Contents

#
# short inspect method on all objects.
#
# "abcdefghijklmnopabcdefghijklmnopabcdefghijklmnopabcdefghijklmnop".insp
#    -> "abcdefghijklmnopabcdefghijk..."
# Model.find(1).insp 
#    -> "<Model#1>"

module Deprecation
  def self.quiet
    @quiet = true
    yield
  ensure
    @quiet = false
  end

  def self.seen
    @seen ||= {}
  end
  
  def self.report(msg, instead=nil)
    return if App.env == "production"
    return if @quiet
    return if seen[[msg, instead]]

    seen[[msg, instead]] = true
    
    msg = "#{msg} is deprecated"
    msg += "; use #{instead} instead" if instead
    msg += ". From\n\t" + caller[1,4].join("\n\t")
    STDERR.puts msg
  end
end

module Deprecation::Etest
  def test_report
    STDERR.expects(:puts)
    Deprecation.report "Hey"
    Deprecation.report "Hey"
  end
end if VEX_TEST == "base"

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
vex-0.3.3 lib/vex/base/deprecation.rb
vex-0.2.9 lib/vex/base/deprecation.rb
vex-0.2.8 lib/vex/base/deprecation.rb
vex-0.2.7 lib/vex/base/deprecation.rb
vex-0.2.6 lib/vex/base/deprecation.rb
vex-0.2.5 lib/vex/base/deprecation.rb
vex-0.2.2 lib/vex/base/deprecation.rb
vex-0.2.1 lib/vex/base/deprecation.rb
vex-0.2 lib/vex/base/deprecation.rb