Skip to content

Instantly share code, notes, and snippets.

@amacdougall
Created September 20, 2011 17:35
Show Gist options
  • Save amacdougall/1229748 to your computer and use it in GitHub Desktop.
Save amacdougall/1229748 to your computer and use it in GitHub Desktop.
task :production_deploy do
xpaths = {
:debug => "//compiler/debug",
:debug_define => "//compiler/define[name='CONFIG::debug']"
}
# read config xml and set to production mode, storing old values
xml = Nokogiri::XML File.open("src/Main-config.xml")
debug_node = xml.at_xpath xpaths[:debug]
debug_define_node = xml.at_xpath xpaths[:debug_define_node]
old_values = {
:debug => debug_node.content,
:debug_define => debug_define_node.content
}
debug_node.content = "false"
debug_define_node.content = "false"
File.open("src/Main-config.xml", "w") {|f| f.write xml.to_xml}
# do the compile/deploy
Rake::Task["deploy"].invoke
# restore old values
debug_node.content = old_values[:debug]
debug_define_node.content = old_values[:debug_define_node]
File.open("src/Main-config.xml", "w") {|f| f.write xml.to_xml}
end
@amacdougall
Copy link
Author

Yeah, there is no xpaths[:debug_define_node], so that was all me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment