Sha256: 54747c9dd0dd9b50d0ecedf65e99cac49c2ac1cce14cb65f4f08f052edd07de4

Contents?: true

Size: 976 Bytes

Versions: 2

Compression:

Stored size: 976 Bytes

Contents

require 'rubygems'

class OperaWatir::Exceptions::DeprecationException < OperaWatir::Exceptions::OperaWatirException
  
  def initialize(desc, fix, trace)
    @desc, @fix = desc, fix
    set_backtrace clean_backtrace(trace)
  end
  
  def message
    "DEPRECATION: #{@desc}\n  #{@fix}"
  end

private

  LIB_PATHS = [File.expand_path('../../../', __FILE__)] + Gem.all_load_paths

  def clean_backtrace(trace)
    trace.reject do |line|
      LIB_PATHS.any? do |lib_path|
        line.include?(lib_path)
      end || line.split(':').first == ''
    end
  end
  
end

module OperaWatir
  module Compat
    module Deprecation
      
      def deprecation(desc, fix)
        warn OperaWatir::Exceptions::DeprecationException.new(desc, fix, caller).message
      end
  
      def deprecation!(desc, fix)
        raise OperaWatir::Exceptions::DeprecationException.new(desc, fix, caller)
      end
      
    end
  end
end

class Object
  include OperaWatir::Compat::Deprecation
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
operawatir-0.3.2-jruby lib/operawatir/compat/deprecation.rb
operawatir-0.3-jruby lib/operawatir/compat/deprecation.rb