Last active
May 6, 2016 04:00
-
-
Save laiso/2b198c81cb49fd00e3f033d040c51aa7 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env ruby | |
# -*- coding: utf-8 -*- | |
require 'nokogiri' | |
path = ARGV.shift | |
doc = Nokogiri::XML(File.open(path)) | |
doc.xpath("/database/object").each do |object| | |
o = object.clone | |
o.children.each do |element| | |
if element.attribute("name")&.value == "sourcename" | |
entity = element.child.text | |
o.add_child("<attribute name=\"migrationpolicyclassname\" type=\"string\">#{entity}To#{entity}MigrationPolicy</attribute>") | |
end | |
end | |
object.replace(o) | |
end | |
doc.write_xml_to(File.open(File.basename(path), "w")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment