File Coverage

blib/lib/Ark.pm
Criterion Covered Total %
statement 44 53 83.0
branch 7 10 70.0
condition n/a
subroutine 8 8 100.0
pod n/a
total 59 71 83.1


line stmt bran cond sub pod time code
1             package Ark;
2 60     60   2147080 use 5.008001;
  60         246  
  60         2419  
3 60     60   1214214 use Mouse;
  60         2137782  
  60         384  
4 60     60   24714 use Mouse::Exporter;
  60         147  
  60         378  
5              
6 60     60   42872 use Ark::Core;
  60         7784  
  60         22174  
7              
8             our $VERSION = '1.20';
9              
10             do {
11             my %EXPORTS;
12              
13             sub import {
14 181     181   525173 my ($class, @bases) = @_;
15              
16 181         464 my $caller = caller;
17              
18 181         67132 require utf8; import utf8;
  181         1499  
19              
20 181         690 my @super;
21 181 100       833 push @bases, 'Core' unless @bases;
22 181         515 for my $base (@bases) {
23 181         275 my $pkg;
24 181 100       1013 if ($base =~ /^\+/) {
25 2         12 ($pkg = $base) =~ s/^\+//;
26             } else {
27 179         418 $pkg = "Ark::${base}";
28             }
29 181         380 push @super, $pkg;
30 181         1057 Ark::Core->ensure_class_loaded($pkg);
31              
32 60     60   595 no strict 'refs';
  60         124  
  60         15915  
33 181         6834 for my $keyword (@{ $pkg . '::EXPORT' }) {
  181         945  
34 0         0 push @{ $EXPORTS{$caller} }, $keyword;
  0         0  
35 0         0 *{ $class . '::' . $keyword } = *{ $pkg . '::' . $keyword };
  0         0  
  0         0  
36             }
37              
38 181 100       2322 if (my $exporter = $pkg->can('EXPORT')) {
39 69         286 $exporter->($pkg, $caller);
40             }
41             }
42              
43 181         5757 Mouse::Meta::Class->initialize($caller);
44              
45 181         6848 my ($import, $unimport) = Mouse::Exporter->build_import_methods(
46             exporting_package => $caller,
47             also => "Mouse",
48             );
49              
50 181         33159 $caller->$import({ into => $caller });
51 181         53953 $caller->meta->superclasses(@super);
52              
53 181         10754 push @{ $EXPORTS{$class} }, $unimport;
  181         16996  
54             }
55              
56             sub unimport {
57 10     10   26 my $caller = caller;
58              
59 10 50       18 for my $item (@{ $EXPORTS{$caller} || [] }) {
  10         6856  
60 0 0         if (ref $item eq 'CODE') {
61 0           $caller->$item;
62             }
63             else {
64 60     60   350 no strict 'refs';
  60         137  
  60         4815  
65 0           delete ${ $caller . '::' }{ $item };
  0            
66             }
67             }
68             }
69             };
70              
71             1;
72             __END__