| 1 | package Net::GitHub::V3::Repos; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 1 | our $VERSION = '1.03'; | |||||||||||||||||||||||||||
| 6 | 1 | our $AUTHORITY = 'cpan:FAYLAND'; | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use URI::Escape; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use URI; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use HTTP::Request::Common qw(POST); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 1 | with 'Net::GitHub::V3::Query'; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | sub list { | ||||||||||||||||||||||||||||
| 16 | 0 | ▶ | my ( $self, $args ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
list: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 0 | return $self->query(_repos_arg2url($args)); | |||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | sub next_repo { | ||||||||||||||||||||||||||||
| 23 | 0 | ▶ | my ( $self, $args ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
next_repo: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 0 | return $self->next(_repos_arg2url($args)); | |||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | sub close_repo { | ||||||||||||||||||||||||||||
| 29 | 0 | ▶ | my ( $self, $args ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
close_repo: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 0 | return $self->close(_repos_arg2url($args)); | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | sub _repos_arg2url { | ||||||||||||||||||||||||||||
| 35 | 0 | ▶ | my ($args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_repos_arg2url: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | # for old | ||||||||||||||||||||||||||||
| 38 | 0 | ▶ | unless (ref($args) eq 'HASH') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | 0 | $args = { type => $args }; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 0 | my $uri = URI->new('/user/repos'); | |||||||||||||||||||||||||||
| 43 | 0 | $uri->query_form($args); | |||||||||||||||||||||||||||
| 44 | 0 | return $uri->as_string; | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | sub list_all { | ||||||||||||||||||||||||||||
| 49 | 0 | ▶ | my ( $self, $since ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
list_all: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 0 | return $self->query(_all_repos_arg2url($since)); | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | sub next_all_repo { | ||||||||||||||||||||||||||||
| 55 | 0 | ▶ | my ( $self, $since ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
next_all_repo: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 0 | return $self->next(_all_repos_arg2url($since)); | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | sub close_all_repo { | ||||||||||||||||||||||||||||
| 61 | 0 | ▶ | my ( $self, $since ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
close_all_repo: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 0 | return $self->close(_all_repos_arg2url($since)); | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | sub _all_repos_arg2url { | ||||||||||||||||||||||||||||
| 67 | 0 | ▶ | my ( $since ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_all_repos_arg2url: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 68 | 0 | ▶ | $since ||= 'first'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$since ||= "first"
MC/DC0%0/1
$since ||= "first"
$since
Truth table0%0/2
A
A= $since
| |||||||||||||||||||||||||||||
| 69 | 0 | my $u = '/repositories'; | |||||||||||||||||||||||||||
| 70 | 0 | ▶ | $u .= '?since=' . $since if $since ne 'first'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 71 | 0 | return $u; | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | sub list_user { | ||||||||||||||||||||||||||||
| 75 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
list_user: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 0 | return $self->query($self->_user_repos_arg2url(@_)); | |||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | sub next_user_repo { | ||||||||||||||||||||||||||||
| 81 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
next_user_repo: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 0 | return $self->next($self->_user_repos_arg2url(@_)); | |||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | sub close_user_repo { | ||||||||||||||||||||||||||||
| 87 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
close_user_repo: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 0 | return $self->close($self->_user_repos_arg2url(@_)); | |||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | sub _user_repos_arg2url { | ||||||||||||||||||||||||||||
| 93 | 0 | ▶ | my ($self, $user, $args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_user_repos_arg2url: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 94 | 0 | ▶ | $user ||= $self->u; | ||||||||||||||||||||||||||
|
Condition0%0/3
$user ||= $self->u
MC/DC0%0/2
$user ||= $self->u
$user
$self->u
Truth table0%0/3
A ||= B
A= $userB= $self->u
| |||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | # for old | ||||||||||||||||||||||||||||
| 97 | 0 | ▶ | unless (ref($args) eq 'HASH') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 98 | 0 | $args = { type => $args }; | |||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 0 | my $uri = URI->new("/users/" . uri_escape($user) . "/repos"); | |||||||||||||||||||||||||||
| 102 | 0 | $uri->query_form($args); | |||||||||||||||||||||||||||
| 103 | 0 | return $uri->as_string; | |||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | sub list_org { | ||||||||||||||||||||||||||||
| 107 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
list_org: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | 0 | return $self->query($self->_org_repos_arg2url(@_)); | |||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | sub next_org_repo { | ||||||||||||||||||||||||||||
| 113 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
next_org_repo: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | 0 | return $self->next($self->_org_repos_arg2url(@_)); | |||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | sub close_org_repo { | ||||||||||||||||||||||||||||
| 119 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
close_org_repo: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | 0 | return $self->close($self->_org_repos_arg2url(@_)); | |||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | sub _org_repos_arg2url { | ||||||||||||||||||||||||||||
| 125 | 0 | ▶ | my ($self, $org, $type) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_org_repos_arg2url: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 126 | 0 | ▶ | $type ||= 'all'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$type ||= "all"
MC/DC0%0/1
$type ||= "all"
$type
Truth table0%0/2
A
A= $type
| |||||||||||||||||||||||||||||
| 127 | 0 | my $u = "/orgs/" . uri_escape($org) . "/repos"; | |||||||||||||||||||||||||||
| 128 | 0 | ▶ | $u .= '?type=' . $type if $type ne 'all'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 129 | 0 | return $u; | |||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | sub create { | ||||||||||||||||||||||||||||
| 134 | 0 | ▶ | my ( $self, $data ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
create: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | 0 | my $u = '/user/repos'; | |||||||||||||||||||||||||||
| 137 | 0 | ▶ | if (exists $data->{org}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 138 | 0 | my $o = delete $data->{org}; | |||||||||||||||||||||||||||
| 139 | 0 | $u = "/orgs/" . uri_escape($o) . "/repos"; | |||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | 0 | return $self->query('POST', $u, $data); | |||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | sub upload_asset { | ||||||||||||||||||||||||||||
| 146 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
upload_asset: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||
| 147 | 0 | ▶ | unshift @_, $self->u, $self->repo if @_ < 5; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 148 | 0 | my ($user, $repos, $release_id, $name, $content_type, $file_content) = @_; | |||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | 0 | my $ua = $self->ua; | |||||||||||||||||||||||||||
| 151 | 0 | my $url = $self->upload_url . "/repos/$user/$repos/releases/$release_id/assets?name=" . uri_escape($name); | |||||||||||||||||||||||||||
| 152 | 0 | my $req = HTTP::Request->new( 'POST', $url ); | |||||||||||||||||||||||||||
| 153 | 0 | $req->accept_decodable; | |||||||||||||||||||||||||||
| 154 | 0 | $req->content($file_content); | |||||||||||||||||||||||||||
| 155 | 0 | $req->header( 'Content-Type', $content_type ); | |||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | 0 | my $res = $ua->request($req); | |||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | 0 | my $data; | |||||||||||||||||||||||||||
| 160 | 0 | ▶ | if ($res->header('Content-Type') and $res->header('Content-Type') =~ 'application/json') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$res->header("Content-Type") and $res->header("Content-Type") =~ m[application/json]
MC/DC0%0/2
$res->header("Content-Type") and $res->header("Content-Type") =~ m[application/json]
$res->header("Content-Type")
$res->header("Content-Type") =~ m[application/json]
Truth table0%0/3
A and B
A= $res->header("Content-Type")B= $res->header("Content-Type") =~ m[application/json]
| |||||||||||||||||||||||||||||
| 161 | 0 | my $json = $res->decoded_content; | |||||||||||||||||||||||||||
| 162 | 0 | $data = eval { $self->json->decode($json) }; | |||||||||||||||||||||||||||
| 163 | 0 | ▶ | unless ($data) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 164 | # We tolerate bad JSON for errors, | ||||||||||||||||||||||||||||
| 165 | # otherwise we just rethrow the JSON parsing problem. | ||||||||||||||||||||||||||||
| 166 | 0 | ▶ | die unless $res->is_error; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 167 | 0 | $data = { message => $res->message }; | |||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||
| 169 | } else { | ||||||||||||||||||||||||||||
| 170 | 0 | $data = { message => $res->message }; | |||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | 0 | ▶ | return wantarray ? %$data : $data; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | sub commits { | ||||||||||||||||||||||||||||
| 177 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
commits: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | 0 | return $self->query($self->_commits_arg2url(@_)); | |||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | sub next_commit { | ||||||||||||||||||||||||||||
| 183 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
next_commit: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | 0 | return $self->next($self->_commits_arg2url(@_)); | |||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | sub close_commit { | ||||||||||||||||||||||||||||
| 189 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
close_commit: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | 0 | return $self->close($self->_commits_arg2url(@_)); | |||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | sub _commits_arg2url { | ||||||||||||||||||||||||||||
| 195 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_commits_arg2url: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 196 | 0 | ▶ | if (@_ < 2) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 197 | 0 | unshift @_, $self->repo; | |||||||||||||||||||||||||||
| 198 | 0 | unshift @_, $self->u; | |||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||
| 200 | 0 | my ($user, $repos, $args) = @_; | |||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | 0 | my $uri = URI->new("/repos/" . uri_escape($user) . "/" . uri_escape($repos) . '/commits'); | |||||||||||||||||||||||||||
| 203 | 0 | $uri->query_form($args); | |||||||||||||||||||||||||||
| 204 | 0 | return $uri->as_string; | |||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||
| 209 | sub list_deployments { | ||||||||||||||||||||||||||||
| 210 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
list_deployments: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | 0 | return $self->query($self->deployments_arg2url(@_)); | |||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | sub next_deployment { | ||||||||||||||||||||||||||||
| 216 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
next_deployment: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | 0 | return $self->next($self->deployments_arg2url(@_)); | |||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | sub close_deployment { | ||||||||||||||||||||||||||||
| 222 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
close_deployment: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | 0 | return $self->close($self->deployments_arg2url(@_)); | |||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | sub _deployments_arg2url { | ||||||||||||||||||||||||||||
| 228 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_deployments_arg2url: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 229 | 0 | ▶ | if (@_ < 2) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 230 | 0 | unshift @_, $self->repo; | |||||||||||||||||||||||||||
| 231 | 0 | unshift @_, $self->u; | |||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||
| 233 | 0 | my ($user, $repos, $args) = @_; | |||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | 0 | my $uri = URI->new("/repos/" . uri_escape($user) . "/" . uri_escape($repos) . '/deployments'); | |||||||||||||||||||||||||||
| 236 | 0 | $uri->query_form($args); | |||||||||||||||||||||||||||
| 237 | 0 | return $uri->as_string; | |||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | ## build methods on fly | ||||||||||||||||||||||||||||
| 242 | 1 | my %__methods = ( | |||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | get => { url => "/repos/%s/%s" }, | ||||||||||||||||||||||||||||
| 245 | update => { url => "/repos/%s/%s", method => 'PATCH', args => 1 }, | ||||||||||||||||||||||||||||
| 246 | contributors => { url => "/repos/%s/%s/contributors", paginate => 1 }, | ||||||||||||||||||||||||||||
| 247 | languages => { url => "/repos/%s/%s/languages" }, | ||||||||||||||||||||||||||||
| 248 | teams => { url => "/repos/%s/%s/teams", paginate => 1 }, | ||||||||||||||||||||||||||||
| 249 | tags => { url => "/repos/%s/%s/tags", paginate => 1 }, | ||||||||||||||||||||||||||||
| 250 | branches => { url => "/repos/%s/%s/branches", paginate => 1 }, | ||||||||||||||||||||||||||||
| 251 | branch => { url => "/repos/%s/%s/branches/%s" }, | ||||||||||||||||||||||||||||
| 252 | delete => { url => "/repos/%s/%s", method => 'DELETE', check_status => 204 }, | ||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | # http://developer.github.com/v3/repos/collaborators/ | ||||||||||||||||||||||||||||
| 255 | collaborators => { url => "/repos/%s/%s/collaborators", paginate => 1 }, | ||||||||||||||||||||||||||||
| 256 | is_collaborator => { url => "/repos/%s/%s/collaborators/%s", check_status => 204 }, | ||||||||||||||||||||||||||||
| 257 | add_collaborator => { url => "/repos/%s/%s/collaborators/%s", method => 'PUT', check_status => 204 }, | ||||||||||||||||||||||||||||
| 258 | delete_collaborator => { url => "/repos/%s/%s/collaborators/%s", method => 'DELETE', check_status => 204 }, | ||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||
| 260 | # http://developer.github.com/v3/repos/commits/ | ||||||||||||||||||||||||||||
| 261 | commit => { url => "/repos/%s/%s/commits/%s" }, | ||||||||||||||||||||||||||||
| 262 | comments => { url => "/repos/%s/%s/comments", paginate => 1 }, | ||||||||||||||||||||||||||||
| 263 | comment => { url => "/repos/%s/%s/comments/%s" }, | ||||||||||||||||||||||||||||
| 264 | commit_comments => { url => "/repos/%s/%s/commits/%s/comments", paginate => 1 }, | ||||||||||||||||||||||||||||
| 265 | create_comment => { url => "/repos/%s/%s/commits/%s/comments", method => 'POST', args => 1 }, | ||||||||||||||||||||||||||||
| 266 | update_comment => { url => "/repos/%s/%s/comments/%s", method => 'PATCH', args => 1 }, | ||||||||||||||||||||||||||||
| 267 | delete_comment => { url => "/repos/%s/%s/comments/%s", method => 'DELETE', check_status => 204 }, | ||||||||||||||||||||||||||||
| 268 | compare_commits => { url => "/repos/%s/%s/compare/%s...%s" }, | ||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||
| 270 | # http://developer.github.com/v3/repos/contents/ | ||||||||||||||||||||||||||||
| 271 | readme => { url => "/repos/%s/%s/readme" }, | ||||||||||||||||||||||||||||
| 272 | get_content => { url => "/repos/:owner/:repo/contents/:path", v => 2 }, | ||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | # http://developer.github.com/v3/repos/downloads/ | ||||||||||||||||||||||||||||
| 275 | downloads => { url => "/repos/%s/%s/downloads", paginate => 1 }, | ||||||||||||||||||||||||||||
| 276 | download => { url => "/repos/%s/%s/downloads/%s" }, | ||||||||||||||||||||||||||||
| 277 | delete_download => { url => "/repos/%s/%s/downloads/%s", method => 'DELETE', check_status => 204 }, | ||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | # http://developer.github.com/v3/repos/releases/ | ||||||||||||||||||||||||||||
| 280 | releases => { url => "/repos/%s/%s/releases", paginate => 1 }, | ||||||||||||||||||||||||||||
| 281 | release => { url => "/repos/%s/%s/releases/%s" }, | ||||||||||||||||||||||||||||
| 282 | create_release => { url => "/repos/%s/%s/releases", method => 'POST', args => 1 }, | ||||||||||||||||||||||||||||
| 283 | update_release => { url => "/repos/%s/%s/releases/%s", method => 'PATCH', args => 1 }, | ||||||||||||||||||||||||||||
| 284 | delete_release => { url => "/repos/%s/%s/releases/%s", method => 'DELETE', check_status => 204 }, | ||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||
| 286 | release_assets => { url => "/repos/%s/%s/releases/%s/assets", paginate => 1 }, | ||||||||||||||||||||||||||||
| 287 | release_asset => { url => "/repos/%s/%s/releases/%s/assets/%s" }, | ||||||||||||||||||||||||||||
| 288 | update_release_asset => { url => "/repos/%s/%s/releases/%s/assets/%s", method => 'PATCH', args => 1 }, | ||||||||||||||||||||||||||||
| 289 | delete_release_asset => { url => "/repos/%s/%s/releases/%s/assets/%s", method => 'DELETE', check_status => 204 }, | ||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||
| 291 | forks => { url => "/repos/%s/%s/forks", paginate => 1 }, | ||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||
| 293 | # http://developer.github.com/v3/repos/keys/ | ||||||||||||||||||||||||||||
| 294 | keys => { url => "/repos/%s/%s/keys", paginate => 1 }, | ||||||||||||||||||||||||||||
| 295 | key => { url => "/repos/%s/%s/keys/%s" }, | ||||||||||||||||||||||||||||
| 296 | create_key => { url => "/repos/%s/%s/keys", method => 'POST', args => 1 }, | ||||||||||||||||||||||||||||
| 297 | update_key => { url => "/repos/%s/%s/keys/%s", method => 'PATCH', check_status => 204, args => 1 }, | ||||||||||||||||||||||||||||
| 298 | delete_key => { url => "/repos/%s/%s/keys/%s", method => 'DELETE', check_status => 204 }, | ||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||
| 300 | # http://developer.github.com/v3/repos/watching/ | ||||||||||||||||||||||||||||
| 301 | watchers => { url => "/repos/%s/%s/watchers", paginate => 1 }, | ||||||||||||||||||||||||||||
| 302 | is_watching => { url => "/user/watched/%s/%s", is_u_repo => 1, check_status => 204 }, | ||||||||||||||||||||||||||||
| 303 | watch => { url => "/user/watched/%s/%s", is_u_repo => 1, method => 'PUT', check_status => 204 }, | ||||||||||||||||||||||||||||
| 304 | unwatch => { url => "/user/watched/%s/%s", is_u_repo => 1, method => 'DELETE', check_status => 204 }, | ||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||
| 306 | subscribers => { url => "/repos/%s/%s/subscribers", paginate => 1 }, | ||||||||||||||||||||||||||||
| 307 | subscription => { url => "/repos/%s/%s/subscription" }, | ||||||||||||||||||||||||||||
| 308 | is_subscribed => { url => "/repos/%s/%s/subscription", check_status => 200 }, | ||||||||||||||||||||||||||||
| 309 | subscribe => { url => "/repos/%s/%s/subscription", method => 'PUT', | ||||||||||||||||||||||||||||
| 310 | check_status => 200, args => 1 }, | ||||||||||||||||||||||||||||
| 311 | unsubscribe => { url => "/repos/%s/%s/subscription", method => 'DELETE', check_status => 204 }, | ||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||
| 313 | # http://developer.github.com/v3/repos/hooks/ | ||||||||||||||||||||||||||||
| 314 | hooks => { url => "/repos/%s/%s/hooks", paginate => 1 }, | ||||||||||||||||||||||||||||
| 315 | hook => { url => "/repos/%s/%s/hooks/%s" }, | ||||||||||||||||||||||||||||
| 316 | delete_hook => { url => "/repos/%s/%s/hooks/%s", method => 'DELETE', check_status => 204 }, | ||||||||||||||||||||||||||||
| 317 | test_hook => { url => "/repos/%s/%s/hooks/%s/test", method => 'POST', check_status => 204 }, | ||||||||||||||||||||||||||||
| 318 | create_hook => { url => "/repos/%s/%s/hooks", method => 'POST', args => 1 }, | ||||||||||||||||||||||||||||
| 319 | update_hook => { url => "/repos/%s/%s/hooks/%s", method => 'PATCH', args => 1 }, | ||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||
| 321 | # http://developer.github.com/v3/repos/merging/ | ||||||||||||||||||||||||||||
| 322 | merges => { url => "/repos/%s/%s/merges", method => 'POST', args => 1 }, | ||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||
| 324 | # http://developer.github.com/v3/repos/statuses/ | ||||||||||||||||||||||||||||
| 325 | list_statuses => { url => "/repos/%s/%s/statuses/%s", paginate => { name => 'status' } }, | ||||||||||||||||||||||||||||
| 326 | create_status => { url => "/repos/%s/%s/statuses/%s", method => 'POST', args => 1 }, | ||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | # https://developer.github.com/v3/repos/deployments | ||||||||||||||||||||||||||||
| 329 | create_deployment => { url => "/repos/%s/%s/deployments", method => 'POST', args => 1 }, | ||||||||||||||||||||||||||||
| 330 | create_deployment_status => { url => "/repos/%s/%s/deployments/%s/statuses", method => 'POST', args => 1}, | ||||||||||||||||||||||||||||
| 331 | list_deployment_statuses => { url => "/repos/%s/%s/deployments/%s/statuses", method => 'GET', paginate => { name => 'deployment_status' } }, | ||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||
| 333 | contributor_stats => { url => "/repos/%s/%s/stats/contributors", method => 'GET'}, | ||||||||||||||||||||||||||||
| 334 | commit_activity => { url => "/repos/%s/%s/stats/commit_activity", method => 'GET'}, | ||||||||||||||||||||||||||||
| 335 | code_frequency => { url => "/repos/%s/%s/stats/code_frequency", method => 'GET'}, | ||||||||||||||||||||||||||||
| 336 | participation => { url => "/repos/%s/%s/stats/participation", method => 'GET'}, | ||||||||||||||||||||||||||||
| 337 | punch_card => { url => "/repos/%s/%s/stats/punch_card", method => 'GET'}, | ||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||
| 339 | ); | ||||||||||||||||||||||||||||
| 340 | 1 | __build_methods(__PACKAGE__, %__methods); | |||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||
| 342 | sub create_download { | ||||||||||||||||||||||||||||
| 343 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
create_download: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||
| 345 | 0 | ▶ | if (@_ == 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 346 | 0 | unshift @_, $self->repo; | |||||||||||||||||||||||||||
| 347 | 0 | unshift @_, $self->u; | |||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||
| 349 | 0 | my ($user, $repos, $download) = @_; | |||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||
| 351 | 0 | my $file = delete $download->{file}; | |||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||
| 353 | 0 | my $u = "/repos/" . uri_escape($user) . "/" . uri_escape($repos) . '/downloads'; | |||||||||||||||||||||||||||
| 354 | 0 | my $d = $self->query('POST', $u, $download); | |||||||||||||||||||||||||||
| 355 | 0 | ▶ | if (defined $file) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 356 | 0 | return $self->upload_download($d, $file); | |||||||||||||||||||||||||||
| 357 | } else { | ||||||||||||||||||||||||||||
| 358 | 0 | return $d; | |||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||
| 362 | sub upload_download { | ||||||||||||||||||||||||||||
| 363 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
upload_download: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||
| 365 | 0 | ▶ | if (@_ < 3) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 366 | 0 | unshift @_, $self->repo; | |||||||||||||||||||||||||||
| 367 | 0 | unshift @_, $self->u; | |||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||
| 369 | 0 | my ($user, $repos, $download, $file) = @_; | |||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||
| 371 | # must successful on create_download | ||||||||||||||||||||||||||||
| 372 | 0 | ▶ | return 0 unless exists $download->{s3_url}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||
| 374 | ## POST form-data | ||||||||||||||||||||||||||||
| 375 | my %data = ( | ||||||||||||||||||||||||||||
| 376 | Content_Type => 'form-data', | ||||||||||||||||||||||||||||
| 377 | Content => [ | ||||||||||||||||||||||||||||
| 378 | 'key' => $download->{path}, | ||||||||||||||||||||||||||||
| 379 | 'acl' => $download->{acl}, | ||||||||||||||||||||||||||||
| 380 | 'success_action_status' => 201, | ||||||||||||||||||||||||||||
| 381 | 'Filename' => $download->{name}, | ||||||||||||||||||||||||||||
| 382 | 'AWSAccessKeyId' => $download->{accesskeyid}, | ||||||||||||||||||||||||||||
| 383 | 'Policy' => $download->{policy}, | ||||||||||||||||||||||||||||
| 384 | 'Signature' => $download->{signature}, | ||||||||||||||||||||||||||||
| 385 | 'Content-Type' => $download->{mime_type}, | ||||||||||||||||||||||||||||
| 386 | 0 | 'file' => [ $file ], | |||||||||||||||||||||||||||
| 387 | ], | ||||||||||||||||||||||||||||
| 388 | ); | ||||||||||||||||||||||||||||
| 389 | 0 | my $request = POST $download->{s3_url}, %data; | |||||||||||||||||||||||||||
| 390 | 0 | my $res = $self->ua->request($request); | |||||||||||||||||||||||||||
| 391 | 0 | ▶ | return $res->code == 201 ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||
| 394 | ## http://developer.github.com/v3/repos/forks/ | ||||||||||||||||||||||||||||
| 395 | sub create_fork { | ||||||||||||||||||||||||||||
| 396 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
create_fork: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||
| 398 | 0 | ▶ | if (@_ < 2) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 399 | 0 | unshift @_, $self->repo; | |||||||||||||||||||||||||||
| 400 | 0 | unshift @_, $self->u; | |||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||
| 402 | 0 | my ($user, $repos, $org) = @_; | |||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||
| 404 | 0 | my $u = "/repos/" . uri_escape($user) . "/" . uri_escape($repos) . '/forks'; | |||||||||||||||||||||||||||
| 405 | 0 | ▶ | $u .= '?org=' . $org if defined $org; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 406 | 0 | return $self->query('POST', $u); | |||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||
| 409 | ## http://developer.github.com/v3/repos/watching/ | ||||||||||||||||||||||||||||
| 410 | sub watched { | ||||||||||||||||||||||||||||
| 411 | 0 | ▶ | my ($self, $user) = @_; | ||||||||||||||||||||||||||
|
Subroutine
watched: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||
| 413 | 0 | ▶ | my $u = $user ? '/users/' . uri_escape($user). '/watched' : '/user/watched'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 414 | 0 | return $self->query($u); | |||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||
| 417 | 1 | ▶ | no Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||
| 419 | 1 | 1; | |||||||||||||||||||||||||||
| 420 | __END__ | ||||||||||||||||||||||||||||