-
Notifications
You must be signed in to change notification settings - Fork 93
/
change_app_id.rb
executable file
·31 lines (26 loc) · 1.05 KB
/
change_app_id.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env ruby
require 'rexml/document'
def rename(app_id = "quantifiedself")
server_name = app_id + ".appspot.com"
# strings resource file update
file = File.read("Paco/res/values/strings.xml")
xml = REXML::Document.new(file)
server = xml.elements["resources"].elements.find {|e| e.attributes["name"] == "server" }
server.text = server_name
about_web_url = xml.elements["resources"].elements.find {|e| e.attributes["name"] == "about_weburl" }
about_web_url.text = server_name + "/Main.html"
file = File.open("Paco/res/values/strings.xml", 'w+') { |f| f.puts xml }
# server appid update
file = File.read("Paco-Server/war/WEB-INF/appengine-web.xml")
xml = REXML::Document.new(file)
current_server_app_id = xml.elements["appengine-web-app"].elements["application"]
xml.elements["appengine-web-app"].elements["application"].text = app_id
file = File.open("Paco-Server/war/WEB-INF/appengine-web.xml", 'w+') { |f| f. puts xml }
end
if __FILE__ == $0
if ARGV.length == 0
puts "need an appid name"
else
rename(ARGV[0])
end
end