| 1 | package WWW::Gitea; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | # ABSTRACT: Perl client for the Gitea REST API | ||||||||||||||
| 4 | |||||||||||||||
| 5 | 5 | ▶ | use Moo; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | 5 | ▶ | use Carp qw(croak); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | 5 | ▶ | use WWW::Gitea::API::Misc; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 8 | 5 | ▶ | use WWW::Gitea::API::Users; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 9 | 5 | ▶ | use WWW::Gitea::API::Repos; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 10 | 5 | ▶ | use WWW::Gitea::API::Issues; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 11 | 5 | ▶ | use WWW::Gitea::API::PullRequests; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 12 | 5 | ▶ | use WWW::Gitea::API::Labels; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 13 | 5 | ▶ | use WWW::Gitea::API::Milestones; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 14 | 5 | ▶ | use WWW::Gitea::API::Releases; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 15 | 5 | ▶ | use WWW::Gitea::API::Orgs; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 16 | 5 | ▶ | use namespace::clean; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 17 | |||||||||||||||
| 18 | 5 | our $VERSION = '0.003'; | |||||||||||||
| 19 | |||||||||||||||
| 20 | |||||||||||||||
| 21 | has url => ( | ||||||||||||||
| 22 | is => 'ro', | ||||||||||||||
| 23 | 1 | ▶ | default => sub { $ENV{GITEA_URL} }, | ||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||
| 24 | 5 | ); | |||||||||||||
| 25 | |||||||||||||||
| 26 | |||||||||||||||
| 27 | has token => ( | ||||||||||||||
| 28 | is => 'ro', | ||||||||||||||
| 29 | 5 | ▶ | default => sub { $ENV{GITEA_TOKEN} }, | ||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||
| 30 | 5 | ); | |||||||||||||
| 31 | |||||||||||||||
| 32 | |||||||||||||||
| 33 | has username => ( | ||||||||||||||
| 34 | is => 'ro', | ||||||||||||||
| 35 | 8 | ▶ | default => sub { $ENV{GITEA_USERNAME} }, | ||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||
| 36 | 5 | ); | |||||||||||||
| 37 | |||||||||||||||
| 38 | has password => ( | ||||||||||||||
| 39 | is => 'ro', | ||||||||||||||
| 40 | 8 | ▶ | default => sub { $ENV{GITEA_PASSWORD} }, | ||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||
| 41 | 5 | ); | |||||||||||||
| 42 | |||||||||||||||
| 43 | |||||||||||||||
| 44 | has api_url => ( | ||||||||||||||
| 45 | is => 'lazy', | ||||||||||||||
| 46 | 7 | ▶ | builder => sub { | ||||||||||||
|
Subroutine
_build_api_url: called CC=2 SCAR=7.1
| |||||||||||||||
| 47 | 7 | my ($self) = @_; | |||||||||||||
| 48 | 7 | ▶ | my $url = $self->url | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 49 | or croak 'url required (e.g. https://gitea.example.com)'; | ||||||||||||||
| 50 | 6 | $url =~ s{/+$}{}; | |||||||||||||
| 51 | 6 | $url =~ s{/api/v1$}{}; | |||||||||||||
| 52 | 6 | return $url . '/api/v1'; | |||||||||||||
| 53 | }, | ||||||||||||||
| 54 | 5 | ); | |||||||||||||
| 55 | |||||||||||||||
| 56 | |||||||||||||||
| 57 | 5 | with 'WWW::Gitea::Role::HTTP'; | |||||||||||||
| 58 | |||||||||||||||
| 59 | has misc => ( | ||||||||||||||
| 60 | is => 'lazy', | ||||||||||||||
| 61 | 0 | ▶ | builder => sub { WWW::Gitea::API::Misc->new(client => $_[0]) }, | ||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||
| 62 | 5 | ); | |||||||||||||
| 63 | |||||||||||||||
| 64 | |||||||||||||||
| 65 | has users => ( | ||||||||||||||
| 66 | is => 'lazy', | ||||||||||||||
| 67 | 0 | ▶ | builder => sub { WWW::Gitea::API::Users->new(client => $_[0]) }, | ||||||||||||
|
Subroutine
_build_users: not called CC=1 SCAR=1.2
Subroutine
__ANON__: called CC=1 SCAR=1.2
| |||||||||||||||
| 68 | 5 | ); | |||||||||||||
| 69 | |||||||||||||||
| 70 | |||||||||||||||
| 71 | has repos => ( | ||||||||||||||
| 72 | is => 'lazy', | ||||||||||||||
| 73 | 0 | ▶ | builder => sub { WWW::Gitea::API::Repos->new(client => $_[0]) }, | ||||||||||||
|
Subroutine
_build_repos: not called CC=1 SCAR=6.9
| |||||||||||||||
| 74 | 5 | ); | |||||||||||||
| 75 | |||||||||||||||
| 76 | |||||||||||||||
| 77 | has issues => ( | ||||||||||||||
| 78 | is => 'lazy', | ||||||||||||||
| 79 | 1 | ▶ | builder => sub { WWW::Gitea::API::Issues->new(client => $_[0]) }, | ||||||||||||
|
Subroutine
_build_issues: called CC=1 SCAR=0.0
| |||||||||||||||
| 80 | 5 | ); | |||||||||||||
| 81 | |||||||||||||||
| 82 | |||||||||||||||
| 83 | has pulls => ( | ||||||||||||||
| 84 | is => 'lazy', | ||||||||||||||
| 85 | 1 | ▶ | builder => sub { WWW::Gitea::API::PullRequests->new(client => $_[0]) }, | ||||||||||||
|
Subroutine
_build_pulls: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||
| 86 | 5 | ); | |||||||||||||
| 87 | |||||||||||||||
| 88 | |||||||||||||||
| 89 | has labels => ( | ||||||||||||||
| 90 | is => 'lazy', | ||||||||||||||
| 91 | 0 | ▶ | builder => sub { WWW::Gitea::API::Labels->new(client => $_[0]) }, | ||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=1.2
| |||||||||||||||
| 92 | 5 | ); | |||||||||||||
| 93 | |||||||||||||||
| 94 | |||||||||||||||
| 95 | has milestones => ( | ||||||||||||||
| 96 | is => 'lazy', | ||||||||||||||
| 97 | 0 | ▶ | builder => sub { WWW::Gitea::API::Milestones->new(client => $_[0]) }, | ||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||
| 98 | 5 | ); | |||||||||||||
| 99 | |||||||||||||||
| 100 | |||||||||||||||
| 101 | has releases => ( | ||||||||||||||
| 102 | is => 'lazy', | ||||||||||||||
| 103 | 0 | ▶ | builder => sub { WWW::Gitea::API::Releases->new(client => $_[0]) }, | ||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=1.2
| |||||||||||||||
| 104 | 5 | ); | |||||||||||||
| 105 | |||||||||||||||
| 106 | |||||||||||||||
| 107 | has orgs => ( | ||||||||||||||
| 108 | is => 'lazy', | ||||||||||||||
| 109 | 1 | ▶ | builder => sub { WWW::Gitea::API::Orgs->new(client => $_[0]) }, | ||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||
| 110 | 5 | ); | |||||||||||||
| 111 | |||||||||||||||
| 112 | |||||||||||||||
| 113 | 0 | ▶ | sub version { | ||||||||||||
|
Subroutine
version: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 114 | 0 | my ($self) = @_; | |||||||||||||
| 115 | 0 | return $self->misc->version; | |||||||||||||
| 116 | } | ||||||||||||||
| 117 | |||||||||||||||
| 118 | |||||||||||||||
| 119 | 0 | ▶ | sub current_user { | ||||||||||||
|
Subroutine
current_user: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 120 | 0 | my ($self) = @_; | |||||||||||||
| 121 | 0 | return $self->misc->current_user; | |||||||||||||
| 122 | } | ||||||||||||||
| 123 | |||||||||||||||
| 124 | |||||||||||||||
| 125 | |||||||||||||||
| 126 | 5 | 1; | |||||||||||||
| 127 | |||||||||||||||
| 128 | __END__ | ||||||||||||||