Journyx/Group.pm

filter: Statementstmt 47.4% 28 / 59 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 24 MC/DCmcdc 0.0% 0 / 13 Subroutinesub 42.8% 6 / 14 Podpod 0.0% 0 / 4 totaltotal 26.5% 34 / 128 CC 16 SCAR 29.3
CC
16
Cov
29%
delete_record
42.0
add_record
30.0
list_records
20.0
CRAP 18.7
« Journyx/SOAP.pm ↑ Summary Journyx/SOAP/Encoding.pm »
1 package Net::Journyx::Group;
2 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 extends 'Net::Journyx::Record';
4  
5 1 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use constant jx_record_class => 'GroupRecord';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use constant jx_strip_record_suffix => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use constant jx_meta => {
Subroutine BEGIN: called CC=1 SCAR=3.8
10 create => {
11 0 ▶ defaults => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
12 0 my $self = shift;
13 0 my $args = shift;
14 0 ▶ if ( defined $args->{'parent'} && length $args->{'parent'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args->{"parent"} and length $args->{"parent"}) 0 0 0
Condition0%0/3
defined $args->{"parent"} and length $args->{"parent"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $args->{"parent"} and length $args->{"parent"}
defined $args->{"parent"} length $args->{"parent"}
Truth table0%0/3
A and B
A= defined $args->{"parent"}B= length $args->{"parent"}
ABresult
0X0
100
111
15 0 warn "Group's parent field is **deprecated**."
16 ." Please leave this field blank."
17 ." Groups do not have a parent-child relationship.)";
18 0 $args->{'parent'} = '';
19 }
20 },
21 },
22 1 };
23  
24 0 ▶sub object_classes {
Subroutine object_classes: not called CC=2 SCAR=17.9
Pod undocumented
25 0 my $res = (shift)->jx->soap->basic_call('getGroupObjectClasses');
26 0 ▶ $res = [$res] unless ref($res) eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $res eq "ARRAY" 0 0 0
27 0 return sort @$res;
28 }
29  
30 1 require Sub::Install;
31  
32 1 our @special_members = qw(code project subcode subsubcode user);
33 1 our %special_members = map {$_ => 1} @special_members;
34  
35 1 foreach my $type ( @special_members ) {
36 Sub::Install::install_sub({
37 0 ▶ code => sub { return (shift)->list_records($type, @_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
38 5 into => __PACKAGE__,
39 as => $type .'s',
40 });
41 Sub::Install::install_sub({
42 0 ▶ code => sub { return (shift)->add_record($type, @_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
43 5 into => __PACKAGE__,
44 as => "add_". $type,
45 });
46 Sub::Install::install_sub({
47 0 ▶ code => sub { return (shift)->delete_record($type, @_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
48 5 into => __PACKAGE__,
49 as => "delete_". $type,
50 });
51 }
52  
53 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
54  
55 0 ▶sub list_records {
Subroutine list_records: not called CC=4 SCAR=30.0
Pod undocumented
56 0 my $self = shift;
57 0 my $type = lc(shift);
58 0 my ($res, $trace) = $self->jx->soap->basic_call(
59 'listGroupObjects',
60 group_id_name => $self->id,
61 object_class => $type,
62 );
63 0 ▶ $res = [$res] unless ref($res) eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $res eq "ARRAY" 0 0 0
64  
65 # XXX: Strange but operation returns string 'Other' as well
66 0 ▶ return grep defined && length && $_ ne 'Other', @$res;
Condition0%0/6
defined $_ && length $_ && $_ ne 'Other'
!ll&&!rl&&r
000
defined $_ and length $_
!ll&&!rl&&r
000
MC/DC0%0/3
defined $_ && length $_ && $_ ne 'Other'
defined $_ length $_ $_ ne 'Other'
Truth table0%0/4
A and B && C
A= defined $_B= length $_C= $_ ne 'Other'
ABCresult
0XX0
10X0
1100
1111
67 }
68  
69 0 ▶sub add_record {
Subroutine add_record: not called CC=5 SCAR=34.0
Pod undocumented
70 0 my $self = shift;
71 0 my $type = lc(shift);
72 0 my $record = shift;
73  
74 0 ▶ my $record_id = blessed($record)? $record->id : $record;
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($record) ? : 0 0 0
75  
76 0 ▶ if ( $special_members{ $type } || ($type =~ s/^(.*)s$/$1/ && $special_members{ $type }) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Net::Journyx::Group::special_members{$type} or $type =~ s/^(.*)s$/$1/ and $Net::Journyx::Group::special_members{$type}) { } 0 0 0
Condition0%0/6
$Net::Journyx::Group::special_members{$type} or $type =~ s/^(.*)s$/$1/ and $Net::Journyx::Group::special_members{$type}
l!l&&r!l&&!r
000
$type =~ s/^(.*)s$/$1/ and $Net::Journyx::Group::special_members{$type}
!ll&&!rl&&r
000
MC/DC0%0/3
$Net::Journyx::Group::special_members{$type} or $type =~ s/^(.*)s$/$1/ and $Net::Journyx::Group::special_members{$type}
$Net::Journyx::Group::special_members{$type} $type =~ s/^(.*)s$/$1/ $Net::Journyx::Group::special_members{$type}
Truth table0%0/4
A or B and C
A= $Net::Journyx::Group::special_members{$type}B= $type =~ s/^(.*)s$/$1/C= $Net::Journyx::Group::special_members{$type}
ABCresult
1XX1
0111
00X0
0100
77  
78 0 my $res = $self->jx->soap->basic_call(
79 'add'. ucfirst($type) .'ToGroup',
80 id => $record_id,
81 group => $self->id,
82 );
83 } else {
84 0 my $res = $self->jx->soap->basic_call(
85 'addObjectToGroup',
86 group_id_name => $self->id,
87 object_class => $type,
88 object_id_name => $record_id,
89 );
90 }
91 }
92  
93 0 ▶sub delete_record {
Subroutine delete_record: not called CC=6 SCAR=37.4
Pod undocumented
94 0 my $self = shift;
95 0 my $type = lc(shift);
96 0 my $record = shift;
97  
98 0 ▶ my $record_id = blessed($record)? $record->id : $record;
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($record) ? : 0 0 0
99  
100 0 ▶ if ( $special_members{ $type } || ($type =~ /^(.*)s$/ && $special_members{ $1 }) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Net::Journyx::Group::special_members{$type} or $type =~ /^(.*)s$/ and $Net::Journyx::Group::special_members{$1}) { } 0 0 0
Condition0%0/6
$Net::Journyx::Group::special_members{$type} or $type =~ /^(.*)s$/ and $Net::Journyx::Group::special_members{$1}
l!l&&r!l&&!r
000
$type =~ /^(.*)s$/ and $Net::Journyx::Group::special_members{$1}
!ll&&!rl&&r
000
MC/DC0%0/3
$Net::Journyx::Group::special_members{$type} or $type =~ /^(.*)s$/ and $Net::Journyx::Group::special_members{$1}
$Net::Journyx::Group::special_members{$type} $type =~ /^(.*)s$/ $Net::Journyx::Group::special_members{$1}
Truth table0%0/4
A or B and C
A= $Net::Journyx::Group::special_members{$type}B= $type =~ /^(.*)s$/C= $Net::Journyx::Group::special_members{$1}
ABCresult
1XX1
0111
00X0
0100
101 0 ▶ $type = $1 || $type;
Condition0%0/3
$1 || $type
l!l&&r!l&&!r
000
MC/DC0%0/2
$1 || $type
$1 $type
Truth table0%0/3
A || B
A= $1B= $type
ABresult
1X1
011
000
102 0 my $res = $self->jx->soap->basic_call(
103 'remove'. ucfirst($type) .'FromGroup',
104 id => $record_id,
105 group => $self->id,
106 );
107 } else {
108 0 my $res = $self->jx->soap->basic_call(
109 'removeObjectFromGroup',
110 group_id_name => $self->id,
111 object_class => $type,
112 object_id_name => $record_id,
113 );
114 }
115 }
116  
117 1 1;
« Journyx/SOAP.pm ↑ Summary Journyx/SOAP/Encoding.pm »