class NginxConfig
Public Class Methods
parse(content)
click to toggle source
# File lib/inspec/utils/nginx_parser.rb, line 83 def self.parse(content) lex = NginxParser.new.parse(content) tree = NginxTransform.new.apply(lex) gtree = NginxTransform::Group.new(nil, "", tree) read_nginx_group(gtree) rescue Parslet::ParseFailed => err raise "Failed to parse NginX config: #{err}" end
read_nginx_group(t)
click to toggle source
# File lib/inspec/utils/nginx_parser.rb, line 92 def self.read_nginx_group(t) agg_conf = Hash.new([]) agg_conf["_"] = t.args unless t.args == "" groups, conf = t.body.partition { |i| i.is_a? NginxTransform::Group } conf.each { |x| agg_conf[x.key] += [x.vals] } groups.each { |x| agg_conf[x.id] += [read_nginx_group(x)] } agg_conf end