Aion-Env
view release on metacpan or search on metacpan
lib/Aion/Env/Etc.md view on Meta::CPAN
## merge_hashes ($file, $path, $x, $y)
ÐбединÑÐµÑ Ð´Ð²Ð° Ñ
еÑа ÑекÑÑÑивно. ÐÑли в ÑовпадаÑÑиÑ
клÑÑаÑ
не Ñ
еÑи, Ñо вÑбÑаÑÑÐ²Ð°ÐµÑ Ð¾ÑÐ¸Ð±ÐºÑ Ñ `$file` и `$path`, где `$file` â подклÑÑаÑÑийÑÑ Ñайл, а `$pat...
## val ($s)
ÐобавлÑÐµÑ Ð±ÑкÑлеÑи. ÐÑполÑзÑеÑÑÑ Ð´Ð»Ñ ÑÑкейпинга ÑнвиÑонменÑов.
```perl
my $escape_string = "\\\"\\'\\\\\\t\\r\\n";
Aion::Env::Etc::val("\"'\\\t\r\n") # -> $escape_string
```
## by_key ($hash, $path)
ÐолÑÑиÑÑ Ð·Ð½Ð°Ñение по клÑÑÑ Ð¸Ð· Ñ
еÑа.
```perl
my ($val, $key_exists) = Aion::Env::Etc::by_key({x => {y => {z => 3}}}, "x.y.z");
$val # -> 3
lib/Aion/Env/Etc.pm view on Meta::CPAN
Reads and parses a configuration file in C<yaml> format. C<${ID}> are replaced with values from C<%ENV>, and if not there, then from the C<.env> file. Parses files in C<include> recursively.
=head2 merge_hashes ($file, $path, $x, $y)
Concatenates two hashes recursively. If the matching keys do not have hashes, then it throws an error with C<$file> and C<$path>, where C<$file> is the connecting file, and C<$path> is the path from the keys through the dot.
=head2 val ($s)
Adds backslashes. Used for escaping environments.
my $escape_string = "\\\"\\'\\\\\\t\\r\\n";
Aion::Env::Etc::val("\"'\\\t\r\n") # -> $escape_string
=head2 by_key ($hash, $path)
Get the value by key from the hash.
my ($val, $key_exists) = Aion::Env::Etc::by_key({x => {y => {z => 3}}}, "x.y.z");
$val # -> 3
$key_exists # -> 1
t/aion/env/etc.t view on Meta::CPAN
#
# ## merge_hashes ($file, $path, $x, $y)
#
# ÐбединÑÐµÑ Ð´Ð²Ð° Ñ
еÑа ÑекÑÑÑивно. ÐÑли в ÑовпадаÑÑиÑ
клÑÑаÑ
не Ñ
еÑи, Ñо вÑбÑаÑÑÐ²Ð°ÐµÑ Ð¾ÑÐ¸Ð±ÐºÑ Ñ `$file` и `$path`, где `$file` â подклÑÑаÑÑийÑÑ Ñайл, а `$p...
#
# ## val ($s)
#
# ÐобавлÑÐµÑ Ð±ÑкÑлеÑи. ÐÑполÑзÑеÑÑÑ Ð´Ð»Ñ ÑÑкейпинга ÑнвиÑонменÑов.
#
::done_testing; }; subtest 'val ($s)' => sub {
my $escape_string = "\\\"\\'\\\\\\t\\r\\n";
local ($::_g0 = do {Aion::Env::Etc::val("\"'\\\t\r\n")}, $::_e0 = do {$escape_string}); ::ok defined($::_g0) == defined($::_e0) && $::_g0 eq $::_e0, 'Aion::Env::Etc::val("\"\'\\\t\r\n") # -> $escape_string' or ::diag ::_struct_diff($::_g0, $::_e0); u...
#
# ## by_key ($hash, $path)
#
# ÐолÑÑиÑÑ Ð·Ð½Ð°Ñение по клÑÑÑ Ð¸Ð· Ñ
еÑа.
#
::done_testing; }; subtest 'by_key ($hash, $path)' => sub {
my ($val, $key_exists) = Aion::Env::Etc::by_key({x => {y => {z => 3}}}, "x.y.z");
local ($::_g0 = do {$val}, $::_e0 = do {3}); ::ok defined($::_g0) == defined($::_e0) && $::_g0 eq $::_e0, '$val # -> 3' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
( run in 0.884 second using v1.01-cache-2.11-cpan-54e63673c56 )