Commit 843bd0ac authored by Jonathan Riddell's avatar Jonathan Riddell 🛶

save the file with pretty printing

parent 192875c2
......@@ -25,6 +25,7 @@ require 'optparse'
class MetaInfoUpdater
attr_accessor :filename
attr_accessor :doc
def initialize(filename)
@filename = filename
......@@ -32,6 +33,17 @@ class MetaInfoUpdater
def open_file
puts "Filename #{@filename}"
# TODO check file exists etc
@doc = File.open(@filename) { |f| Nokogiri::XML(f, &:noblanks) }
component = @doc.at_css("component")
releases = component.add_child("<releases><release version='1.0' date='today'/></releases>")
puts component.to_xml(:indent => 2)
end
def save_file
#File.write("#{@filename}.new", @doc.to_xml(:indent => 2))
f = File.open("#{@filename}.new", "w")
@doc.write_xml_to(f, {indent: 2})
end
end
......@@ -47,3 +59,4 @@ file_name = ARGV[0]
updater = MetaInfoUpdater.new(file_name)
updater.open_file
updater.save_file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment