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
|
# File 'lib/camping_boot.rb', line 6
def self.boot(conf, *apps)
unless conf.kind_of? OpenStruct
apps.unshift conf
conf = OpenStruct.new
end
if home = ENV['HOME'] conf.db = File.join(home, '.camping.db')
conf.rc = File.join(home, '.campingrc')
elsif home = ENV['APPDATA'] conf.db = File.join(home, 'Camping.db')
conf.rc = File.join(home, 'Campingrc')
end
if conf.rc and File.exists?( conf.rc )
YAML.load_file(conf.rc).each do |k,v|
conf.send("#{k}=", v)
end
end
unless conf.database
unless conf.db
puts "!! No home directory found. Please specify a database file, see --help."; exit
end
conf.database = {:adapter => 'sqlite3', :database => conf.db}
end
apps = apps.inject([]) do |apps, script|
if File.directory? script
apps.push(*Dir[File.join(script, '*.rb')])
else
apps << script
end
end
Camping::Reloader.database = conf.database
Camping::Reloader.log = conf.log
apps.map! { |script| Camping::Reloader.new(script) }
return apps
end
|