File Coverage

blib/lib/WWW/Ohloh/API/Messages.pm
Criterion Covered Total %
statement 35 43 81.4
branch 1 8 12.5
condition 0 6 0.0
subroutine 12 15 80.0
pod 0 4 0.0
total 48 76 63.1


line stmt bran cond sub pod time code
1             package WWW::Ohloh::API::Messages;
2             our $AUTHORITY = 'cpan:YANICK';
3              
4 4     4   262141 use strict;
  4         8  
  4         181  
5 4     4   24 use warnings;
  4         9  
  4         333  
6              
7 4     4   947 use Object::InsideOut qw/ WWW::Ohloh::API::Collection /;
  4         71452  
  4         28  
8              
9 4     4   787 use Carp;
  4         8  
  4         339  
10 4     4   1099 use XML::LibXML;
  4         36027  
  4         29  
11 4     4   1692 use Readonly;
  4         3226  
  4         269  
12 4     4   719 use List::MoreUtils qw/ any /;
  4         13184  
  4         67  
13 4     4   5810 use WWW::Ohloh::API::Message;
  4         21  
  4         36  
14              
15             our $VERSION = '1.0_1';
16              
17             my @account_of : Field : Arg(name => 'account') : Get(account);
18              
19             my @project_of : Field : Arg(name => 'project') : Get(project);
20              
21             my @ALLOWED_SORTING;
22             Readonly @ALLOWED_SORTING => qw/ /; # TODO
23              
24 1     1 0 3 sub element { return 'WWW::Ohloh::API::Message' }
25 1     1 0 19 sub element_name { return 'message' }
26              
27             #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
28              
29             sub query_path {
30 1     1 0 28 my $self = shift;
31              
32 1         5 my $path;
33              
34 1 50       44 if ( $self->account ) {
    0          
35 1         35 $path = 'accounts/' . $self->account;
36             }
37             elsif ( $self->project ) {
38 0         0 $path = 'projects/' . $self->project;
39             }
40             else {
41 0         0 croak "needs to have either an acccount or a project";
42             }
43              
44 1         11 $path .= '/messages.xml';
45              
46 1         13 return $path;
47             }
48              
49             #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
50              
51             sub _init : Init {
52 0     0     my $self = shift;
53              
54 0 0 0       croak "must use only one of the arguments 'account' and 'project'"
55             if $self->project and $self->account;
56              
57 0 0 0       croak "must use one of the arguments 'account' or 'project'"
58             unless $self->project
59             or $self->account;
60 4     4   1781 }
  4         10  
  4         25  
61              
62             #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
63              
64             sub is_allowed_sort {
65 0     0 0   my $s = shift;
66 0     0     return any { $s eq $_ } @ALLOWED_SORTING;
  0            
67             }
68              
69             #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
70              
71             'end of WWW::Ohloh::API::Messages';
72              
73             __END__