Aion-Env
view release on metacpan or search on metacpan
lib/Aion/Env.pm view on Meta::CPAN
die UNIVERSAL::can($isa, "get_message")? $isa->get_message($val): "$name type is'nt isa!" unless $isa->();
}
}
constant->import("$pkg\::$name", $val);
}
my $BOM = "\x{feff}";
sub parse {
my ($file) = @_;
open my $f, '<:utf8', $file or die "$file: $!";
my %env;
my $interpolate = sub {
$_[0] =~ s!\$\{(\w+)\}!$env{$1}!ge;
};
while(<$f>) {
s/^$BOM// if $. == 1;
next if /^\s*(?:#|$)/;
lib/Aion/Env/Etc.pm view on Meta::CPAN
}
# СÑиÑÑÐ²Ð°ÐµÑ Ð¸ паÑÑÐ¸Ñ ÐºÐ¾Ð½ÑигÑÑаÑионнÑй Ñайл Ñ Ð²ÐºÐ»ÑÑениÑми
sub parse {
my ($path) = @_;
my $etc;
my @S = $path;
while(@S) {
my $path = shift @S;
open my $f, '<:utf8', $path or die "$path :$!";
read $f, my $buf, -s $f;
close $f;
$buf =~ s!\$\{([a-z_]\w*)\}! val($ENV{$1} // $Aion::Env::env{$1}) !gie;
my $include = YAML::Syck::Load($buf); undef $buf;
push @S, @{$include->{includes}};
%$include = (%$include, %{$include->{'when@' . APP_ENV}});
$etc = merge_hashes($path, undef, $etc, $include);
}
$etc
t/aion/env.t view on Meta::CPAN
use common::sense; use open qw/:std :utf8/; use Carp qw//; use Cwd qw//; use File::Basename qw//; use File::Find qw//; use File::Slurper qw//; use File::Spec qw//; use File::Path qw//; use Scalar::Util qw//; use Test::More 0.98; use String::Diff q...
# # NAME
#
# Aion::Env - ÑоздаÑÑ ÐºÐ¾Ð½ÑÑанÑÑ ÑвÑзаннÑÑ Ñо знаÑением из .env
#
# # VERSION
#
# 0.1
#
# # SYNOPSIS
#
t/aion/env/etc.pm view on Meta::CPAN
use common::sense; use open qw/:std :utf8/; use Carp qw//; use Cwd qw//; use File::Basename qw//; use File::Find qw//; use File::Slurper qw//; use File::Spec qw//; use File::Path qw//; use Scalar::Util qw//; use Test::More 0.98; use String::Diff q...
#
# use common::sense;
#
# use YAML::Syck qw//;
#
# use Aion::Env AION_ENV_ETC_PATH => (default => 'etc/include.yml');
# use Aion::Env APP_ENV => (default => 'prod');
#
# our %ETC = -e AION_ENV_ETC_PATH? _parse(AION_ENV_ETC_PATH): ();
#
t/aion/env/etc.pm view on Meta::CPAN
# }
#
# # СÑиÑÑÐ²Ð°ÐµÑ Ð¸ паÑÑÐ¸Ñ ÐºÐ¾Ð½ÑигÑÑаÑионнÑй Ñайл Ñ Ð²ÐºÐ»ÑÑениÑми
# sub _parse {
# my ($path) = @_;
#
# my %etc;
# my @S = ["", $path];
# while(@S) {
# my ($key, $path) = @{shift @S};
# open my $f, '<:utf8', $path or die "$path :$!";
# my $etc = YAML::Syck::Load($path);
# my $include = $etc->{include};
# push @S, ["$key.$_", "$path/$include->{$_}"] for keys %$include;
# %$etc = (%$etc, %{$etc->{'when@' . APP_ENV}});
# die "$key exists. $path" if exists $etc{$key};
# $etc{$key} = $etc;
# }
#
# %etc
# }
t/aion/env/etc.t view on Meta::CPAN
use common::sense; use open qw/:std :utf8/; use Carp qw//; use Cwd qw//; use File::Basename qw//; use File::Find qw//; use File::Slurper qw//; use File::Spec qw//; use File::Path qw//; use Scalar::Util qw//; use Test::More 0.98; use String::Diff q...
# # NAME
#
# Aion::Env::Etc - ÑоздаÑÑ ÐºÐ¾Ð½ÑÑанÑÑ ÑвÑзаннÑÑ Ñ ÐºÐ»ÑÑом из конÑигÑÑаÑионнÑÑ
Ñайлов
#
# # SYNOPSIS
#
# Файл etc/include.yml:
#@> etc/include.yml
#>> includes:
#>> - etc/test.yml
( run in 1.277 second using v1.01-cache-2.11-cpan-6aa56a78535 )