/usr/lib/ruby/vendor_ruby/introspection/snapshot.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 | require "introspection/receivers"
require "metaclass"
module Introspection
class Snapshot
attr_reader :methods
def initialize(object)
@methods = (object.receivers rescue []).map do |receiver|
[:public, :protected, :private].map do |visibility|
query_method = "#{visibility}_instance_methods"
receiver.send(query_method, false).map do |method|
unbound_method = receiver.instance_method(method)
if unbound_method.owner.equal?(receiver)
Method.new(unbound_method, visibility)
end
end.compact
end
end.flatten
end
def diff(other)
{
:added => other.methods - methods,
:removed => methods - other.methods
}
end
def changed?(other)
diff(other).values.flatten.any?
end
end
end
|