class ApacheVhostsParser::Config
Attributes
vhosts[R]
Public Class Methods
new(tag)
click to toggle source
# File lib/apache-vhosts-parser.rb, line 7 def initialize tag @tag = tag @vhosts = @tag[:children].keep_if do |child| child[:name] == 'virtualhost' end.each do |vhost| vhost[:addresses] = vhost[:arguments].map do |hp| host, port = hp.split(':') { host: host, port: port ? port.to_i : nil } end (vhost[:children] || []).each do |nested| if nested[:type] == 'directive' case nested[:name] when 'servername' vhost[:server_name] = nested[:arguments].first when 'documentroot' vhost[:document_root] = nested[:arguments].first end end end end end
Public Instance Methods
urlFor(dir)
click to toggle source
# File lib/apache-vhosts-parser.rb, line 35 def urlFor dir vhosts.each do |h| if h[:document_root] == dir return h[:server_name] end end return nil end