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   2457 use Moose;
  5         15  
  5         40  
4             with 'MooseX::DIC::Configuration';
5             with 'MooseX::DIC::Loggable';
6              
7 5     5   40353 use Module::Load 'load';
  5         15  
  5         49  
8 5     5   407 use List::Util 'reduce';
  5         16  
  5         442  
9 5     5   1918 use MooseX::DIC::Configuration::Scanner::Injectable 'fetch_injectable_packages_from_path';
  5         17  
  5         347  
10 5     5   37 use aliased 'MooseX::DIC::PackageIsNotServiceException';
  5         13  
  5         39  
11 5     5   694 use aliased 'MooseX::DIC::FunctionalityNotImplementedException';
  5         15  
  5         36  
12 5     5   633 use aliased 'MooseX::DIC::ContainerConfigurationException';
  5         16  
  5         37  
13              
14             sub get_services_metadata_from_path {
15 8     8 0 215 my ($self,$paths) = @_;
16              
17             return
18 8         59 map { $self->_get_meta_from_package($_) }
  14         76  
19             fetch_injectable_packages_from_path( $paths );
20             }
21              
22             sub _get_meta_from_package {
23 14     14   57 my ($self,$package_name) = @_;
24              
25             # Make sure the the package is loaded
26 14         78 load $package_name;
27              
28             # Check the package is an Injectable class
29             my $injectable_role =
30 0     0   0 reduce {$a}
31 14         45704 grep { $_->{package} eq 'MooseX::DIC::Injectable' }
  41         5335  
32             $package_name->meta->calculate_all_roles_with_inheritance;
33 14 50       98 PackageIsNotServiceException->throw( package => $package_name )
34             unless defined $injectable_role;
35              
36             # Get the meta information from the injectable role
37 14         91 my $meta = $package_name->get_service_metadata;
38 14 50       55 ContainerConfigurationException->throw( message =>
39             "The package $package_name is not propertly configured for injection"
40             ) unless $meta;
41              
42 14         82 return $meta;
43             }