I'm a bit lost here as to why my rake
task will not create the desired XML file, however it works fine when I have the method build_xml
in an .rb
file.
require 'rubygems'
require 'nokogiri'
require 'open-uri'
namespace :xml do
desc "xml build test"
task :xml_build => :environment do
build_xml
end
end
def build_xml
# build xml docoument
builder = Nokogiri::XML::Builder.new do |xml|
xml.root {
xml.location {
xml.value "test"
}
}
end
File.open("test.xml", 'w') {|f| f.write(builder.to_xml) }
end