Created
March 21, 2012 12:10
-
-
Save mxrguspxrt/2146524 to your computer and use it in GitHub Desktop.
Compare methods in different classes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def digest array | |
Digest::MD5.hexdigest array.to_s | |
end | |
def write file, array | |
File.open(file, 'w') { |f| f.write array.sort.to_json } | |
end | |
def read file | |
File.open(file, 'r') { |f| JSON.parse(f.read) } | |
end | |
def compare a, b | |
puts "count: #{a.count} #{b.count}" | |
puts "MD5s: #{digest(a)} #{digest(b)}" | |
if digest(a) != digest(b) | |
puts "Missing from A: " + b.select { |i| !a.include? i }.to_s | |
puts "Missing from B: " + a.select { |i| !b.include? i }.to_s | |
end | |
end | |
branch = 'liii_modularize' | |
klass = Liii | |
write "/tmp/#{klass.name}.methods.#{branch}", klass.methods | |
write "/tmp/#{klass.name}.new.methods.#{branch}", klass.new.methods | |
# comparing | |
branch_a = 'master' | |
branch_b = 'liii_modularize' | |
compare read("/tmp/#{klass.name}.methods.#{branch_a}"), read("/tmp/#{klass.name}.methods.#{branch_b}") | |
compare read("/tmp/#{klass.name}.new.methods.#{branch_a}"), read("/tmp/#{klass.name}.new.methods.#{branch_b}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment