/usr/lib/ruby/vendor_ruby/introspection/change_detector.rb is in ruby-introspection 0.0.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | require "introspection"
require "instantiator"
before_class_snapshots = {}
before_instance_snapshots = {}
ObjectSpace.each_object do |object|
if Class === object
next if Instantiator.unsupported_class?(object)
object.instantiate
end
end
ObjectSpace.each_object do |object|
if Class === object
next if Instantiator.unsupported_class?(object)
before_class_snapshots[object] = Introspection::Snapshot.new(object)
before_instance_snapshots[object] = Introspection::Snapshot.new(object.instantiate)
end
end
class String
def foo
end
def self.bar
end
end
after_class_snapshots = {}
after_instance_snapshots = {}
ObjectSpace.each_object do |object|
if Class === object
next if Instantiator.unsupported_class?(object)
after_class_snapshots[object] = Introspection::Snapshot.new(object)
after_instance_snapshots[object] = Introspection::Snapshot.new(object.instantiate)
end
end
before_instance_snapshots.each_key do |key|
if after_instance_snapshots[key]
if before_instance_snapshots[key].changed?(after_instance_snapshots[key])
p [key, :instance_method, before_instance_snapshots[key].diff(after_instance_snapshots[key])]
end
end
end
before_class_snapshots.each_key do |key|
if after_class_snapshots[key]
if before_class_snapshots[key].changed?(after_class_snapshots[key])
p [key, :class_method, before_class_snapshots[key].diff(after_class_snapshots[key])]
end
end
end
# => [String, :instance_method, {:removed=>[], :added=>[String#foo (public)]}]
# => [String, :class_method, {:removed=>[], :added=>[#<Class:String>#bar (public)]}]
|