Sha256: 6f70b007944f7d9893dd4e399e61e4f2a4d9747543c8cfd5f6f6d3b38c38c3a0
Contents?: true
Size: 1.1 KB
Versions: 3
Compression:
Stored size: 1.1 KB
Contents
# frozen_string_literal: true module Kernel rubygems_path = "#{__dir__}/" # Frames to be skipped start with this path. original_warn = instance_method(:warn) remove_method :warn class << self remove_method :warn end module_function define_method(:warn) {|*messages, **kw| unless uplevel = kw[:uplevel] if Gem.java_platform? && RUBY_VERSION < "3.1" return original_warn.bind(self).call(*messages) else return original_warn.bind(self).call(*messages, **kw) end end # Ensure `uplevel` fits a `long` uplevel, = [uplevel].pack("l!").unpack("l!") if uplevel >= 0 start = 0 while uplevel >= 0 loc, = caller_locations(start, 1) unless loc # No more backtrace start += uplevel break end start += 1 next unless path = loc.path unless path.start_with?(rubygems_path) || path.start_with?("<internal:") # Non-rubygems frames uplevel -= 1 end end kw[:uplevel] = start end original_warn.bind(self).call(*messages, **kw) } end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rubygems-update-3.4.22 | lib/rubygems/core_ext/kernel_warn.rb |
rubygems-update-3.4.21 | lib/rubygems/core_ext/kernel_warn.rb |
rubygems-update-3.4.20 | lib/rubygems/core_ext/kernel_warn.rb |