-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttpd_config.rb
More file actions
72 lines (61 loc) · 1.71 KB
/
httpd_config.rb
File metadata and controls
72 lines (61 loc) · 1.71 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#Child of ConfigFile that Parses, stores and hashes values from httpdconfig file
require_relative 'config_file'
class HttpdConfig < ConfigFile
attr_reader :httpdconfig_hash
def load
super
process_lines
end
def process_lines
@httpdconfig_hash = {}
#Check each line to see if there's more than 3 elements(ie Script Alias)
#If so, store that information into a hash of hashes
@lines.each do |conf_line|
if conf_line.length < 3
httpdconfig_hash[conf_line[0]] = conf_line[1].gsub(/"/, "")
else
if httpdconfig_hash.has_key?(conf_line[0])
httpdconfig_hash[conf_line[0]][conf_line[1]] = conf_line[2].gsub(/"/, "")
else
httpdconfig_hash[conf_line[0]] = {conf_line[1] => conf_line[2].gsub(/"/, "")}
end
end
end
end
# returns values from server root
def server_root
@httpdconfig_hash["ServerRoot"]
end
#returns documentroot values
def document_root
@httpdconfig_hash["DocumentRoot"]
end
#returns listen values
def listen
@httpdconfig_hash["Listen"]
end
#returns logfile values
def log_file
@httpdconfig_hash["LogFile"]
end
def script_alias
@httpdconfig_hash["ScriptAlias"]
end
#return an hash of alias directories
def alias
@httpdconfig_hash["Alias"]
end
def access_file_name
@httpdconfig_hash["AccessFileName"]
end
def directory_index
@httpdconfig_hash["DirectoryIndex"]
end
def script_alias_path(directory)
@httpdconfig_hash["ScriptAlias"] != [] ? @httpdconfig_hash["ScriptAlias"][directory] : nil
end
#return an alias path given an directory
def alias_path(directory)
@httpdconfig_hash["Alias"] != [] ? @httpdconfig_hash["Alias"][directory] : nil
end
end