Pithub/Repos.pm

filter: Statementstmt 100% 123 / 123 Branchbran 83.3% 15 / 18 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 47 / 47 Podpod 100% 29 / 29 totaltotal 98.6% 214 / 217 CC 10 SCAR 3.6
CC
10
Cov
98%
rename_branch
3.1
create
3.0
list
3.0
CRAP 1.4
« Pithub/Repos/Forks.pm ↑ Summary Pithub/Issues/Assignees.pm »
1 package Pithub::Repos;
2 16 our $AUTHORITY = 'cpan:PLU';
3  
4 # ABSTRACT: Github v3 Repos API
5  
6 16 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 16 our $VERSION = '0.01043';
9  
10 16 ▶use Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
11 16 ▶use Pithub::Issues ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12 16 ▶use Pithub::Markdown ();
Subroutine BEGIN: called CC=1 SCAR=0.0
13 16 ▶use Pithub::PullRequests ();
Subroutine BEGIN: called CC=1 SCAR=0.0
14 16 ▶use Pithub::Repos::Actions ();
Subroutine BEGIN: called CC=1 SCAR=0.0
15 16 ▶use Pithub::Repos::Collaborators ();
Subroutine BEGIN: called CC=1 SCAR=0.0
16 16 ▶use Pithub::Repos::Commits ();
Subroutine BEGIN: called CC=1 SCAR=0.0
17 16 ▶use Pithub::Repos::Contents ();
Subroutine BEGIN: called CC=1 SCAR=0.0
18 16 ▶use Pithub::Repos::Downloads ();
Subroutine BEGIN: called CC=1 SCAR=0.0
19 16 ▶use Pithub::Repos::Forks ();
Subroutine BEGIN: called CC=1 SCAR=0.0
20 16 ▶use Pithub::Repos::Hooks ();
Subroutine BEGIN: called CC=1 SCAR=0.0
21 16 ▶use Pithub::Repos::Keys ();
Subroutine BEGIN: called CC=1 SCAR=0.0
22 16 ▶use Pithub::Repos::Releases ();
Subroutine BEGIN: called CC=1 SCAR=0.0
23 16 ▶use Pithub::Repos::Starring ();
Subroutine BEGIN: called CC=1 SCAR=0.0
24 16 ▶use Pithub::Repos::Stats ();
Subroutine BEGIN: called CC=1 SCAR=0.0
25 16 ▶use Pithub::Repos::Statuses ();
Subroutine BEGIN: called CC=1 SCAR=0.0
26 16 ▶use Pithub::Repos::Watching ();
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 16 extends 'Pithub::Base';
29  
30  
31 1 ▶sub actions {
Subroutine actions: called CC=1 SCAR=0.0
Pod documented
32 1 return shift->_create_instance( Pithub::Repos::Actions::, @_ );
33 }
34  
35  
36 3 ▶sub branch {
Subroutine branch: called CC=2 SCAR=6.9
Pod documented
37 3 my ( $self, %args ) = @_;
38 croak 'Missing key in parameters: branch (string)'
39 3 ▶ unless defined $args{branch};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"branch"} 1 2 3
40 2 $self->_validate_user_repo_args( \%args );
41 return $self->request(
42 method => 'GET',
43 path => sprintf(
44 '/repos/%s/%s/branches/%s', delete $args{user},
45 delete $args{repo},
46 delete $args{branch},
47 2 ),
48 %args,
49 );
50 }
51  
52  
53 9 ▶sub branches {
Subroutine branches: called CC=1 SCAR=0.0
Pod documented
54 9 my ( $self, %args ) = @_;
55 9 $self->_validate_user_repo_args( \%args );
56 return $self->request(
57 method => 'GET',
58 path => sprintf(
59 '/repos/%s/%s/branches', delete $args{user}, delete $args{repo}
60 9 ),
61 %args,
62 );
63 }
64  
65  
66 2 ▶sub rename_branch {
Subroutine rename_branch: called CC=3 SCAR=11.3
Pod documented
67 2 my ( $self, %args ) = @_;
68 2 ▶ croak 'Missing parameters: branch' unless $args{branch};
Branch: 1 branch
BranchTrueFalseTotal
unless $args{"branch"} 0 2 2
69 croak 'Missing key in parameters: data (hashref)'
70 2 ▶ unless ref $args{data} eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $args{"data"} eq "HASH" 0 2 2
71 2 $self->_validate_user_repo_args( \%args );
72 return $self->request(
73 method => 'POST',
74 path => sprintf(
75 '/repos/%s/%s/branches/%s/rename', delete $args{user},
76 delete $args{repo}, delete $args{branch}
77 2 ),
78 %args,
79 );
80 }
81  
82  
83 2 ▶sub merge_branch {
Subroutine merge_branch: called CC=2 SCAR=7.0
Pod documented
84 2 my ( $self, %args ) = @_;
85 croak 'Missing key in parameters: data (hashref)'
86 2 ▶ unless ref $args{data} eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $args{"data"} eq "HASH" 0 2 2
87 2 $self->_validate_user_repo_args( \%args );
88 return $self->request(
89 method => 'POST',
90 path => sprintf(
91 '/repos/%s/%s/merges', delete $args{user}, delete $args{repo}
92 2 ),
93 %args,
94 );
95 }
96  
97  
98 13 ▶sub collaborators {
Subroutine collaborators: called CC=1 SCAR=0.0
Pod documented
99 13 return shift->_create_instance( Pithub::Repos::Collaborators::, @_ );
100 }
101  
102  
103 13 ▶sub commits {
Subroutine commits: called CC=1 SCAR=0.0
Pod documented
104 13 return shift->_create_instance( Pithub::Repos::Commits::, @_ );
105 }
106  
107  
108 1 ▶sub contents {
Subroutine contents: called CC=1 SCAR=0.0
Pod documented
109 1 return shift->_create_instance( Pithub::Repos::Contents::, @_ );
110 }
111  
112  
113 9 ▶sub contributors {
Subroutine contributors: called CC=1 SCAR=0.0
Pod documented
114 9 my ( $self, %args ) = @_;
115 9 $self->_validate_user_repo_args( \%args );
116 return $self->request(
117 method => 'GET',
118 path => sprintf(
119 '/repos/%s/%s/contributors', delete $args{user},
120 delete $args{repo}
121 9 ),
122 %args,
123 );
124 }
125  
126  
127 6 ▶sub create {
Subroutine create: called CC=3 SCAR=11.0
Pod documented
128 6 my ( $self, %args ) = @_;
129 croak 'Missing key in parameters: data (hashref)'
130 6 ▶ unless ref $args{data} eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $args{"data"} eq "HASH" 1 5 6
131 5 ▶ if ( my $org = delete $args{org} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $org = delete $args{'org'}) { } 3 2 5
132 3 return $self->request(
133 method => 'POST',
134 path => sprintf( '/orgs/%s/repos', $org ),
135 %args,
136 );
137 }
138 else {
139 2 return $self->request(
140 method => 'POST',
141 path => '/user/repos',
142 %args,
143 );
144 }
145 }
146  
147  
148 4 ▶sub delete {
Subroutine delete: called CC=1 SCAR=0.0
Pod documented
149 4 my ( $self, %args ) = @_;
150 4 $self->_validate_user_repo_args( \%args );
151 return $self->request(
152 method => 'DELETE',
153 path =>
154 2 sprintf( '/repos/%s/%s', delete $args{user}, delete $args{repo} ),
155 %args,
156 );
157 }
158  
159  
160 13 ▶sub downloads {
Subroutine downloads: called CC=1 SCAR=0.0
Pod documented
161 13 return shift->_create_instance( Pithub::Repos::Downloads::, @_ );
162 }
163  
164  
165 13 ▶sub forks {
Subroutine forks: called CC=1 SCAR=0.0
Pod documented
166 13 return shift->_create_instance( Pithub::Repos::Forks::, @_ );
167 }
168  
169  
170 2 ▶sub get {
Subroutine get: called CC=1 SCAR=0.0
Pod documented
171 2 my ( $self, %args ) = @_;
172 2 $self->_validate_user_repo_args( \%args );
173 return $self->request(
174 method => 'GET',
175 path =>
176 2 sprintf( '/repos/%s/%s', delete $args{user}, delete $args{repo} ),
177 %args,
178 );
179 }
180  
181  
182 1 ▶sub hooks {
Subroutine hooks: called CC=1 SCAR=0.0
Pod documented
183 1 return shift->_create_instance( Pithub::Repos::Hooks::, @_ );
184 }
185  
186  
187 1 ▶sub issues {
Subroutine issues: called CC=1 SCAR=0.0
Pod documented
188 1 return shift->_create_instance( Pithub::Issues::, @_ );
189 }
190  
191  
192 13 ▶sub keys {
Subroutine keys: called CC=1 SCAR=0.0
Pod documented
193 13 return shift->_create_instance( Pithub::Repos::Keys::, @_ );
194 }
195  
196  
197 9 ▶sub languages {
Subroutine languages: called CC=1 SCAR=0.0
Pod documented
198 9 my ( $self, %args ) = @_;
199 9 $self->_validate_user_repo_args( \%args );
200 return $self->request(
201 method => 'GET',
202 path => sprintf(
203 '/repos/%s/%s/languages', delete $args{user}, delete $args{repo}
204 9 ),
205 %args,
206 );
207 }
208  
209  
210 5 ▶sub list {
Subroutine list: called CC=3 SCAR=11.0
Pod documented
211 5 my ( $self, %args ) = @_;
212 5 ▶ if ( my $user = delete $args{user} ) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $user = delete $args{'user'}) { } 2 3 5
elsif (my $org = delete $args{'org'}) { } 1 2 3
213 2 return $self->request(
214 method => 'GET',
215 path => sprintf( '/users/%s/repos', $user ),
216 %args,
217 );
218 }
219 elsif ( my $org = delete $args{org} ) {
220 1 return $self->request(
221 method => 'GET',
222 path => sprintf( '/orgs/%s/repos', $org ),
223 %args
224 );
225 }
226 else {
227 2 return $self->request(
228 method => 'GET',
229 path => '/user/repos',
230 %args,
231 );
232 }
233 }
234  
235  
236 2 ▶sub markdown {
Subroutine markdown: called CC=1 SCAR=0.0
Pod documented
237 2 my $self = shift;
238 2 return $self->_create_instance(
239 Pithub::Markdown::,
240 mode => 'gfm',
241 context => sprintf( '%s/%s', $self->user, $self->repo ),
242 @_
243 );
244 }
245  
246  
247 1 ▶sub pull_requests {
Subroutine pull_requests: called CC=1 SCAR=0.0
Pod documented
248 1 return shift->_create_instance( Pithub::PullRequests::, @_ );
249 }
250  
251  
252 3 ▶sub releases {
Subroutine releases: called CC=1 SCAR=0.0
Pod documented
253 3 return shift->_create_instance( Pithub::Repos::Releases::, @_ );
254 }
255  
256  
257 1 ▶sub starring {
Subroutine starring: called CC=1 SCAR=0.0
Pod documented
258 1 return shift->_create_instance( Pithub::Repos::Starring::, @_ );
259 }
260  
261  
262 1 ▶sub stats {
Subroutine stats: called CC=1 SCAR=0.0
Pod documented
263 1 return shift->_create_instance( Pithub::Repos::Stats::, @_ );
264 }
265  
266  
267 1 ▶sub statuses {
Subroutine statuses: called CC=1 SCAR=0.0
Pod documented
268 1 return shift->_create_instance( Pithub::Repos::Statuses::, @_ );
269 }
270  
271  
272 9 ▶sub tags {
Subroutine tags: called CC=1 SCAR=0.0
Pod documented
273 9 my ( $self, %args ) = @_;
274 9 $self->_validate_user_repo_args( \%args );
275 return $self->request(
276 method => 'GET',
277 path => sprintf(
278 '/repos/%s/%s/tags', delete $args{user}, delete $args{repo}
279 9 ),
280 %args,
281 );
282 }
283  
284  
285 9 ▶sub teams {
Subroutine teams: called CC=1 SCAR=0.0
Pod documented
286 9 my ( $self, %args ) = @_;
287 9 $self->_validate_user_repo_args( \%args );
288 return $self->request(
289 method => 'GET',
290 path => sprintf(
291 '/repos/%s/%s/teams', delete $args{user}, delete $args{repo}
292 9 ),
293 %args,
294 );
295 }
296  
297  
298 4 ▶sub update {
Subroutine update: called CC=2 SCAR=6.9
Pod documented
299 4 my ( $self, %args ) = @_;
300 croak 'Missing key in parameters: data (hashref)'
301 4 ▶ unless ref $args{data} eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $args{"data"} eq "HASH" 1 3 4
302 3 $self->_validate_user_repo_args( \%args );
303 return $self->request(
304 method => 'PATCH',
305 path =>
306 3 sprintf( '/repos/%s/%s', delete $args{user}, delete $args{repo} ),
307 %args,
308 );
309 }
310  
311  
312 13 ▶sub watching {
Subroutine watching: called CC=1 SCAR=0.0
Pod documented
313 13 return shift->_create_instance( Pithub::Repos::Watching::, @_ );
314 }
315  
316 16 1;
317  
318 __END__
« Pithub/Repos/Forks.pm ↑ Summary Pithub/Issues/Assignees.pm »