blob: 931b639a26aefe5771925eddb116674e011cb0c7 (
plain)
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
|
# web/lib/config.rb
class TaginfoConfig
@@config = {}
def self.read
open(File.expand_path(File.dirname(__FILE__)) + '/../../../taginfo-config.json') do |file|
@@config = JSON.parse(file.gets(nil), { :create_additions => false })
end
end
def self.get(key, default=nil)
tree = @@config
key.split('.').each do |i|
tree = tree[i]
return default unless tree
end
return tree.nil? ? default : tree
end
# Config without anything that a security concious admin wouldn't want to
# be public. Currently everything that contains local paths is removed.
def self.sanitized_config
c = @@config
c['sources'] && c['sources'].delete('db')
c['logging'] && c['logging'].delete('directory')
c['tagstats'] && c['tagstats'].delete('cxxflags')
return c
end
end
|