blib/lib/CSS/Sass/Plugins.pm

filter: Statementstmt 96.6% 29 / 30 Branchbran 80.0% 8 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 93.0% 40 / 43 CC 1 SCAR 0.0
CC
1
Cov
92%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« plugins/digest/vendor/md5/md5.cpp ↑ Summary
1 # Copyright (c) 2013-2014 David Caldwell.
2 # Copyright (c) 2014-2017 Marcel Greter.
3 #
4 # Permission is hereby granted, free of charge, to any person obtaining a copy
5 # of this software and associated documentation files (the "Software"), to deal
6 # in the Software without restriction, including without limitation the rights
7 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 # copies of the Software, and to permit persons to whom the Software is
9 # furnished to do so, subject to the following conditions:
10 #
11 # The above copyright notice and this permission notice shall be included in
12 # all copies or substantial portions of the Software.
13 #
14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 # THE SOFTWARE.
21  
22 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 12 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 ################################################################################
26 package CSS::Sass::Plugins;
27 12 our $VERSION = "3.6.4";
28 ################################################################################
29 # collect plugins
30 12 our %plugins;
31 ################################################################################
32 # all plugin directory variants
33 # propably too many, check-a-lot
34 12 our @ppaths = (
35 'auto',
36 'auto/lib',
37 'arch',
38 'arch/auto',
39 'arch/auto/lib',
40 'blib',
41 'blib/auto',
42 'blib/auto/arch',
43 'blib/arch',
44 'blib/arch/auto',
45 'blib/lib',
46 'blib/lib/arch',
47 'blib/lib/arch/auto',
48 'lib',
49 'lib/auto',
50 'lib/arch',
51 'lib/arch/auto',
52 );
53 ################################################################################
54 12 ▶use Exporter 'import'; # gives you Exporter's import() method directly
Subroutine BEGIN: called CC=1 SCAR=0.0
55 12 our @EXPORT = qw(%plugins @ppaths); # symbols to export by default
56 ################################################################################
57  
58 12 foreach my $path (map {
59 204 $_ . '/CSS/Sass/plugins'
60 } @ppaths) {
61 # get our own path for module file
62 # we asume plugin path from install
63 204 my $rpath = $INC{'CSS/Sass/Plugins.pm'};
64 204 ▶ die "Module path not found" unless $rpath;
Branch: 1 branch
BranchTrueFalseTotal
unless $rpath 0 204 204
65 # normalize all slashes
66 204 $rpath =~ s/[\\\/]+/\//g;
67 # remove our own file from path
68 204 $rpath =~ s/CSS\/(?:Sass\/)?Plugins\.pm$//;
69 # remove perl path parts (install tests)
70 204 $rpath =~ s/(?:blib\/+lib\/*)$//g;
71 # remove trailing slash
72 204 $rpath =~ s/[\\\/]+$//g;
73 # only interested in base path
74 204 $rpath = $rpath . '/' . $path;
75 # silently ignore missing directory
76 204 ▶ next unless -d $rpath;
Branch: 1 branch
BranchTrueFalseTotal
unless -d $rpath 192 12 204
77 # open plugins directory to query
78 12 ▶ opendir (my $dh, $rpath) or
Branch: 1 branch
BranchTrueFalseTotal
opendir my $dh, $rpath or die "error querying plugins" 12 0 12
79 die "error querying plugins";
80 12 ▶ while (my $item = readdir($dh)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $item = readdir $dh)) 72 12 84
81 72 ▶ next unless $item =~ m/^[a-zA-Z\-]+$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $item =~ /^[a-zA-Z\-]+$/ 24 48 72
82 48 $plugins{$item} = $rpath . '/' . $item;
83 # normalize directory slashes
84 48 $plugins{$item} =~ s/[\\\/]+/\//g;
85 }
86  
87 }
88  
89 12 return \%plugins;
90  
91 ################################################################################
92 ################################################################################
93 0 1;
« plugins/digest/vendor/md5/md5.cpp ↑ Summary