Created
January 31, 2011 21:56
-
-
Save BrandonMathis/804908 to your computer and use it in GitHub Desktop.
JRuby Nokogiri generate CCOM type raketask
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
<?xml version="1.0" encoding="UTF-8"?> | |
<root> | |
<Entity xsi:type="EntityType"> | |
<GUID>c014e3c1-0fb2-012e-8f94-549a20e02a6a</GUID> | |
<Tag>Adapter Plate</Tag> | |
<Status>1</Status> | |
</Entity> | |
</root> |
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
# -- | |
# Will generate a series of MLoc EntityTypes for each define Type in the given FILE (one type per line) | |
# -- | |
desc "parse a FILE and generate a series of CCOM Types (of type TYPE) for each line and outputs into TARGET" | |
task :gen_type => :environment do | |
types = File.open("./samples/meas_loc_sorted").map { |line| line.chomp! } | |
builder = Nokogiri::XML::Builder.new do |xml| | |
xml.root do | |
types.each do |type| | |
xml.Entity "xsi:type" => ENV['TYPE'] do | |
xml.GUID UUID.generate | |
xml.Tag type | |
xml.Status "1" | |
end | |
end | |
end | |
end | |
File.open(File.join("samples", ENV['TARGET']), 'w') {|f| f.write(builder.to_xml(:indent => 2, :encoding => 'UTF-8'))} | |
end |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<root> | |
<Entity xsi:type="EntityType"> | |
<GUID>c014e3c1-0fb2-012e-8f94-549a20e02a6a</GUID><Tag>Adapter Plate</Tag><Status>1</Status> | |
</Entity> | |
</root> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment