Top Level Namespace
- Extended by:
- HelperClasses::DPuts
- Includes:
- GetText, HelperClasses, HelperClasses::DPuts, WEBrick
Defined Under Namespace
Modules: PrintButton, QooxParser, QooxView, StorageHandler, VTListPane
Classes: Array, CSV, ConfigBase, ConfigBases, Date, Entities, Entity, Hash, ICC, Integer, LDAP, MakeSteps, MigrationVersions, Object, OpenPrint, Permission, RPCQooxdooHandler, RPCQooxdooPath, RPCQooxdooService, SQLite, Session, Sessions, Statics, StorageType, String, UploadFiles, Value, View, Welcome
Constant Summary
collapse
- QOOXVIEW_DIR =
QOOXVIEW_DIR=%x[ echo $PWD/#File.dirname(__FILE__)].chomp
File.dirname(__FILE__)
- DEBUG_LVL =
Unknown debug-level for recognition in ConfigBase
0.5
Instance Method Summary
collapse
Instance Method Details
#get_config(default, *path) ⇒ Object
56
57
58
|
# File 'lib/qooxview/config_yaml.rb', line 56
def get_config(default, *path)
get_config_rec(path, default)
end
|
#get_config_rec(path, default, config = $config) ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/qooxview/config_yaml.rb', line 60
def get_config_rec(path, default, config = $config)
if path.length == 0
return config
else
key = path.shift.to_sym
if config and config.has_key? key
return get_config_rec(path, default, config[key])
else
return default
end
end
end
|
#load_config_global(path = nil) ⇒ Object
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
|
# File 'lib/qooxview/config_yaml.rb', line 16
def load_config_global(path=nil)
if conf = search_up("#{$name.downcase}.conf", path)
dputs(3) { "Found configuration-file #{conf}" }
IO.readlines(conf).each { |l|
dputs(4) { "Reading line #{l}" }
next if l =~ /(^#|^\s*$)/
name, value =
case l
when /^\s*(.*?)="(.*?)".*$/
[$1, $2]
when /^\s*(.*?)=([^\s#]*)/
[$1, $2]
else
[nil, nil]
end
if name && value
dputs(3) { "Writing configuration _#{$1}_ = _#{$2}_" }
$config[$1.to_sym] = $2
end
}
end
unless defined?($data_dir)
$data_dir = $config[:DATA_DIR] || "/var/lib/#{$name.downcase}"
FileUtils.mkdir_p($data_dir)
end
unless defined?($config_file)
$config_file = File.join($data_dir, 'config.yaml')
end
end
|
#load_config_yaml(path = nil) ⇒ Object
47
48
49
50
51
52
53
54
|
# File 'lib/qooxview/config_yaml.rb', line 47
def load_config_yaml(path = nil)
if defined?($config_file)
file = path ? File.join(path, $config_file) : $config_file
if FileTest.exist?(file)
File.open(file) { |f| $config.merge!(YAML::load(f).to_sym) }
end
end
end
|
#search_up(name, dir = nil) ⇒ Object
Searches for name in every directory from ‘dir’ towards the root and returns the found filename. If nothing is found, it returns nil If ‘dir’ is nil, the directory of the running script is taken
8
9
10
11
12
13
14
|
# File 'lib/qooxview/config_yaml.rb', line 8
def search_up(name, dir = nil)
dir ||= File.realdirpath(File.dirname($0))
dputs(3){"Directory is #{dir}, searching #{name}"}
return File.join(dir, name) if File.exists?(File.join(dir, name))
return nil if File.realdirpath(dir) == '/'
search_up(name, File.realdirpath(File.join(dir, '..')))
end
|
#set_config(value, *path) ⇒ Object
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/qooxview/config_yaml.rb', line 73
def set_config(value, *path)
if path.length == 0
dputs(0) { "Error: empty path in #{caller.inspect}" }
else
config = $config
path[0...-1].each { |p|
dputs(4) { "Doing level #{p}" }
if !config.has_key? p
config[p] = {}
dputs(4) { "Added Hash to #{p} - #{$config.inspect}" }
end
config = config[p]
}
config[path.last] = value
dputs(4) { "config is #{config.inspect} - $config is #{$config.inspect}" }
end
end
|