{"id":16115275,"url":"https://github.com/iafan/config-neat","last_synced_at":"2025-03-18T10:30:32.359Z","repository":{"id":4765298,"uuid":"5916049","full_name":"iafan/Config-Neat","owner":"iafan","description":"Parse, validate and generate nginx-like configuration files using Perl","archived":false,"fork":false,"pushed_at":"2021-02-01T06:20:38.000Z","size":184,"stargazers_count":13,"open_issues_count":2,"forks_count":7,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-02-28T08:49:39.349Z","etag":null,"topics":["config","nginx","parser","serializer","syntax-highlighting","validator"],"latest_commit_sha":null,"homepage":"","language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iafan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-09-22T19:14:03.000Z","updated_at":"2023-03-23T13:57:05.000Z","dependencies_parsed_at":"2022-09-21T01:00:55.842Z","dependency_job_id":null,"html_url":"https://github.com/iafan/Config-Neat","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iafan%2FConfig-Neat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iafan%2FConfig-Neat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iafan%2FConfig-Neat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iafan%2FConfig-Neat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iafan","download_url":"https://codeload.github.com/iafan/Config-Neat/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243918627,"owners_count":20368745,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["config","nginx","parser","serializer","syntax-highlighting","validator"],"created_at":"2024-10-09T20:18:23.426Z","updated_at":"2025-03-18T10:30:31.889Z","avatar_url":"https://github.com/iafan.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"# About Config::Neat\n\nConfiguration files don't have to be ugly. Inspired by\n[nginx configuration files](http://wiki.nginx.org/FullExample)\nI decided to go a bit further and implement a format which is highly readable,\nless error prone, requires little to no special markup, and yet is robust\nto allow nested blocks for the projects that require more than just a plain\nkey-value list.\n\nCurrently Config::Neat is implemented as a suite of Perl modules\nwhich, in addition to parsing and rendering configuration files,\nimplement automatic configuration file inheritance (aka includes)\nand validation against schema (see below).\n\n### Simple Syntax Example\n\nIn its simplest form, the configuration file can look like this:\n\n    # Server configuration\n    server     Some string\n    port       8080\n    port       8081\n    use_ssl    YES\n\nYou are not forced to enclose strings in quotes, or specify delimiters\nat the end of each line; you will never need to escape single or double quotes.\n\n### Robust Syntax Example\n\nWhen it comes to having different (even nested) sections,\nmultiline lists or strings, block comments, Config::Neat will\noffer you such an opportunity:\n\n    /*\n        Global server configuration\n    */\n    server {\n        listen                  8080\n        use_ssl                 YES\n        debug                   NO\n        log_format              $remote_addr - $remote_user [$time]\n                                $status $size $request\n\n        supported_mime_types    text/html text/css text/xml text/plain\n                                image/gif image/jpeg image/png image/x-icon\n                                application/x-javascript\n\n        /*\n            My virtual hosts\n        */\n        virtual_hosts {\n\n            www.domain.com {\n                root            /var/www/domain\n                ...\n            }\n\n            www.otherdomain.com {\n                root            /var/www/otherdomain\n                ...\n            }\n        }\n    }\n\n### Full Syntax Example\n\nSee `sample/readme.nconf` file, which gives a full overview\nof the supported syntax.\n\n## Perl Module\n\nPerl module is located in `perl/lib` subdirectory.\nIt depends on [Tie::IxHash](http://search.cpan.org/~chorny/Tie-IxHash/)\nmodule available from CPAN.\n\n### Synopsis\n\n    use Config::Neat;\n\n    my $cfg = Config::Neat-\u003enew();\n    my $data = $cfg-\u003eparse_file('/path/to/myconfig.nconf');\n\n    # now $data contains a parsed hash tree which you can examine\n\n    # consider the example config above\n\n    my $list = $data-\u003e{'server'}-\u003e{'supported_mime_types'};\n    #\n    # $list now is an array reference:\n    #     ['text/html', 'text/css', ..., 'application/x-javascript']\n\n    my $log_format = $data-\u003e{'server'}-\u003e{'log_format'}-\u003eas_string;\n    #\n    # $log_format now is a scalar:\n    #     '$remote_addr - $remote_user [$time] $status $size $request'\n\n## Config::Neat::Inheritable\n\nThis module adds config inheritance to Config::Neat files by automatically\nprocessing `@inherit file#subnode`, `-somekey` and `+otherkey` keys.\nSee [Config::Neat::Inheritable source code](perl/lib/Config/Neat/Inheritable.pm)\nfor further explanation.\n\n## Config::Neat::Schema\n\nThis module adds config validation against provided schema (schema itself\ncan be defined using Config::Neat format). See\n[Config::Neat::Schema source code](perl/lib/Config/Neat/Schema.pm)\nfor further explanation.\n\n## Config::Neat::Render\n\nThis module allows you render Config::Neat-compatible structures from your data\n(but read below for limitations).\n\n### When shoud I use it?\n\n1. When you need to convert your old configuration files to a new format\n   (and then manually tweak the output).\n2. When you want to dump some data for diff purposes or just for reading.\n3. When readability of your output is more important than knowing original\n   data types of each node in your data output.\n\n### When shoud I NOT use it?\n\nDo not use it for arbitrary data serialization/deserialization.\nJSON and YAML will work better for this kind of task.\n\nWhy? Because Config::Neat was primarily designed to allow easier configuration\nfile authoring and reading, and uses relaxed syntax where strings are treated like\nspace-separated arrays (and vice versa), and where there's no strict definition\nfor boolean types, no null values, etc.\n\nIt's the developer's responsibility to treat any given parameter as a boolean,\nor string, or an array. This means that once you serialize your string into\nConfig::Neat format and parse it back, it will be converted to an array,\nand you will need to use `-\u003eas_string` method to get the value as string.\n\nIn other words, when doing this:\n\n    my $c = Config::Neat-\u003enew();\n    my $r = Config::Neat::Render-\u003enew();\n    my $parsed_data = $c-\u003eparse($r-\u003erender($arbitrary_data));\n\n$parsed_data will almost always be different from $arbitrary_data.\n\nHowever, doing this immediately after:\n\n    my $parsed_data_2 = $c-\u003eparse($r-\u003erender($parsed_data));\n\nShould produce the same data structure again.\n\n### Synopsis\n\n    use Config::Neat::Render;\n\n    my $r = Config::Neat::Render-\u003enew();\n\n    my $data = {\n        'foo' =\u003e 'Hello, World!',\n        'bar' =\u003e [1, 2, 3],\n        'baz' =\u003e {\n            'etc' =\u003e ['foo bar', 'baz', '', 1]\n        }\n    };\n\n    print $r-\u003erender($data);\n\nThe output will be:\n\n    bar    1 2 3\n\n    baz\n    {\n        etc    `foo bar` baz `` 1\n    }\n\n    foo    Hello, World!\n\nNote that hashes in Perl do not guarantee the correct order, so blocks may have\nindividual parameters shuffled randomly. To sort the keys, you can provide a reference\nto an ordered list of key names in the `sort` option:\n\n    ...\n\n    my @order = qw(foo bar baz);\n\n    print $r-\u003erender($data, {sort =\u003e \\@order});\n\nAnd now the output will be:\n\n    foo    Hello, World!\n    bar    1 2 3\n\n    baz\n    {\n        etc    `foo bar` baz `` 1\n    }\n\nAlternatively, setting `sort` to a true value will just sort keys alphabetically.\n\n## Tools\n\n### [dump-nconf](perl/bin/dump-nconf)\n\nThis script will read the configuration file\nand emit the parsed data structure in either Config::Neat::Render, Data::Dumper\nor JSON format. This script can be used to validate the syntax of the\nconfiguration file and understand its internal tree representation.\n\n## Syntax Highlighters\n\nThere are a few syntax highlighters available (see the `highlighters` folder):\n\n1. for [Sublime Text](http://www.sublimetext.com/) desktop editor\n   (also compatible with [TextMate](http://macromates.com/))\n2. for [Visual Studio Code](https://code.visualstudio.com)\n3. for JavaScript-based editor called [CodeMirror](http://codemirror.net/).\n\nYou can also use CodeMirror with Config::Neat highlighter to\n[statically highlight](http://codemirror.net/demo/runmode.html)\nconfiguration snippets/examples within web pages.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiafan%2Fconfig-neat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiafan%2Fconfig-neat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiafan%2Fconfig-neat/lists"}