File Coverage

blib/lib/Net/GitHub/V3/Issues.pm
Criterion Covered Total %
statement 9 39 23.0
branch 0 18 0.0
condition n/a
subroutine 3 6 50.0
pod 3 3 100.0
total 15 66 22.7


line stmt bran cond sub pod time code
1             package Net::GitHub::V3::Issues;
2              
3 1     1   4 use Moo;
  1         1  
  1         4  
4              
5             our $VERSION = '0.60';
6             our $AUTHORITY = 'cpan:FAYLAND';
7              
8 1     1   193 use URI::Escape;
  1         2  
  1         449  
9              
10             with 'Net::GitHub::V3::Query';
11              
12             sub issues {
13 0     0 1   my $self = shift;
14 0 0         my $args = @_ % 2 ? shift : { @_ };
15              
16 0           my @p;
17 0           foreach my $p (qw/filter state labels sort direction since/) {
18 0 0         push @p, "$p=" . $args->{$p} if exists $args->{$p};
19             }
20 0           my $u = '/issues';
21 0 0         $u .= '?' . join('&', @p) if @p;
22 0           return $self->query($u);
23             }
24              
25             sub repos_issues {
26 0     0 1   my $self = shift;
27              
28 0 0         if (@_ < 2) {
29 0           unshift @_, $self->repo;
30 0           unshift @_, $self->u;
31             }
32 0           my ($user, $repos, $args) = @_;
33              
34 0           my @p;
35 0           foreach my $p (qw/milestone state assignee mentioned labels sort direction since/) {
36 0 0         push @p, "$p=" . $args->{$p} if exists $args->{$p};
37             }
38 0           my $u = "/repos/" . uri_escape($user) . "/" . uri_escape($repos) . '/issues';
39 0 0         $u .= '?' . join('&', @p) if @p;
40 0           return $self->query($u);
41             }
42              
43             ## build methods on fly
44             my %__methods = (
45              
46             issue => { url => "/repos/%s/%s/issues/%s" },
47             create_issue => { url => "/repos/%s/%s/issues", method => 'POST', args => 1 },
48             update_issue => { url => "/repos/%s/%s/issues/%s", method => 'PATCH', args => 1 },
49              
50             ## http://developer.github.com/v3/issues/comments/
51             comments => { url => "/repos/%s/%s/issues/%s/comments" },
52             comment => { url => "/repos/%s/%s/issues/comments/%s" },
53             create_comment => { url => "/repos/%s/%s/issues/%s/comments", method => 'POST', args => 1 },
54             update_comment => { url => "/repos/%s/%s/issues/comments/%s", method => 'PATCH', args => 1 },
55             delete_comment => { url => "/repos/%s/%s/issues/comments/%s", method => 'DELETE', check_status => 204 },
56              
57             # http://developer.github.com/v3/issues/events/
58             events => { url => "/repos/%s/%s/issues/%s/events" },
59             repos_events => { url => "/repos/%s/%s/issues/events" },
60             event => { url => "/repos/%s/%s/issues/events/%s" },
61              
62             # http://developer.github.com/v3/issues/labels/
63             labels => { url => "/repos/%s/%s/labels" },
64             label => { url => "/repos/%s/%s/labels/%s" },
65             create_label => { url => "/repos/%s/%s/labels", method => 'POST', args => 1 },
66             update_label => { url => "/repos/%s/%s/labels/%s", method => 'PATCH', args => 1 },
67             delete_label => { url => "/repos/%s/%s/labels/%s", method => 'DELETE', check_status => 204 },
68             issue_labels => { url => "/repos/%s/%s/issues/%s/labels" },
69             create_issue_label => { url => "/repos/%s/%s/issues/%s/labels", method => 'POST', args => 1 },
70             delete_issue_label => { url => "/repos/%s/%s/issues/%s/labels/%s", method => 'DELETE', check_status => 204 },
71             replace_issue_label => { url => "/repos/%s/%s/issues/%s/labels", method => 'PUT', args => 1 },
72             delete_issue_labels => { url => "/repos/%s/%s/issues/%s/labels", method => 'DELETE', check_status => 204 },
73             milestone_labels => { url => "/repos/%s/%s/milestones/%s/labels" },
74              
75             # http://developer.github.com/v3/issues/milestones/
76             milestone => { url => "/repos/%s/%s/milestones/%s" },
77             create_milestone => { url => "/repos/%s/%s/milestones", method => 'POST', args => 1 },
78             update_milestone => { url => "/repos/%s/%s/milestones/%s", method => 'PATCH', args => 1 },
79             delete_milestone => { url => "/repos/%s/%s/milestones/%s", method => 'DELETE', check_status => 204 },
80              
81             );
82             __build_methods(__PACKAGE__, %__methods);
83              
84             ## http://developer.github.com/v3/issues/milestones/
85             sub milestones {
86 0     0 1   my $self = shift;
87              
88 0 0         if (@_ < 3) {
89 0           unshift @_, $self->repo;
90 0           unshift @_, $self->u;
91             }
92 0           my ($user, $repos, $args) = @_;
93              
94 0           my @p;
95 0           foreach my $p (qw/state sort direction/) {
96 0 0         push @p, "$p=" . $args->{$p} if exists $args->{$p};
97             }
98 0           my $u = "/repos/" . uri_escape($user) . "/" . uri_escape($repos) . '/milestones';
99 0 0         $u .= '?' . join('&', @p) if @p;
100 0           return $self->query($u);
101             }
102              
103 1     1   4 no Moo;
  1         1  
  1         3  
104              
105             1;
106             __END__