Sling/GroupUtil.pm

filter: Statementstmt 100% 64 / 64 Branchbran 100% 18 / 18 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 14 / 14 Podpod 100% 8 / 8 totaltotal 98.1% 107 / 109 CC 11 SCAR 8.5
CC
11
Cov
99%
add_setup
4.0
delete_setup
3.0
exists_setup
3.0
CRAP 2.3
« Sling/GroupMemberUtil.pm ↑ Summary Sling.pm »
1 #!/usr/bin/perl -w
2  
3 package Apache::Sling::GroupUtil;
4  
5 3 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use Apache::Sling::URL;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 3 require Exporter;
12  
13 3 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 3 our @EXPORT_OK = ();
16  
17 3 our $VERSION = '0.27';
18  
19 #{{{sub add_setup
20  
21 4 ▶sub add_setup {
Subroutine add_setup: called CC=4 SCAR=13.9
Pod documented
22 4 my ( $base_url, $act_on_group, $properties ) = @_;
23 4 ▶ if ( !defined $base_url ) { croak 'No base url defined to add against!'; }
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $base_url) 1 3 4
24 3 ▶ if ( !defined $act_on_group ) { croak 'No group name defined to add!'; }
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $act_on_group) 1 2 3
25  
26 # property_post_vars is set to q{} if no properties are specified:
27 2 my $property_post_vars =
28 Apache::Sling::URL::properties_array_to_string($properties);
29 2 my $post_variables = "\$post_variables = [':name','$act_on_group'";
30 2 ▶ if ( $property_post_vars ne q{} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($property_post_vars ne "") 1 1 2
31 1 $post_variables .= ",$property_post_vars";
32 }
33 2 $post_variables .= "]";
34 return
35 2 "post $base_url/system/userManager/group.create.html $post_variables";
36 }
37  
38 #}}}
39  
40 #{{{sub add_eval
41  
42 1 ▶sub add_eval {
Subroutine add_eval: called CC=1 SCAR=0.0
Pod documented
43 1 my ($res) = @_;
44 1 return ( ${$res}->code eq '200' );
45 }
46  
47 #}}}
48  
49 #{{{sub delete_setup
50  
51 3 ▶sub delete_setup {
Subroutine delete_setup: called CC=3 SCAR=11.0
Pod documented
52 3 my ( $base_url, $act_on_group ) = @_;
53 3 ▶ if ( !defined $base_url ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $base_url) 1 2 3
54 1 croak 'No base url defined to delete against!';
55 }
56 2 ▶ if ( !defined $act_on_group ) { croak 'No group name defined to delete!'; }
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $act_on_group) 1 1 2
57 1 my $post_variables = q{$post_variables = []};
58 return
59 1 "post $base_url/system/userManager/group/$act_on_group.delete.html $post_variables";
60 }
61  
62 #}}}
63  
64 #{{{sub delete_eval
65  
66 1 ▶sub delete_eval {
Subroutine delete_eval: called CC=1 SCAR=0.0
Pod documented
67 1 my ($res) = @_;
68 1 return ( ${$res}->code eq '200' );
69 }
70  
71 #}}}
72  
73 #{{{sub exists_setup
74  
75 3 ▶sub exists_setup {
Subroutine exists_setup: called CC=3 SCAR=11.0
Pod documented
76 3 my ( $base_url, $act_on_group ) = @_;
77 3 ▶ if ( !defined $base_url ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $base_url) 1 2 3
78 1 croak 'No base url to check existence against!';
79 }
80 2 ▶ if ( !defined $act_on_group ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $act_on_group) 1 1 2
81 1 croak 'No group to check existence of defined!';
82 }
83 1 return "get $base_url/system/userManager/group/$act_on_group.json";
84 }
85  
86 #}}}
87  
88 #{{{sub exists_eval
89  
90 1 ▶sub exists_eval {
Subroutine exists_eval: called CC=1 SCAR=0.0
Pod documented
91 1 my ($res) = @_;
92 1 return ( ${$res}->code eq '200' );
93 }
94  
95 #}}}
96  
97 #{{{sub view_setup
98  
99 6 ▶sub view_setup {
Subroutine view_setup: called CC=3 SCAR=11.0
Pod documented
100 6 my ( $base_url, $act_on_group ) = @_;
101 6 ▶ if ( !defined $base_url ) { croak 'No base url to view with defined!'; }
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $base_url) 2 4 6
102 4 ▶ if ( !defined $act_on_group ) { croak 'No group to view defined!'; }
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $act_on_group) 3 1 4
103 1 return "get $base_url/system/userManager/group/$act_on_group.tidy.json";
104 }
105  
106 #}}}
107  
108 #{{{sub view_eval
109  
110 2 ▶sub view_eval {
Subroutine view_eval: called CC=2 SCAR=7.0
Pod documented
111 2 my ($res) = @_;
112 2 ▶ return ( ${$res}->code eq '200' && ${$res}->content ne q{} );
Condition66%2/3
${$res;}->code eq '200' && ${$res;}->content ne ''
!ll&&!rl&&r
011
MC/DC50%1/2
${$res;}->code eq '200' && ${$res;}->content ne ''
${$res;}->code eq '200' ${$res;}->content ne ''
Truth table66%2/3
A && B
A= ${$res;}->code eq '200'B= ${$res;}->content ne ''
ABresult
0X0
100
111
113 }
114  
115 #}}}
116  
117 3 1;
118  
119 __END__
« Sling/GroupMemberUtil.pm ↑ Summary Sling.pm »