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 1.082 second using v1.01-cache-2.11-cpan-54e63673c56 )