lib/Net/API/CPAN/Mirrors.pm

filter: Statementstmt 97.0% 33 / 34 Branchbran 50.0% 4 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 91.6% 11 / 12 Podpod 100% 5 / 5 totaltotal 89.8% 53 / 59 CC 5 SCAR 8.7
CC
5
Cov
88%
init
5.3
object
2.0
BEGIN
1.0
CRAP 2.4
« lib/Net/API/CPAN/Diff.pm ↑ Summary lib/Net/API/CPAN/Permission.pm »
1 ##----------------------------------------------------------------------------
2 ## Meta CPAN API - ~/lib/Net/API/CPAN/Mirrors.pm
3 ## Version v0.1.0
4 ## Copyright(c) 2023 DEGUEST Pte. Ltd.
5 ## Author: Jacques Deguest <jack@deguest.jp>
6 ## Created 2023/07/25
7 ## Modified 2023/09/26
8 ## All rights reserved
9 ##
10 ##
11 ## This program is free software; you can redistribute it and/or modify it
12 ## under the same terms as Perl itself.
13 ##----------------------------------------------------------------------------
14 # This module file has been automatically generated. Any change made here will be lost.
15 # Edit the script in ./build/build_modules.pl instead
16 package Net::API::CPAN::Mirrors;
17 BEGIN
18 {
19 2 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 2 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 2 ▶ use parent qw( Net::API::CPAN::Generic );
Subroutine BEGIN: called CC=1 SCAR=0.0
22 2 ▶ use vars qw( $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
23 2 ▶ our $VERSION = 'v0.1.0';
Subroutine BEGIN: called CC=1 SCAR=0.0
24 };
25  
26 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 sub init
30 {
31 1 ▶ my $self = shift( @_ );
Subroutine init: called CC=5 SCAR=16.6
Pod documented
32 1 ▶ $self->{mirrors} = [] unless( CORE::exists( $self->{mirrors} ) );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"mirrors"} 1 0 1
33 1 $self->{object} = 'mirrors';
34 1 ▶ $self->{took} = undef unless( CORE::exists( $self->{took} ) );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"took"} 1 0 1
35 1 ▶ $self->{total} = undef unless( CORE::exists( $self->{total} ) );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"total"} 1 0 1
36 1 $self->{_init_strict_use_sub} = 1;
37 1 $self->{_exception_class} = 'Net::API::CPAN::Exception';
38 1 ▶ $self->SUPER::init( @_ ) || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->SUPER::init(@_) or return $self->pass_error 0 1 1
39 1 $self->{fields} = [qw( mirrors took total )];
40 1 return( $self );
41 }
42  
43 2 ▶sub mirrors { return( shift->_set_get_object_array_object( 'mirrors', 'Net::API::CPAN::Mirror', @_ ) ); }
Subroutine mirrors: called CC=1 SCAR=0.0
Pod documented
44  
45 0 ▶sub object { return( shift->_set_get_scalar_as_object( 'object', @_ ) ); }
Subroutine object: not called CC=1 SCAR=6.9
Pod documented
46  
47 2 ▶sub took { return( shift->_set_get_number( 'took', @_ ) ); }
Subroutine took: called CC=1 SCAR=0.0
Pod documented
48  
49 2 ▶sub total { return( shift->_set_get_number( 'total', @_ ) ); }
Subroutine total: called CC=1 SCAR=0.0
Pod documented
50  
51 2 1;
52 # NOTE: POD
53 __END__
54  
55 =encoding utf-8
56  
57 =head1 NAME
58  
59 Net::API::CPAN::Mirrors - Meta CPAN API Mirrors Class
60  
61 =head1 SYNOPSIS
62  
63 use Net::API::CPAN::Mirrors;
64 my $obj = Net::API::CPAN::Mirrors->new( {
65 mirrors => [
66 {
67 ccode => "zz",
68 city => "Everywhere",
69 contact => [
70 {
71 contact_site => "perl.org",
72 contact_user => "cpan",
73 },
74 ],
75 continent => "Global",
76 country => "Global",
77 distance => undef,
78 dnsrr => "N",
79 freq => "instant",
80 http => "http://www.cpan.org/",
81 inceptdate => "2021-04-09T00:00:00",
82 location => [
83 0,
84 0,
85 ],
86 name => "www.cpan.org",
87 org => "Global CPAN CDN",
88 src => "rsync://cpan-rsync.perl.org/CPAN/",
89 tz => 0,
90 },
91 ],
92 took => 2,
93 total => 1,
94 } ) || die( Net::API::CPAN::Mirrors->error );
95
96 my $array = $obj->mirrors;
97 my $str = $obj->object;
98 my $num = $obj->took;
99 my $num = $obj->total;
100  
101 =head1 VERSION
102  
103 v0.1.0
104  
105 =head1 DESCRIPTION
106  
107 This class serves to retrieve and manipulate mirrors.
108  
109 It inherits from L<Net::API::CPAN::Generic>
110  
111 =head1 CONSTRUCTOR
112  
113 =head2 new
114  
115 Provided with an hash or hash reference of parameters, and this instantiates a new C<Net::API::CPAN::Mirrors> object.
116  
117 The parameters that can be provided bear the same name and supports the same values as the methods below.
118  
119 =head1 METHODS
120  
121 =head2 mirrors
122  
123 $obj->mirrors( [
124 {
125 ccode => "zz",
126 city => "Everywhere",
127 contact => [
128 {
129 contact_site => "perl.org",
130 contact_user => "cpan",
131 },
132 ],
133 continent => "Global",
134 country => "Global",
135 distance => undef,
136 dnsrr => "N",
137 freq => "instant",
138 http => "http://www.cpan.org/",
139 inceptdate => "2021-04-09T00:00:00",
140 location => [
141 0,
142 0,
143 ],
144 name => "www.cpan.org",
145 org => "Global CPAN CDN",
146 src => "rsync://cpan-rsync.perl.org/CPAN/",
147 tz => 0,
148 },
149 ] );
150 my $array = $obj->mirrors;
151  
152 Sets or gets an array of L<Net::API::CPAN::Mirror> objects, or creates an L<Net::API::CPAN::Mirror> instance for each mirrors provided in the array, and returns an L<array object|Module::Generic::Array>, even if no value was provided.
153  
154 =head2 object
155  
156 Returns the object type for this class, which is C<mirrors>
157  
158 =head2 took
159  
160 $obj->took(2);
161 my $number = $obj->took;
162  
163 Sets or gets an integer value, and returns a L<number object|Module::Generic::Number> or C<undef> if no value is set.
164  
165 =head2 total
166  
167 $obj->total(1);
168 my $number = $obj->total;
169  
170 Sets or gets an integer value, and returns a L<number object|Module::Generic::Number> or C<undef> if no value is set.
171  
172 =head1 API SAMPLE
173  
174 {
175 "mirrors" : [
176 {
177 "ccode" : "zz",
178 "city" : "Everywhere",
179 "contact" : [
180 {
181 "contact_site" : "perl.org",
182 "contact_user" : "cpan"
183 }
184 ],
185 "continent" : "Global",
186 "country" : "Global",
187 "distance" : null,
188 "dnsrr" : "N",
189 "freq" : "instant",
190 "http" : "http://www.cpan.org/",
191 "inceptdate" : "2021-04-09T00:00:00",
192 "location" : [
193 0,
194 0
195 ],
196 "name" : "www.cpan.org",
197 "org" : "Global CPAN CDN",
198 "src" : "rsync://cpan-rsync.perl.org/CPAN/",
199 "tz" : "0"
200 }
201 ],
202 "took" : 2,
203 "total" : 1
204 }
205  
206 =head1 AUTHOR
207  
208 Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
209  
210 =head1 SEE ALSO
211  
212 L<Net::API::CPAN>, L<Net::API::CPAN::Activity>, L<Net::API::CPAN::Author>, L<Net::API::CPAN::Changes>, L<Net::API::CPAN::Changes::Release>, L<Net::API::CPAN::Contributor>, L<Net::API::CPAN::Cover>, L<Net::API::CPAN::Diff>, L<Net::API::CPAN::Distribution>, L<Net::API::CPAN::DownloadUrl>, L<Net::API::CPAN::Favorite>, L<Net::API::CPAN::File>, L<Net::API::CPAN::Module>, L<Net::API::CPAN::Package>, L<Net::API::CPAN::Permission>, L<Net::API::CPAN::Rating>, L<Net::API::CPAN::Release>
213  
214 L<MetaCPAN::API>, L<MetaCPAN::Client>
215  
216 L<https://github.com/metacpan/metacpan-api/blob/master/docs/API-docs.md>
217  
218 =head1 COPYRIGHT & LICENSE
219  
220 Copyright(c) 2023 DEGUEST Pte. Ltd.
221  
222 All rights reserved
223  
224 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
225  
226 =cut
227  
« lib/Net/API/CPAN/Diff.pm ↑ Summary lib/Net/API/CPAN/Permission.pm »