-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinit.rb
51 lines (42 loc) · 1.05 KB
/
init.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
require 'rake'
require 'rake/testtask'
require 'fileutils'
require 'rubygems'
require 'log4r'
require 'log4r/yamlconfigurator'
require 'log4r/outputter/datefileoutputter'
include Log4r
def log_config(conf)
cfg = YamlConfigurator
cfg.load_yaml_file("./conf/#{conf}/log4r.yml")
end
ARGV.each do |arg|
[Regexp.new("--(.*)=(.*)"), Regexp.new("-(.*)=(.*)")].each do |r|
m = arg.match(r)
if (m!=nil)
puts "#{m[1]}, #{m[2]}"
ENV[m[1]] = m[2]
end
end
end
def from_env(long, short, default)
res = default
if (ENV[long])
res = ENV[long]
elsif (ENV[short])
res = ENV[short]
end
res
end
def oldlocation(str)
return "./#{str}"
end
$LOAD_PATH << oldlocation("./src")
$LOAD_PATH << oldlocation("./src/gui")
$LOAD_PATH << oldlocation("./src/plugins/core")
FileUtils.mkdir_p("logs")
log_config("dev")
adventure_name = from_env("adventure", "a", "foobar")
level_name = from_env("level", "l", nil)
require oldlocation("src/gui/gui")
play(:adventure_name => adventure_name, :level_name => level_name, :prefix => oldlocation("."))