Gitea/API/Releases.pm

filter: Statementstmt 30.3% 17 / 56 Branchbran 0.0% 0 / 40 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 38.4% 5 / 13 Podpod 100% 6 / 6 totaltotal 24.3% 28 / 115 CC 21 SCAR 27.6
CC
21
Cov
18%
list
20.0
create
20.0
get
20.0
CRAP 15.8
« Gitea/API/PullRequests.pm ↑ Summary Gitea/API/Milestones.pm »
1 package WWW::Gitea::API::Releases;
2  
3 # ABSTRACT: Gitea repository releases API
4  
5 4 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use WWW::Gitea::Release;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10  
11 4 has client => (
12 is => 'ro',
13 required => 1,
14 weak_ref => 1,
15 );
16  
17  
18 has openapi_operations => (
19 is => 'lazy',
20 builder => sub {
21 return {
22 1 ▶ 'releases.list' => { method => 'GET', path => '/repos/{owner}/{repo}/releases' },
Subroutine _build_openapi_operations: called CC=1 SCAR=1.2
Subroutine __ANON__: not called CC=1 SCAR=1.2
23 'releases.create' => { method => 'POST', path => '/repos/{owner}/{repo}/releases' },
24 'releases.get' => { method => 'GET', path => '/repos/{owner}/{repo}/releases/{id}' },
25 'releases.get_by_tag' => { method => 'GET', path => '/repos/{owner}/{repo}/releases/tags/{tag}' },
26 'releases.edit' => { method => 'PATCH', path => '/repos/{owner}/{repo}/releases/{id}' },
27 'releases.delete' => { method => 'DELETE', path => '/repos/{owner}/{repo}/releases/{id}' },
28 };
29 },
30 4 );
31  
32  
33 4 with 'WWW::Gitea::Role::OpenAPI';
34  
35 sub _wrap {
36 0 ▶ my ($self, $data, $owner, $repo) = @_;
Subroutine _wrap: not called CC=3 SCAR=24.8
37 0 ▶ return WWW::Gitea::Release->new(
Branch: 2 branches
BranchTrueFalseTotal
defined $owner ? : 0 0 0
defined $repo ? : 0 0 0
38 client => $self->client,
39 data => $data,
40 (defined $owner ? (owner => $owner) : ()),
41 (defined $repo ? (repo => $repo) : ()),
42 );
43 }
44  
45 sub list {
46 0 ▶ my ($self, $owner, $repo, %query) = @_;
Subroutine list: not called CC=4 SCAR=30.0
Pod documented
47 0 ▶ croak 'owner required' unless defined $owner;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $owner 0 0 0
48 0 ▶ croak 'repo required' unless defined $repo;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $repo 0 0 0
49 0 my $data = $self->call_operation('releases.list',
50 path => { owner => $owner, repo => $repo }, query => \%query);
51 0 ▶ return [ map { $self->_wrap($_, $owner, $repo) } @{ $data || [] } ];
Branch: 1 branch
BranchTrueFalseTotal
$data or [] 0 0 0
52 }
53  
54  
55 sub create {
56 0 ▶ my ($self, $owner, $repo, %args) = @_;
Subroutine create: not called CC=4 SCAR=30.0
Pod documented
57 0 ▶ croak 'owner required' unless defined $owner;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $owner 0 0 0
58 0 ▶ croak 'repo required' unless defined $repo;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $repo 0 0 0
59 0 ▶ croak 'tag_name required' unless defined $args{tag_name};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"tag_name"} 0 0 0
60 0 my $data = $self->call_operation('releases.create',
61 path => { owner => $owner, repo => $repo }, body => \%args);
62 0 return $self->_wrap($data, $owner, $repo);
63 }
64  
65  
66 sub get {
67 0 ▶ my ($self, $owner, $repo, $id) = @_;
Subroutine get: not called CC=4 SCAR=30.0
Pod documented
68 0 ▶ croak 'owner required' unless defined $owner;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $owner 0 0 0
69 0 ▶ croak 'repo required' unless defined $repo;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $repo 0 0 0
70 0 ▶ croak 'id required' unless defined $id;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $id 0 0 0
71 0 my $data = $self->call_operation('releases.get',
72 path => { owner => $owner, repo => $repo, id => $id });
73 0 return $self->_wrap($data, $owner, $repo);
74 }
75  
76  
77 sub get_by_tag {
78 0 ▶ my ($self, $owner, $repo, $tag) = @_;
Subroutine get_by_tag: not called CC=4 SCAR=30.0
Pod documented
79 0 ▶ croak 'owner required' unless defined $owner;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $owner 0 0 0
80 0 ▶ croak 'repo required' unless defined $repo;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $repo 0 0 0
81 0 ▶ croak 'tag required' unless defined $tag;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $tag 0 0 0
82 0 my $data = $self->call_operation('releases.get_by_tag',
83 path => { owner => $owner, repo => $repo, tag => $tag });
84 0 return $self->_wrap($data, $owner, $repo);
85 }
86  
87  
88 sub edit {
89 0 ▶ my ($self, $owner, $repo, $id, %args) = @_;
Subroutine edit: not called CC=4 SCAR=30.0
Pod documented
90 0 ▶ croak 'owner required' unless defined $owner;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $owner 0 0 0
91 0 ▶ croak 'repo required' unless defined $repo;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $repo 0 0 0
92 0 ▶ croak 'id required' unless defined $id;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $id 0 0 0
93 0 my $data = $self->call_operation('releases.edit',
94 path => { owner => $owner, repo => $repo, id => $id }, body => \%args);
95 0 return $self->_wrap($data, $owner, $repo);
96 }
97  
98  
99 sub delete {
100 0 ▶ my ($self, $owner, $repo, $id) = @_;
Subroutine delete: not called CC=4 SCAR=30.0
Pod documented
101 0 ▶ croak 'owner required' unless defined $owner;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $owner 0 0 0
102 0 ▶ croak 'repo required' unless defined $repo;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $repo 0 0 0
103 0 ▶ croak 'id required' unless defined $id;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $id 0 0 0
104 0 return $self->call_operation('releases.delete',
105 path => { owner => $owner, repo => $repo, id => $id });
106 }
107  
108  
109  
110 4 1;
111  
112 __END__
« Gitea/API/PullRequests.pm ↑ Summary Gitea/API/Milestones.pm »