File Coverage

blib/lib/Pithub/Repos/Statuses.pm
Criterion Covered Total %
statement 16 17 94.1
branch 2 4 50.0
condition n/a
subroutine 4 4 100.0
pod 2 2 100.0
total 24 27 88.8


line stmt bran cond sub pod time code
1             package Pithub::Repos::Statuses;
2             our $AUTHORITY = 'cpan:PLU';
3             our $VERSION = '0.01039';
4             # ABSTRACT: Github v3 repos / statuses API
5              
6 15     15   88 use Moo;
  15         26  
  15         71  
7 15     15   3973 use Carp qw( croak );
  15         54  
  15         4578  
8              
9             extends 'Pithub::Base';
10              
11              
12             sub list {
13 2     2 1 1860 my ($self, %args) = @_;
14              
15 2         14 $self->_validate_user_repo_args( \%args );
16             my $req = {
17             method => 'GET',
18             path => sprintf(
19             '/repos/%s/%s/statuses/%s',
20             delete $args{user}, delete $args{repo}, delete $args{ref}
21 2         27 ),
22             %args
23             };
24 2         14 return $self->request(%$req);
25             }
26              
27              
28             sub create {
29 2     2 1 7946 my ($self, %args) = @_;
30 2         20 $self->_validate_user_repo_args( \%args );
31             croak 'Missing state paramenter. Must be one of pending, success, error or failure'
32 2 50       9 unless $args{data}->{state};
33              
34 2 50       19 unless ($args{data}->{state} =~ m/^(?:pending|success|error|failure)$/) {
35             croak 'state param must be one of pending, success, error, failure. Was ' .
36 0         0 $args{data}->{state};
37             }
38              
39             my $req = {
40             method => 'POST',
41             path => sprintf(
42             '/repos/%s/%s/statuses/%s',
43             delete $args{user}, delete $args{repo}, delete $args{sha},
44 2         29 ),
45             %args
46             };
47              
48 2         17 return $self->request(%$req);
49             }
50              
51              
52             1;
53              
54             __END__