File Coverage

blib/lib/Net/GitHub/V3/PullRequests.pm
Criterion Covered Total %
statement 12 26 46.1
branch 0 2 0.0
condition n/a
subroutine 4 8 50.0
pod 1 3 33.3
total 17 39 43.5


line stmt bran cond sub pod time code
1             package Net::GitHub::V3::PullRequests;
2              
3 1     1   7 use Moo;
  1         2  
  1         7  
4              
5             our $VERSION = '1.05';
6             our $AUTHORITY = 'cpan:FAYLAND';
7              
8 1     1   384 use URI;
  1         2  
  1         32  
9 1     1   6 use URI::Escape;
  1         2  
  1         452  
10              
11             with 'Net::GitHub::V3::Query';
12              
13             sub pulls {
14 0     0 1   my $self = shift;
15              
16 0           return $self->query($self->_pulls_arg2url(@_));
17             }
18              
19             sub next_pull {
20 0     0 0   my $self = shift;
21              
22 0           return $self->next($self->_pulls_arg2url(@_));
23             }
24              
25             sub close_pull {
26 0     0 0   my $self = shift;
27              
28 0           return $self->close($self->_pulls_arg2url(@_));
29             }
30              
31             sub _pulls_arg2url {
32 0     0     my $self = shift @_;
33 0           my $args = pop @_;
34              
35 0           my ($user, $repos) = ($self->u, $self->repo);
36 0 0         if (scalar(@_) >= 2) {
37 0           ($user, $repos) = @_;
38             }
39              
40 0           my $uri = URI->new('/repos/' . uri_escape($user) . '/' . uri_escape($repos) . '/pulls');
41 0           $uri->query_form($args);
42 0           return $uri->as_string;
43             }
44              
45             ## build methods on fly
46             my %__methods = (
47              
48             pull => { url => "/repos/%s/%s/pulls/%s" },
49              
50             create_pull => { url => "/repos/%s/%s/pulls", method => "POST", args => 1 },
51             update_pull => { url => "/repos/%s/%s/pulls/%s", method => "PATCH", args => 1 },
52              
53             commits => { url => "/repos/%s/%s/pulls/%s/commits", paginate => 1 },
54             files => { url => "/repos/%s/%s/pulls/%s/files", paginate => 1 },
55             is_merged => { url => "/repos/%s/%s/pulls/%s/merge", check_status => 204 },
56             merge => { url => "/repos/%s/%s/pulls/%s/merge", method => "PUT" },
57              
58             # http://developer.github.com/v3/pulls/comments/
59             comments => { url => "/repos/%s/%s/pulls/%s/comments", paginate => 1 },
60             comment => { url => "/repos/%s/%s/pulls/comments/%s" },
61             create_comment => { url => "/repos/%s/%s/pulls/%s/comments", method => 'POST', args => 1 },
62             update_comment => { url => "/repos/%s/%s/pulls/comments/%s", method => 'PATCH', args => 1 },
63             delete_comment => { url => "/repos/%s/%s/pulls/comments/%s", method => 'DELETE', check_status => 204 },
64              
65             # http://developer.github.com/v3/pulls/reviews/
66             reviews => { url => "/repos/%s/%s/pulls/%s/reviews", paginate => 1 },
67             review => { url => "/repos/%s/%s/pulls/%s/reviews/%s" },
68             create_review => { url => "/repos/%s/%s/pulls/%s/reviews", method => 'POST', args => 1 },
69             delete_review => { url => "/repos/%s/%s/pulls/%s/reviews/%s", method => 'DELETE' },
70             update_review => { url => "/repos/%s/%s/pulls/%s/reviews/%s", method => 'PUT', args => 1 },
71              
72             # https://developer.github.com/v3/pulls/review_requests/
73             reviewers => { url => "/repos/%s/%s/pulls/%s/requested_reviewers", paginate => 1 },
74             add_reviewers => { url => "/repos/%s/%s/pulls/%s/requested_reviewers", method => 'POST', args => 1 },
75             delete_reviewers => { url => "/repos/%s/%s/pulls/%s/requested_reviewers", method => 'DELETE', check_status => 204, args => 1 },
76             );
77             __build_methods(__PACKAGE__, %__methods);
78              
79 1     1   8 no Moo;
  1         2  
  1         5  
80              
81             1;
82             __END__