API/Messages.pm

filter: Statementstmt 90.0% 45 / 50 Branchbran 37.5% 3 / 8 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 86.6% 13 / 15 Podpod 0.0% 0 / 4 totaltotal 72.4% 63 / 87 CC 7 SCAR 11.0
CC
7
Cov
78%
_init
7.5
query_path
3.7
is_allowed_sort
2.0
CRAP 3.0
« API/Collection.pm ↑ Summary API/StackEntry.pm »
1 package WWW::Ohloh::API::Messages;
2 4 our $AUTHORITY = 'cpan:YANICK';
3  
4 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 4 ▶use Object::InsideOut qw/ WWW::Ohloh::API::Collection /;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 4 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 4 ▶use XML::LibXML;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 4 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 4 ▶use List::MoreUtils qw/ any /;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 4 ▶use WWW::Ohloh::API::Message;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 4 our $VERSION = '1.0_1';
16  
17 4 my @account_of : Field : Arg(name => 'account') : Get(account);
18  
19 4 my @project_of : Field : Arg(name => 'project') : Get(project);
20  
21 4 my @ALLOWED_SORTING;
22 4 Readonly @ALLOWED_SORTING => qw/ /; # TODO
23  
24 1 ▶sub element { return 'WWW::Ohloh::API::Message' }
Subroutine element: called CC=1 SCAR=0.0
Pod undocumented
25 1 ▶sub element_name { return 'message' }
Subroutine element_name: called CC=1 SCAR=0.0
Pod undocumented
26  
27 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
28  
29 1 ▶sub query_path {
Subroutine query_path: called CC=3 SCAR=13.0
Pod undocumented
30 1 my $self = shift;
31  
32 1 my $path;
33  
34 1 ▶ if ( $self->account ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->account) { } 1 0 1
elsif ($self->project) { } 0 0 0
35 1 $path = 'accounts/' . $self->account;
36 }
37 elsif ( $self->project ) {
38 0 $path = 'projects/' . $self->project;
39 }
40 else {
41 0 croak "needs to have either an acccount or a project";
42 }
43  
44 1 $path .= '/messages.xml';
45  
46 1 return $path;
47 }
48  
49 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
50  
51 1 ▶sub _init : Init {
Subroutine _init: called CC=5 SCAR=20.1
52 1 my $self = shift;
53  
54 1 ▶ croak "must use only one of the arguments 'account' and 'project'"
Branch: 1 branch
BranchTrueFalseTotal
if $self->project and $self->account 0 1 1
Condition33%1/3
$self->project and $self->account
!ll&&!rl&&r
100
MC/DC0%0/2
$self->project and $self->account
$self->project $self->account
Truth table33%1/3
A and B
A= $self->projectB= $self->account
ABresult
0X0
100
111
55 if $self->project and $self->account;
56  
57 1 ▶ croak "must use one of the arguments 'account' or 'project'"
Branch: 1 branch
BranchTrueFalseTotal
unless $self->project or $self->account 0 1 1
Condition33%1/3
$self->project or $self->account
l!l&&r!l&&!r
010
MC/DC0%0/2
$self->project or $self->account
$self->project $self->account
Truth table33%1/3
A or B
A= $self->projectB= $self->account
ABresult
1X1
011
000
58 unless $self->project
59 or $self->account;
60 4 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
61  
62 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
63  
64 0 ▶sub is_allowed_sort {
Subroutine is_allowed_sort: not called CC=1 SCAR=6.9
Pod undocumented
65 0 my $s = shift;
66 0 ▶ return any { $s eq $_ } @ALLOWED_SORTING;
Subroutine __ANON__: not called CC=1 SCAR=6.9
67 }
68  
69 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
70  
71 4 'end of WWW::Ohloh::API::Messages';
72  
73 __END__
« API/Collection.pm ↑ Summary API/StackEntry.pm »