Mercurial > pub > Impl
changeset 418:3f38dabaf5cc ref20150831
sync
author | cin |
---|---|
date | Mon, 28 Dec 2015 15:11:35 +0300 |
parents | 3ed0c58e9da3 |
children | bbc4739c4d48 |
files | _test/Test/Config/Container.pm _test/any.pl _test/run_tests.pl _test/sample.yaml _test/temp.pl impl.komodoproject lib/IMPL/Config/Container.pm lib/IMPL/Config/YAMLConfig.pm |
diffstat | 8 files changed, 104 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/_test/Test/Config/Container.pm Mon Nov 02 01:56:53 2015 +0300 +++ b/_test/Test/Config/Container.pm Mon Dec 28 15:11:35 2015 +0300 @@ -20,7 +20,8 @@ use IMPL::declare { require => { - Container => 'IMPL::Config::Container' + Container => 'IMPL::Config::Container', + }, base => { 'IMPL::Test::Unit' => '@_' @@ -32,9 +33,21 @@ my $c1 = Container->new(); }; -sub RegisterServices { +test RegisterServices => sub { my $c1 = Container->new(); -} + + $c1->Register( 'db' => Service->new( + type => 'Foo::Data', + norequire => 1, + activation => 'container' + )); + + return $c1; +}; + +test ResolveServices => sub { + +}; 1; \ No newline at end of file
--- a/_test/any.pl Mon Nov 02 01:56:53 2015 +0300 +++ b/_test/any.pl Mon Dec 28 15:11:35 2015 +0300 @@ -1,6 +1,6 @@ #!/usr/bin/perl -w use strict; -use lib '..\Lib'; +use lib '..\lib'; require IMPL::DOM::Navigator::SimpleBuilder; require IMPL::DOM::XMLReader;
--- a/_test/run_tests.pl Mon Nov 02 01:56:53 2015 +0300 +++ b/_test/run_tests.pl Mon Dec 28 15:11:35 2015 +0300 @@ -2,7 +2,7 @@ use strict; use warnings; -use lib '../Lib'; +use lib '../lib'; use lib '.'; use IMPL::Test::HarnessRunner;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/_test/sample.yaml Mon Dec 28 15:11:35 2015 +0300 @@ -0,0 +1,20 @@ +include: +- secrets.yaml +- defaults.yaml +services: +- role: db + type: My::Db::Context +- role: + - auth + - authz + - users-provider + - roles-provider + type: My::LDAP::Adapter +- role: security-provider + type: My::SecureCookies + params: + users: + $ref: users-provider + roles: + $ref: roles-provider + persistent: 0 \ No newline at end of file
--- a/_test/temp.pl Mon Nov 02 01:56:53 2015 +0300 +++ b/_test/temp.pl Mon Dec 28 15:11:35 2015 +0300 @@ -3,9 +3,9 @@ use Carp; use Time::HiRes qw(gettimeofday tv_interval); use Scalar::Util qw(blessed refaddr); -use YAML::XS qw(Dump); +use YAML::XS qw(Dump Load); -my $t = [gettimeofday]; + use IMPL::require { Container => 'IMPL::Config::Container', @@ -14,36 +14,19 @@ Value => 'IMPL::Config::ValueDescriptor' }; -my $c1 = Container->new(); - -$c1->Register('db', Service->new( - type => 'Foo::Data', - norequire => 1, - activation => 'container' -) ); - -$c1->Register(['sec', 'ldap'], Reference->new('db') ); +my $data; +{ + open my $h, "sample.yaml" or die; + binmode $h; + local $/; + $data = <$h>; +} -$c1->Register('mixed', Value->new([ - Reference->new('db'), - Reference->new('sec'), - Reference->new('ldap') -])); +my $t = [gettimeofday]; -my $c2 = Container->new($c1); - -my $data = [ $c1->Resolve('mixed')] ; +print Dump Load($data); print "Activated: ",tv_interval($t,[gettimeofday]),"\n"; -print Dump($data); - - -package Foo::Data; -use IMPL::declare { - base => [ - 'IMPL::Object' => undef - ] -}; 1;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/impl.komodoproject Mon Dec 28 15:11:35 2015 +0300 @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Komodo Project File - DO NOT EDIT --> +<project id="66c7d414-175f-45b6-92fe-dbda51c64843" kpf_version="5" name="impl.komodoproject"> +<file id="c255e877-43b0-4625-a9f2-fbf8e65179c8" idref="66c7d414-175f-45b6-92fe-dbda51c64843/Lib/IMPL/DOM" name="Node.pm" url="Lib/IMPL/DOM/Node.pm"> +</file> +<preference-set idref="66c7d414-175f-45b6-92fe-dbda51c64843" id="project" preftype="project"> + <string relative="path" id="import_dirname"></string> + <boolean id="import_live">1</boolean> + <string id="last_local_directory">None</string> + <string id="last_remote_directory">None</string> + <string relative="path" id="perlExtraPaths">lib</string> + <long id="prefs_version">1</long> +<preference-set id="testPlans"> +<preference-set id="impl.kpf - test plan # 1"> + <string id="command_line"></string> + <string relative="url" id="directory"></string> + <string id="language">Perl - TAP (*.t)</string> +</preference-set> +</preference-set> +</preference-set> +</project>
--- a/lib/IMPL/Config/Container.pm Mon Nov 02 01:56:53 2015 +0300 +++ b/lib/IMPL/Config/Container.pm Mon Dec 28 15:11:35 2015 +0300 @@ -6,7 +6,6 @@ use IMPL::declare { require => { Descriptor => 'IMPL::Config::Descriptor', - ValueDescriptor => 'IMPL::Config::ValueDescriptor', ActivationContext => 'IMPL::Config::ActivationContext', Hierarchy => 'IMPL::Config::Hierarchy', Bag => 'IMPL::Config::Bag', @@ -107,6 +106,24 @@ 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; __END__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/IMPL/Config/YAMLConfig.pm Mon Dec 28 15:11:35 2015 +0300 @@ -0,0 +1,16 @@ +package IMPL::Config::YAMLConfig; +use strict; + +sub Configure { + my ($this, $container, $config) = @_; + +} + +1; + +__END__ + +=pod + + +=cut \ No newline at end of file