Update version and improve config validation

This commit is contained in:
netkas 2024-09-26 14:57:27 -04:00
parent 6eb1f68f98
commit beb133dc75
3 changed files with 25 additions and 74 deletions

View file

@ -5,9 +5,6 @@
"minimum_version": "8.0", "minimum_version": "8.0",
"maximum_version": "8.2" "maximum_version": "8.2"
}, },
"options": {
"create_symlink": true
},
"update_source": { "update_source": {
"source": "nosial/libs.config@n64", "source": "nosial/libs.config@n64",
"repository": { "repository": {
@ -16,14 +13,28 @@
"host": "git.n64.cc", "host": "git.n64.cc",
"ssl": true "ssl": true
} }
},
"options": {
"create_symlink": true
} }
}, },
"execution_policies":[
{
"name": "main",
"runner": "php",
"execute": {
"target": "main",
"working_directory": "%CWD%",
"tty": true
}
}
],
"assembly": { "assembly": {
"name": "ConfigLib", "name": "ConfigLib",
"package": "net.nosial.configlib", "package": "net.nosial.configlib",
"description": "ConfigLib is a library for reading and writing configuration files via the NCC Runtime API",
"company": "Nosial", "company": "Nosial",
"copyright": "Copyright (c) 2022-2023 Nosial", "copyright": "Copyright (c) 2022-2023 Nosial",
"description": "ConfigLib is a library for reading and writing configuration files via the NCC Runtime API",
"version": "1.1.1", "version": "1.1.1",
"uuid": "9347259e-8e4d-11ed-85a7-fd07cf28ef35" "uuid": "9347259e-8e4d-11ed-85a7-fd07cf28ef35"
}, },
@ -38,26 +49,31 @@
{ {
"name": "net.nosial.optslib", "name": "net.nosial.optslib",
"version": "latest", "version": "latest",
"source_type": "remote",
"source": "nosial/libs.opts=latest@n64" "source": "nosial/libs.opts=latest@n64"
}, },
{ {
"name": "net.nosial.loglib", "name": "net.nosial.loglib",
"version": "latest", "version": "latest",
"source_type": "remote",
"source": "nosial/libs.log=latest@n64" "source": "nosial/libs.log=latest@n64"
}, },
{ {
"name": "com.symfony.filesystem", "name": "com.symfony.filesystem",
"version": "latest", "version": "latest",
"source_type": "remote",
"source": "symfony/filesystem=latest@packagist" "source": "symfony/filesystem=latest@packagist"
}, },
{ {
"name": "com.symfony.yaml", "name": "com.symfony.yaml",
"version": "latest", "version": "latest",
"source_type": "remote",
"source": "symfony/yaml=latest@packagist" "source": "symfony/yaml=latest@packagist"
}, },
{ {
"name": "com.symfony.process", "name": "com.symfony.process",
"version": "latest", "version": "latest",
"source_type": "remote",
"source": "symfony/process=latest@packagist" "source": "symfony/process=latest@packagist"
} }
], ],
@ -74,72 +90,7 @@
"define_constants": { "define_constants": {
"DEBUG": "1" "DEBUG": "1"
} }
},
{
"name": "release-compressed",
"build_type": "ncc",
"output": "build/release/%ASSEMBLY.PACKAGE%.gz.ncc",
"options": {
"compression": "high"
}
},
{
"name": "debug-compressed",
"build_type": "ncc",
"output": "build/debug/%ASSEMBLY.PACKAGE%.gz.ncc",
"options": {
"compression": "high"
},
"define_constants": {
"DEBUG": "1"
}
},
{
"name": "release-executable",
"build_type": "executable",
"output": "build/release/release_executable_gz",
"options": {
"ncc_configuration": "release"
}
},
{
"name": "debug-executable",
"build_type": "executable",
"output": "build/debug/debug_executable_gz",
"options": {
"ncc_configuration": "debug"
}
},
{
"name": "release-compressed-executable",
"build_type": "executable",
"output": "build/release/release_compressed_executable",
"options": {
"ncc_configuration": "release-compressed"
}
},
{
"name": "debug-compressed-executable",
"build_type": "executable",
"output": "build/debug/debug_compressed_executable",
"options": {
"ncc_configuration": "debug-compressed"
}
} }
] ]
},
"execution_policies": [
{
"name": "main",
"runner": "php",
"execute": {
"working_directory": "%CWD%",
"silent": false,
"tty": true,
"timeout": null,
"idle_timeout": null,
"target": "main"
} }
}
]
} }

View file

@ -161,9 +161,7 @@
*/ */
private static function validateKey(string $input): bool private static function validateKey(string $input): bool
{ {
$pattern = '/^([a-zA-Z0-9]+\.?)+$/'; if (preg_match('/^([a-zA-Z0-9_]+\.?)+$/', $input))
if (preg_match($pattern, $input))
{ {
return true; return true;
} }

View file

@ -52,8 +52,10 @@ class ConfigurationTest extends TestCase
public function testGetMethodWithValidKey(): void public function testGetMethodWithValidKey(): void
{ {
$config = new Configuration('test'); $config = new Configuration('test');
$config->set('key1.key2', 'value'); $this->assertTrue($config->set('key1.key2', 'value', true));
$this->assertEquals('value', $config->get('key1.key2')); $this->assertEquals('value', $config->get('key1.key2'));
$this->assertTrue($config->set('foo.fizz_buzz', 'value', true));
$this->assertEquals('value', $config->get('foo.fizz_buzz'));
} }
/** /**