changeset 419:bbc4739c4d48 ref20150831

working on IMPL::Config::Container
author cin
date Sun, 29 Jan 2017 10:30:20 +0300
parents 3f38dabaf5cc
children df591e3afd10
files _test/sample.yaml _test/temp.pl lib/IMPL/Config/Container.pm lib/IMPL/Config/YAMLConfig.pm lib/IMPL/_core/version.pm lib/IMPL/lang.pm
diffstat 6 files changed, 31 insertions(+), 49 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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>;
--- 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;
 
--- 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
--- 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<IMPL::_core::version> - Модуль с версией библиотеки C<IMPL>.
-
-=head1 DESCRIPTION
-
-Модуль исключительно для внутреннего использования. 
-
-Все модули подключившие данный модуль разделяют с ним версию.
-
-=cut
--- 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;