OSDN Git Service

imported from subversion repository
[xerial/xerial-core.git] / script / generateContext.rb
1 \r
2 # This script generates webapp/META-INF/context.xml\r
3 # > ruby generateContext.rb (template file) (path to the config file) (docBase) (application path) \r
4 \r
5 templateFile = ARGV[0] \r
6 configFile = ARGV[1] || "ModernSCMD.config"\r
7 docBase = ARGV[2] || "ModernSCMD.war"\r
8 applicationPath = ARGV[3] || "/ModernSCMD"\r
9 \r
10 \r
11 if !(File.file? templateFile)\r
12   puts "#{templateFile} doesn't exist"\r
13   exit\r
14 end\r
15 \r
16 replacement =[\r
17   [/\$\{docbase\}/i, docBase],\r
18   [/\$\{application\.path\}/i, applicationPath],\r
19   [/\$\{config\.file\}/i, configFile]\r
20 ]\r
21 \r
22 open(templateFile, 'r').each { |l|\r
23   replacement.each { |pattern, var|\r
24     l.gsub!(pattern, var)\r
25   }\r
26   puts l\r
27 }\r