Oozie/Constants.pm

filter: Statementstmt 100% 63 / 63 Branchbran 100% 4 / 4 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 9 / 9 Podpod n/a totaltotal 95.0% 77 / 81 CC 6 SCAR 11.5
CC
6
Cov
97%
_build_valid_regex
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.1
« Oozie/Role/LWP.pm ↑ Summary Oozie/Role/Common.pm »
1 package Net::Hadoop::Oozie::Constants;
2 1 $Net::Hadoop::Oozie::Constants::VERSION = '0.114';
3 1 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use parent qw( Exporter );
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use Carp qw( confess );
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 use constant JOB_OPTIONS => qw(
11 action
12 len
13 offset
14 order
15 show
16 1 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 1 use constant COORD_STATUS => qw(
19 DONWITHERROR
20 FAILED
21 KILLED
22 PAUSED
23 PREP
24 PREPPAUSED
25 PREPSUSPENDED
26 READY
27 RUNNING
28 SUBMITTED
29 SUCCEEDED
30 SUSPENDED
31 WAITING
32 1 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
33  
34 1 use constant WF_STATUS => qw(
35 FAILED
36 KILLED
37 PREP
38 RUNNING
39 SUCCEEDED
40 SUSPENDED
41 1 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
42  
43 1 our $RE_VALID_COORD_STATUS = do {
44 1 my $s = join '|', COORD_STATUS;
45 1 qr/^$s$/;
46 };
47  
48 1 our $RE_VALID_WF_STATUS = do {
49 1 my $s = join '|', WF_STATUS;
50 1 qr/^$s$/;
51 };
52  
53 1 our $RE_VALID_STATUS = do {
54 1 my $s = join '|', COORD_STATUS, WF_STATUS;
55 1 qr/^$s$/;
56 };
57  
58 our $RE_VALID_ENDPOINT = _build_valid_regex({
59 v1 => {
60 admin => {
61 7 map { $_ => 1 } qw(
62 build-version
63 configuration
64 instrumentation
65 os-env
66 status
67 sys-props
68 systems
69 ),
70 },
71 jobs => 1,
72 job => 'dynamic',
73 },
74 v2 => {
75 admin => {
76 1 map { $_ => 1 } qw(
77 build-version
78 configuration
79 instrumentation
80 jmsinfo
81 os-env
82 status
83 sys-props
84 systems
85 ),
86 },
87 jobs => 1,
88 job => 'dynamic',
89 },
90 });
91  
92 1 our $RE_BAD_REQUEST = qr{
93 \QThe request sent by the client was syntactically incorrect. 400 Bad Request\E
94 }xms;
95  
96 1 our %IS_VALID_SHOW = map { $_ => 1 } qw(
97 definition
98 info
99 log
100 );
101  
102 1 our %IS_VALID_ACTION = map { $_ => 1 } qw(
103 coord-rerun
104 kill
105 rerun
106 resume
107 start
108 suspend
109 );
110  
111 1 our @EXPORT_OK = qw(
112 COORD_STATUS
113 JOB_OPTIONS
114 WF_STATUS
115  
116 $RE_BAD_REQUEST
117 $RE_VALID_COORD_STATUS
118 $RE_VALID_ENDPOINT
119 $RE_VALID_STATUS
120 $RE_VALID_WF_STATUS
121 %IS_VALID_ACTION
122 %IS_VALID_SHOW
123 );
124  
125 1 our %EXPORT_TAGS = (
126 all => \@EXPORT_OK,
127 );
128  
129 sub _build_valid_regex {
130 1 ▶ my $valid = shift || confess "No valid definition specified";
Subroutine _build_valid_regex: called CC=6 SCAR=17.9
Condition33%1/3
shift() || confess('No valid definition specified')
l!l&&r!l&&!r
100
MC/DC0%0/2
shift() || confess('No valid definition specified')
shift() confess('No valid definition specified')
Truth table33%1/3
A || B
A= shift()B= confess('No valid definition specified')
ABresult
1X1
011
000
131 1 my %rv;
132 1 foreach my $version ( keys %{ $valid } ) {
133 2 my $ep = $valid->{ $version };
134 2 my @patterns;
135 2 foreach my $base ( keys %{ $ep } ) {
136 6 my $subs = $ep->{ $base };
137 6 my $val;
138 6 ▶ if ( ref $subs eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $subs eq 'HASH') { } 2 4 6
139 $val = sprintf '(?:%s)/(?:%s)?',
140 $base,
141 join( '|',
142 2 map quotemeta( $_ ), keys %{ $subs } ),
143 ;
144 }
145 else {
146 4 ▶ $val = $ep->{ $base } eq 'dynamic'
Branch: 1 branch
BranchTrueFalseTotal
$ep->{$base} eq 'dynamic' ? : 2 2 4
147 ? $base . "(?:/[\@a-zA-Z0-9_\-]+)?"
148 : $base
149 ;
150 }
151 6 push @patterns, $val;
152 }
153 my $pattern = sprintf '\A%s\z',
154 2 join '|', map { sprintf '(?:%s)', $_ } @patterns;
155 2 $rv{ $version } = qr{$pattern}xms;
156 }
157 1 return \%rv;
158 }
159  
160 1 1;
161  
162 __END__
« Oozie/Role/LWP.pm ↑ Summary Oozie/Role/Common.pm »