nginx-config 0.13.2

A parser, AST and formatter for nginx configuration files.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
extern crate nginx_config;
#[cfg(test)] #[macro_use] extern crate pretty_assertions;

use nginx_config::parse_main;

fn roundtrip(value: &str) {
    let ast = parse_main(&value).unwrap();
    assert_eq!(ast.to_string(), value);
}

#[test] fn exact()    { roundtrip("server_name devd.io;\n"); }
#[test] fn suffix()   { roundtrip("server_name .devd.io;\n"); }
#[test] fn multiple() { roundtrip("server_name example.com .devd.io;\n"); }
#[test] fn star_pre() { roundtrip("server_name *.devd.io;\n"); }
#[test] fn star_suf() { roundtrip("server_name mail.*;\n"); }
#[test] fn regex()    { roundtrip("server_name ~^www\\.[.*]\\.devd\\.io;\n"); }