Aion-Env

 view release on metacpan or  search on metacpan

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): ();
# 
# sub import {
#     my ($cls, $name, %kw) = @_;
#     my $isa = delete $kw{isa};
#     my $is_default = exists $kw{default};
#     my $default = delete $kw{default};
#     my $key = delete $kw{key} // lc($name) =~ y/_/./r;
#     die sprintf "Unknown keyword%s: %s",
#     	scalar keys %kw == 1? '': 's',
#      	join ", ", sort keys %kw if keys %kw;
#       
#       die "$name is'nt defined!" if !exists $ETC{$key} and !$is_default;
#   
#       my $pkg = caller;
#       my $val = exists $ETC{$key}? $ETC{$key}: $default;
#   
#       if($isa) {
#       	if(UNIVERSAL::isa($isa, "Aion::Type")) { $isa->validate($val, $name) }
#        	else {
# 	    	local $_ = $val;
# 	    	die UNIVERSAL::can($isa, "get_message")? $isa->get_message($val): "$name type is'nt isa!" unless $isa->();
# 		}
#       }
#       
#       constant->import("$pkg\::$name", $val);
# }
# 
# # Считывает и парсит конфигурационный файл с включениями
# 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
# }
# 
# 1;

::done_testing;



( run in 0.691 second using v1.01-cache-2.11-cpan-6aa56a78535 )