-
-
Save nolili/1979c6039242b81d47c5c8bd78f1b846 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