# HG changeset patch # User cin # Date 1485675020 -10800 # Node ID bbc4739c4d483a79e9ecc4e53b67523c2ae24004 # Parent 3f38dabaf5cc42a13ce89afbdb58b4c840a44ca6 working on IMPL::Config::Container diff -r 3f38dabaf5cc -r bbc4739c4d48 _test/sample.yaml --- a/_test/sample.yaml Mon Dec 28 15:11:35 2015 +0300 +++ b/_test/sample.yaml Sun Jan 29 10:30:20 2017 +0300 @@ -3,15 +3,15 @@ - defaults.yaml services: - role: db - type: My::Db::Context + $type: My::Db::Context - role: - auth - authz - users-provider - roles-provider - type: My::LDAP::Adapter + $type: My::LDAP::Adapter - role: security-provider - type: My::SecureCookies + $type: My::SecureCookies params: users: $ref: users-provider diff -r 3f38dabaf5cc -r bbc4739c4d48 _test/temp.pl --- a/_test/temp.pl Mon Dec 28 15:11:35 2015 +0300 +++ b/_test/temp.pl Sun Jan 29 10:30:20 2017 +0300 @@ -16,7 +16,8 @@ my $data; { - open my $h, "sample.yaml" or die; + open my $h, "<", "sample.yaml" or die; + print "H: ", *{$h}{IO}, "\n"; binmode $h; local $/; $data = <$h>; diff -r 3f38dabaf5cc -r bbc4739c4d48 lib/IMPL/Config/Container.pm --- a/lib/IMPL/Config/Container.pm Mon Dec 28 15:11:35 2015 +0300 +++ b/lib/IMPL/Config/Container.pm Sun Jan 29 10:30:20 2017 +0300 @@ -106,23 +106,6 @@ return \@result; } -sub Configure { - my ($this, $config) = @_; - - if (isarray($config)) { - $this->Configure($_) foreach @$config; - } elsif (ishash($config)) { - - } else { - die IMPL::ArgumentException->new(config => 'Either a hash or an array is required'); - } -} - -sub ParseDescriptor { - my ($this, $data) = @_; - - if () -} 1; diff -r 3f38dabaf5cc -r bbc4739c4d48 lib/IMPL/Config/YAMLConfig.pm --- a/lib/IMPL/Config/YAMLConfig.pm Mon Dec 28 15:11:35 2015 +0300 +++ b/lib/IMPL/Config/YAMLConfig.pm Sun Jan 29 10:30:20 2017 +0300 @@ -1,9 +1,23 @@ package IMPL::Config::YAMLConfig; use strict; +use IMPL::lang qw(:base); +use IMPL::Exception(); +use YAML::XS(); + +sub Load { + my ( $this, $container, $file ) = @_; + + $this->Configure( isscalar($file) + ? YAML::XS::Load( ${$file} ) + : YAML::XS::LoadFile($file) ); +} + sub Configure { - my ($this, $container, $config) = @_; + my ( $this, $container, $config ) = @_; + + } 1; @@ -13,4 +27,4 @@ =pod -=cut \ No newline at end of file +=cut diff -r 3f38dabaf5cc -r bbc4739c4d48 lib/IMPL/_core/version.pm --- a/lib/IMPL/_core/version.pm Mon Dec 28 15:11:35 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -package IMPL::_core::version; - -our $VERSION = '0.04'; - -sub import { - *{scalar(caller).'::VERSION'} = \$VERSION; -} - -1; - -__END__ - -=pod - -=head1 NAME - -C - Модуль с версией библиотеки C. - -=head1 DESCRIPTION - -Модуль исключительно для внутреннего использования. - -Все модули подключившие данный модуль разделяют с ним версию. - -=cut diff -r 3f38dabaf5cc -r bbc4739c4d48 lib/IMPL/lang.pm --- a/lib/IMPL/lang.pm Mon Dec 28 15:11:35 2015 +0300 +++ b/lib/IMPL/lang.pm Sun Jan 29 10:30:20 2017 +0300 @@ -3,7 +3,6 @@ use warnings; use parent qw(Exporter); -use IMPL::_core::version; use IMPL::clone qw(clone); use Scalar::Util qw(blessed); use POSIX; @@ -19,6 +18,8 @@ &typeof &ishash &isarray + &isscalar + &isglob ) ], @@ -90,6 +91,14 @@ not blessed($_[0]) and ref $_[0] eq 'HASH'; } +sub isscalar { + not blessed($_[0]) and ref $_[0] eq 'SCALAR'; +} + +sub isglob { + not blessed($_[0]) and ref $_[0] eq 'GLOB'; +} + sub public($) { my $info = shift; $info->{access} = ACCESS_PUBLIC;