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
|
# File 'lib/active_samba_ldap/configuration.rb', line 10
def read(file)
require 'yaml'
require 'erb'
erb = ERB.new(File.read(file))
erb.filename = file
result = nil
begin
begin
result = YAML.load(erb.result)
unless result
raise InvalidConfigurationFormatError.new(file, "0",
"empty source")
end
rescue ArgumentError
if /syntax error on line (\d+), col (\d+): `(.*)'/ =~ $!.message
raise InvalidConfigurationFormatError.new(file, "#{$1}:#{$2}", $3)
else
raise
end
end
rescue InvalidConfigurationFormatError
raise
rescue Exception
file, location = $@.first.split(/:/, 2)
detail = "#{$!.class}: #{$!.message}"
raise InvalidConfigurationFormatError.new(file, location, detail)
end
result
end
|