blib/lib/syntax.pm

filter: Statementstmt 96.3% 52 / 54 Branchbran 50.0% 1 / 2 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 13 / 13 Podpod 100% 2 / 2 totaltotal 93.2% 69 / 74 CC 5 SCAR 4.0
CC
5
Cov
93%
_uninstall_feature
2.1
import_into
2.0
unimport_from
2.0
CRAP 1.5
↑ Summary
1 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 # ABSTRACT: Activate syntax extensions
5  
6 package syntax;
7 {
8 1 $syntax::VERSION = '0.004';
9 }
10 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 $syntax::AUTHORITY = 'cpan:PHAYLON';
12 }
13  
14 1 ▶use Carp qw( carp );
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use Data::OptList 0.104 qw( mkopt );
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 1 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 1 $Carp::Internal{ +__PACKAGE__ }++;
20 1 ▶$Carp::Internal{ 'Devel::Declare' } ||= 1;
Condition50%1/2
$Carp::Internal{"Devel::Declare"} ||= 1
l!l
01
MC/DC0%0/1
$Carp::Internal{"Devel::Declare"} ||= 1
$Carp::Internal{"Devel::Declare"}
Truth table50%1/2
A
A= $Carp::Internal{"Devel::Declare"}
Aresult
11
00
21  
22 2 ▶sub import_into {
Subroutine import_into: called CC=2 SCAR=6.9
Pod documented
23 2 my ($class, $into, @args) = @_;
24  
25 2 my $import = mkopt \@args;
26  
27 2 for my $declaration (@$import) {
28 2 my ($feature, $options) = @$declaration;
29  
30 2 $class->_install_feature(
31 $feature,
32 $into,
33 $options,
34 [@args],
35 );
36 }
37  
38 2 return 1;
39 }
40  
41 1 ▶sub unimport_from {
Subroutine unimport_from: called CC=2 SCAR=6.9
Pod documented
42 1 my ($class, $from, @args) = @_;
43  
44 1 for my $feature (@args) {
45  
46 1 $class->_uninstall_feature(
47 $feature,
48 $from,
49 );
50 }
51  
52 1 return 1;
53 }
54  
55 2 ▶sub import {
Subroutine import: called CC=1 SCAR=0.0
56 2 my ($class, @args) = @_;
57  
58 2 my $caller = caller;
59  
60 2 return $class->import_into($caller, @args);
61 }
62  
63 1 ▶sub unimport {
Subroutine unimport: called CC=1 SCAR=0.0
64 1 my ($class, @args) = @_;
65  
66 1 my $caller = caller;
67  
68 1 return $class->unimport_from($caller, @args);
69 }
70  
71 3 ▶sub _parse_feature_name {
Subroutine _parse_feature_name: called CC=2 SCAR=6.9
72 3 my ($class, $feature) = @_;
73  
74 3 my $name =
75 join '/',
76 map ucfirst,
77 split m{/},
78 join '',
79 map ucfirst,
80 split qr{_}, $feature;
81  
82 3 my $file = "Syntax/Feature/${name}.pm";
83 3 my $package = $file;
84 s{ \/ }{::}xg, s{ \.pm \Z }{}xgi
85 3 for $package;
86  
87 3 return $package, $file;
88 }
89  
90 1 ▶sub _uninstall_feature {
Subroutine _uninstall_feature: called CC=2 SCAR=7.6
91 1 my ($class, $feature, $target) = @_;
92  
93 1 my ($package, $file) = $class->_parse_feature_name($feature);
94  
95 1 require $file;
96 1 ▶ unless ($package->can('uninstall')) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($package->can("uninstall")) 0 1 1
97 0 carp "Syntax extension $package does not know how to uninstall";
98 0 return;
99 }
100 1 return $package->uninstall(
101 from => $target,
102 identifier => $feature,
103 );
104 }
105  
106 2 ▶sub _install_feature {
Subroutine _install_feature: called CC=1 SCAR=0.0
107 2 my ($class, $feature, $target, $options, $all_params) = @_;
108  
109 2 my ($package, $file) = $class->_parse_feature_name($feature);
110  
111 2 require $file;
112 2 return $package->install(
113 into => $target,
114 options => $options,
115 identifier => $feature,
116 outer => $all_params,
117 );
118 }
119  
120 1 1;
121  
122  
123 __END__
↑ Summary