File Coverage

blib/lib/Pithub/Repos/Commits.pm
Criterion Covered Total %
statement 41 41 100.0
branch 20 20 100.0
condition n/a
subroutine 10 10 100.0
pod 8 8 100.0
total 79 79 100.0


line stmt bran cond sub pod time code
1             package Pithub::Repos::Commits;
2             our $AUTHORITY = 'cpan:PLU';
3             our $VERSION = '0.01039';
4             # ABSTRACT: Github v3 Repo Commits API
5              
6 15     15   88 use Moo;
  15         33  
  15         73  
7 15     15   3924 use Carp qw( croak );
  15         30  
  15         9994  
8             extends 'Pithub::Base';
9              
10              
11             sub compare {
12 3     3 1 1866 my ( $self, %args ) = @_;
13 3 100       17 croak 'Missing key in parameters: base' unless $args{base};
14 2 100       10 croak 'Missing key in parameters: head' unless $args{head};
15 1         8 $self->_validate_user_repo_args( \%args );
16             return $self->request(
17             method => 'GET',
18 1         12 path => sprintf( '/repos/%s/%s/compare/%s...%s', delete $args{user}, delete $args{repo}, delete $args{base}, delete $args{head} ),
19             %args,
20             );
21             }
22              
23              
24             sub create_comment {
25 6     6 1 9610 my ( $self, %args ) = @_;
26 6 100       27 croak 'Missing key in parameters: sha' unless $args{sha};
27 5 100       31 croak 'Missing key in parameters: data (hashref)' unless ref $args{data} eq 'HASH';
28 3         24 $self->_validate_user_repo_args( \%args );
29             return $self->request(
30             method => 'POST',
31 3         39 path => sprintf( '/repos/%s/%s/commits/%s/comments', delete $args{user}, delete $args{repo}, delete $args{sha} ),
32             %args,
33             );
34             }
35              
36              
37             sub delete_comment {
38 4     4 1 3545 my ( $self, %args ) = @_;
39 4 100       22 croak 'Missing key in parameters: comment_id' unless $args{comment_id};
40 3         15 $self->_validate_user_repo_args( \%args );
41             return $self->request(
42             method => 'DELETE',
43 3         31 path => sprintf( '/repos/%s/%s/comments/%s', delete $args{user}, delete $args{repo}, delete $args{comment_id} ),
44             %args,
45             );
46             }
47              
48              
49             sub get {
50 3     3 1 2513 my ( $self, %args ) = @_;
51 3 100       19 croak 'Missing key in parameters: sha' unless $args{sha};
52 2         12 $self->_validate_user_repo_args( \%args );
53             return $self->request(
54             method => 'GET',
55 2         27 path => sprintf( '/repos/%s/%s/commits/%s', delete $args{user}, delete $args{repo}, delete $args{sha} ),
56             %args,
57             );
58             }
59              
60              
61             sub get_comment {
62 3     3 1 2417 my ( $self, %args ) = @_;
63 3 100       19 croak 'Missing key in parameters: comment_id' unless $args{comment_id};
64 2         27 $self->_validate_user_repo_args( \%args );
65             return $self->request(
66             method => 'GET',
67 2         23 path => sprintf( '/repos/%s/%s/comments/%s', delete $args{user}, delete $args{repo}, delete $args{comment_id} ),
68             %args,
69             );
70             }
71              
72              
73             sub list {
74 19     19 1 2252 my ( $self, %args ) = @_;
75 19         68 $self->_validate_user_repo_args( \%args );
76             return $self->request(
77             method => 'GET',
78 13         77 path => sprintf( '/repos/%s/%s/commits', delete $args{user}, delete $args{repo} ),
79             %args,
80             );
81             }
82              
83              
84             sub list_comments {
85 3     3 1 2881 my ( $self, %args ) = @_;
86 3         30 $self->_validate_user_repo_args( \%args );
87 3 100       17 if ( my $sha = delete $args{sha} ) {
88             return $self->request(
89             method => 'GET',
90 2         21 path => sprintf( '/repos/%s/%s/commits/%s/comments', delete $args{user}, delete $args{repo}, $sha ),
91             %args,
92             );
93             }
94             return $self->request(
95             method => 'GET',
96 1         9 path => sprintf( '/repos/%s/%s/comments', delete $args{user}, delete $args{repo} ),
97             %args,
98             );
99             }
100              
101              
102             sub update_comment {
103 6     6 1 4791 my ( $self, %args ) = @_;
104 6 100       28 croak 'Missing key in parameters: comment_id' unless $args{comment_id};
105 5 100       29 croak 'Missing key in parameters: data (hashref)' unless ref $args{data} eq 'HASH';
106 3         15 $self->_validate_user_repo_args( \%args );
107             return $self->request(
108             method => 'PATCH',
109 3         26 path => sprintf( '/repos/%s/%s/comments/%s', delete $args{user}, delete $args{repo}, delete $args{comment_id} ),
110             %args,
111             );
112             }
113              
114             1;
115              
116             __END__