File Coverage

lib/MooseX/DIC/Configuration/Code.pm
Criterion Covered Total %
statement 32 33 96.9
branch 2 4 50.0
condition n/a
subroutine 9 10 90.0
pod 0 1 0.0
total 43 48 89.5


line stmt bran cond sub pod time code
1             package MooseX::DIC::Configuration::Code;
2              
3 5     5   2363 use Moose;
  5         12  
  5         35  
4             with 'MooseX::DIC::Configuration';
5             with 'MooseX::DIC::Loggable';
6              
7 5     5   31428 use Module::Load 'load';
  5         15  
  5         45  
8 5     5   340 use List::Util 'reduce';
  5         12  
  5         379  
9 5     5   1963 use MooseX::DIC::Configuration::Scanner::Injectable 'fetch_injectable_packages_from_path';
  5         20  
  5         352  
10 5     5   39 use aliased 'MooseX::DIC::PackageIsNotServiceException';
  5         11  
  5         41  
11 5     5   610 use aliased 'MooseX::DIC::FunctionalityNotImplementedException';
  5         11  
  5         29  
12 5     5   542 use aliased 'MooseX::DIC::ContainerConfigurationException';
  5         12  
  5         32  
13              
14             sub get_services_metadata_from_path {
15 8     8 0 28 my ($self,$paths) = @_;
16              
17             return
18 8         46 map { $self->_get_meta_from_package($_) }
  14         77  
19             fetch_injectable_packages_from_path( $paths );
20             }
21              
22             sub _get_meta_from_package {
23 14     14   42 my ($self,$package_name) = @_;
24              
25             # Make sure the the package is loaded
26 14         119 load $package_name;
27              
28             # Check the package is an Injectable class
29             my $injectable_role =
30 0     0   0 reduce {$a}
31 14         35055 grep { $_->{package} eq 'MooseX::DIC::Injectable' }
  41         4546  
32             $package_name->meta->calculate_all_roles_with_inheritance;
33 14 50       94 PackageIsNotServiceException->throw( package => $package_name )
34             unless defined $injectable_role;
35              
36             # Get the meta information from the injectable role
37 14         75 my $meta = $package_name->get_service_metadata;
38 14 50       53 ContainerConfigurationException->throw( message =>
39             "The package $package_name is not propertly configured for injection"
40             ) unless $meta;
41              
42 14         81 return $meta;
43             }