Class: NginxConfig
- Inherits:
-
Object
- Object
- NginxConfig
- Defined in:
- lib/inspec/utils/nginx_parser.rb
Class Method Summary collapse
Class Method Details
.parse(content) ⇒ Object
83 84 85 86 87 88 89 90 |
# 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) ⇒ Object
92 93 94 95 96 97 98 99 100 |
# 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 |