Hi, I'm sending the api diff script again (it's still gross and needs to
be rewired up to catch visibility diffs and singleton method diffs)
usage is still the same as it has been (first run it on MRI, then on JRuby)
Marcin
require 'enumerator'
require 'bigdecimal'
def each_object
exclude =
/YAML|Errno|ExceptionExtender|Java|NativeException|ConstantAlreadyExistsError|Fatal|Error/
ObjectSpace.each_object do |c|
if c.is_a? Module and not c.name =~ exclude
yield c
end
end
end
def write file_name
open(file_name,"w") do |f|
each_object do |c|
methods = c.instance_methods(false) +
c.private_instance_methods(false) +
c.protected_instance_methods(false)
f << "#{c.name},#{methods.map{|m|m + ',' +
c.instance_method(m).arity.to_s}.join(',')}\n"
end
end
end
def java?
RUBY_PLATFORM =~ /java/
end
def load file_name
classes = {}
open(file_name) do |f|
f.each_line do |l|
c,*ms = l.chop.split(',')
methods = {}
ms.each_slice(2){|m|methods[m.first] = m.last.to_i} # arghh...
map_cons would be usefull here
classes[c] = methods
end
end
classes
end
def run
write java? ? "objectlist_java" : "objectlist"
if java?
rc = load("objectlist")
jrc = load("objectlist_java")
compare(rc,jrc,"missing",true)
compare(jrc,rc,"extra")
end
end
def compare rcs,rcd,message,report_arities = false
rcs.each_pair do |cs,meths|
if clsd = rcd[cs]
meths.each_pair do |mths,aritys|
if arityd = clsd[mths]
puts "arity mismatch for Method: #{cs}##{mths} #{aritys} vs
#{arityd}" if aritys != arityd and report_arities
else
puts "#{message} Method: #{cs}##{mths}"
end
end
else
puts "#{message} Class: #{cs}"
end
end
end
run
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email