Skip to content

Instantly share code, notes, and snippets.

@alexvollmer
Created August 17, 2010 17:42
Show Gist options
  • Save alexvollmer/531053 to your computer and use it in GitHub Desktop.
Save alexvollmer/531053 to your computer and use it in GitHub Desktop.
#!/usr/bin/env macruby -wKU
framework 'CoreData'
def dump_mom(mom_path, out)
mom = NSManagedObjectModel.alloc.initWithContentsOfURL(mom_path)
mom.entities.sort_by {|e| e.name}.each do |entity|
out.puts "-" * 80
out.puts entity.name
entity.attributesByName.keys.sort.each do |k|
v = entity.attributesByName[k]
out.puts "\t#{k}"
out.puts "\t\ttype=#{v.attributeType}"
out.puts "\t\tdefault=#{v.defaultValue}"
out.puts "\t\thash=#{v.versionHash.description}"
end
end
end
ARGV.each do |momd|
mom_path = NSURL.fileURLWithPath(momd)
puts mom_path.absoluteString
dump_mom(mom_path, STDOUT)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment