Sha256: edabed25002edf28ece5c0d408beeac546d3605fadcd3caee7caf2ae75b533dd
Contents?: true
Size: 930 Bytes
Versions: 3
Compression:
Stored size: 930 Bytes
Contents
module Uncruft module Warning DEPRECATION_PATTERN = /(deprecation|deprecated)/i.freeze def warn(str, *args) if str =~ DEPRECATION_PATTERN # rubocop:disable Performance/RegexpMatch message = strip_caller_info(str, caller_locations(1..1).first).strip ActiveSupport::Deprecation.warn(message) else super end end private def strip_caller_info(str, cloc) str.sub(cloc.to_s, '') # try full caller information first .gsub(/#{cloc.path}(:#{cloc.lineno})?:?\s*/, '') # try path with optional line end end end if Rails.env.development? || Rails.env.test? if defined?(Warning) Warning.prepend(Uncruft::Warning) Warning.singleton_class.prepend(Uncruft::Warning) end Kernel.prepend(Uncruft::Warning) Kernel.singleton_class.prepend(Uncruft::Warning) Object.prepend(Uncruft::Warning) Object.singleton_class.prepend(Uncruft::Warning) end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
uncruft-0.2.1 | lib/uncruft/warning.rb |
uncruft-0.2.0 | lib/uncruft/warning.rb |
uncruft-0.1.0 | lib/uncruft/warning.rb |