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 4     4   1614 use Moose;
  4         7  
  4         24  
4             with 'MooseX::DIC::Configuration';
5             with 'MooseX::DIC::Loggable';
6              
7 4     4   22517 use Module::Load 'load';
  4         8  
  4         32  
8 4     4   255 use List::Util 'reduce';
  4         9  
  4         273  
9 4     4   1246 use MooseX::DIC::Configuration::Scanner::Injectable 'fetch_injectable_packages_from_path';
  4         12  
  4         219  
10 4     4   24 use aliased 'MooseX::DIC::PackageIsNotServiceException';
  4         9  
  4         32  
11 4     4   402 use aliased 'MooseX::DIC::FunctionalityNotImplementedException';
  4         8  
  4         26  
12 4     4   371 use aliased 'MooseX::DIC::ContainerConfigurationException';
  4         9  
  4         22  
13              
14             sub get_services_metadata_from_path {
15 7     7 0 28 my ($self,$paths) = @_;
16              
17             return
18 7         46 map { $self->_get_meta_from_package($_) }
  12         56  
19             fetch_injectable_packages_from_path( $paths );
20             }
21              
22             sub _get_meta_from_package {
23 12     12   39 my ($self,$package_name) = @_;
24              
25             # Make sure the the package is loaded
26 12         65 load $package_name;
27              
28             # Check the package is an Injectable class
29             my $injectable_role =
30 0     0   0 reduce {$a}
31 12         30868 grep { $_->{package} eq 'MooseX::DIC::Injectable' }
  35         3445  
32             $package_name->meta->calculate_all_roles_with_inheritance;
33 12 50       70 PackageIsNotServiceException->throw( package => $package_name )
34             unless defined $injectable_role;
35              
36             # Get the meta information from the injectable role
37 12         56 my $meta = $package_name->get_service_metadata;
38 12 50       40 ContainerConfigurationException->throw( message =>
39             "The package $package_name is not propertly configured for injection"
40             ) unless $meta;
41              
42 12         55 return $meta;
43             }