blib/lib/Web/Machine/Util.pm

filter: Statementstmt 100% 52 / 52 Branchbran 95.0% 19 / 20 Conditioncond 66.6% 4 / 6 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 100% 14 / 14 Podpod 85.7% 6 / 7 totaltotal 94.1% 97 / 103 CC 14 SCAR 20.5
CC
14
Cov
96%
bind_path
14.1
BEGIN
1.0
BEGIN
1.0
CRAP 7.8
« blib/lib/Web/Machine/FSM.pm ↑ Summary blib/lib/Web/Machine/FSM/States.pm »
1 package Web::Machine::Util;
2 # ABSTRACT: General Utility module
3  
4 25 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 25 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 25 our $VERSION = '0.17';
8  
9 25 ▶use Carp qw[ confess ];
Subroutine BEGIN: called CC=1 SCAR=0.0
10 25 ▶use Scalar::Util qw[ blessed ];
Subroutine BEGIN: called CC=1 SCAR=0.0
11 25 ▶use List::Util qw[ first ];
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 25 ▶use HTTP::Headers::ActionPack 0.07;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 25 ▶use Sub::Exporter -setup => {
Subroutine BEGIN: called CC=1 SCAR=0.0
16 exports => [qw[
17 first
18 pair_key
19 pair_value
20 bind_path
21 create_date
22 create_header
23 inflate_headers
24 ]]
25 25 };
26  
27 230 ▶sub pair_key { ( keys %{ $_[0] } )[0] }
Subroutine pair_key: called CC=1 SCAR=0.0
Pod documented
28 63 ▶sub pair_value { ( values %{ $_[0] } )[0] }
Subroutine pair_value: called CC=1 SCAR=0.0
Pod documented
29  
30 {
31 25 my $ACTION_PACK = HTTP::Headers::ActionPack->new;
32 153 ▶ sub create_header { $ACTION_PACK->create( @_ ) }
Subroutine create_header: called CC=1 SCAR=0.0
Pod documented
33 28 ▶ sub create_date { $ACTION_PACK->create( 'DateHeader' => shift ) }
Subroutine create_date: called CC=1 SCAR=0.0
Pod documented
34 138 ▶ sub inflate_headers { $ACTION_PACK->inflate( @_ ) }
Subroutine inflate_headers: called CC=1 SCAR=0.0
Pod documented
35 24 ▶ sub get_action_pack { $ACTION_PACK }
Subroutine get_action_pack: called CC=1 SCAR=0.0
Pod undocumented
36 }
37  
38 25 ▶sub bind_path {
Subroutine bind_path: called CC=14 SCAR=26.4
Pod documented
39 25 my ($spec, $path) = @_;
40 25 ▶ my @parts = grep { defined $_ && $_ ne q{} } split /\// => $path;
Condition66%2/3
defined $_ && $_ ne ''
!ll&&!rl&&r
02148
MC/DC50%1/2
defined $_ && $_ ne ''
defined $_ $_ ne ''
Truth table66%2/3
A && B
A= defined $_B= $_ ne ''
ABresult
0X0
100
111
41 25 ▶ my @spec = grep { defined $_ && $_ ne q{} } split /\// => $spec;
Condition66%2/3
defined $_ && $_ ne ''
!ll&&!rl&&r
02552
MC/DC50%1/2
defined $_ && $_ ne ''
defined $_ $_ ne ''
Truth table66%2/3
A && B
A= defined $_B= $_ ne ''
ABresult
0X0
100
111
42  
43 25 my @results;
44 25 foreach my $i ( 0 .. $#spec ) {
45 49 ▶ if ( $spec[ $i ] =~ /^\*$/ ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($spec[$i] =~ /^\*$/) { } 5 44 49
elsif ($spec[$i] =~ /^\:/) { } 20 24 44
elsif ($spec[$i] =~ /^\?\:/) { } 9 15 24
46 5 push @results => @parts;
47 5 @parts = ();
48 5 last;
49 }
50 elsif ( $spec[ $i ] =~ /^\:/ ) {
51 20 ▶ return unless defined $parts[ 0 ];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $parts[0] 2 18 20
52 18 push @results => shift @parts;
53 }
54 elsif ( $spec[ $i ] =~ /^\?\:/ ) {
55 9 ▶ push @results => shift @parts
Branch: 1 branch
BranchTrueFalseTotal
if defined $parts[0] 5 4 9
56 if defined $parts[ 0 ];
57 }
58 else {
59 15 ▶ return unless defined $parts[ 0 ];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $parts[0] 0 15 15
60 15 ▶ return unless $spec[ $i ] eq $parts[ 0 ];
Branch: 1 branch
BranchTrueFalseTotal
unless $spec[$i] eq $parts[0] 1 14 15
61 14 shift @parts;
62 }
63 }
64  
65 22 ▶ return if @parts;
Branch: 1 branch
BranchTrueFalseTotal
if @parts 4 18 22
66  
67 wantarray
68 ? @results
69 18 ▶ : (scalar @results == 1)
Branch: 2 branches
BranchTrueFalseTotal
wantarray ? : 13 5 18
scalar @results == 1 ? : 1 4 5
70 ? $results[0]
71 : @results;
72 }
73  
74 25 1;
75  
76 __END__
« blib/lib/Web/Machine/FSM.pm ↑ Summary blib/lib/Web/Machine/FSM/States.pm »