lib/Net/API/CPAN/Mirror.pm

filter: Statementstmt 98.6% 71 / 72 Branchbran 50.0% 23 / 46 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 96.7% 30 / 31 Podpod 100% 24 / 24 totaltotal 85.5% 148 / 173 CC 24 SCAR 29.2
CC
24
Cov
80%
init
40.6
object
2.0
BEGIN
1.0
CRAP 18.6
« blib/lib/Net/API/CPAN/Release/Suggest.pm ↑ Summary blib/lib/Net/API/CPAN/Generic.pm »
1 ##----------------------------------------------------------------------------
2 ## Meta CPAN API - ~/lib/Net/API/CPAN/Mirror.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::Mirror;
17 BEGIN
18 {
19 3 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 3 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 3 ▶ use parent qw( Net::API::CPAN::Generic );
Subroutine BEGIN: called CC=1 SCAR=0.0
22 3 ▶ use vars qw( $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
23 3 ▶ our $VERSION = 'v0.1.0';
Subroutine BEGIN: called CC=1 SCAR=0.0
24 };
25  
26 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 sub init
30 {
31 2 ▶ my $self = shift( @_ );
Subroutine init: called CC=24 SCAR=37.0
Pod documented
32 2 ▶ $self->{A_or_CNAME} = undef unless( CORE::exists( $self->{A_or_CNAME} ) );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"A_or_CNAME"} 2 0 2
33 2 ▶ $self->{aka_name} = undef unless( CORE::exists( $self->{aka_name} ) );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"aka_name"} 2 0 2
34 2 ▶ $self->{ccode} = undef unless( CORE::exists( $self->{ccode} ) );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"ccode"} 2 0 2
35 2 ▶ $self->{city} = undef unless( CORE::exists( $self->{city} ) );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"city"} 2 0 2
36 2 ▶ $self->{contact} = [] unless( CORE::exists( $self->{contact} ) );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"contact"} 2 0 2
37 2 ▶ $self->{continent} = undef unless( CORE::exists( $self->{continent} ) );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"continent"} 2 0 2
38 2 ▶ $self->{country} = undef unless( CORE::exists( $self->{country} ) );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"country"} 2 0 2
39 2 ▶ $self->{distance} = undef unless( CORE::exists( $self->{distance} ) );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"distance"} 2 0 2
40 2 ▶ $self->{dnsrr} = undef unless( CORE::exists( $self->{dnsrr} ) );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"dnsrr"} 2 0 2
41 2 ▶ $self->{freq} = undef unless( CORE::exists( $self->{freq} ) );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"freq"} 2 0 2
42 2 ▶ $self->{ftp} = undef unless( CORE::exists( $self->{ftp} ) );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"ftp"} 2 0 2
43 2 ▶ $self->{http} = undef unless( CORE::exists( $self->{http} ) );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"http"} 2 0 2
44 2 ▶ $self->{inceptdate} = undef unless( CORE::exists( $self->{inceptdate} ) );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"inceptdate"} 2 0 2
45 2 ▶ $self->{location} = [] unless( CORE::exists( $self->{location} ) );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"location"} 2 0 2
46 2 ▶ $self->{name} = undef unless( CORE::exists( $self->{name} ) );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"name"} 2 0 2
47 2 ▶ $self->{note} = undef unless( CORE::exists( $self->{note} ) );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"note"} 2 0 2
48 2 $self->{object} = 'mirror';
49 2 ▶ $self->{org} = undef unless( CORE::exists( $self->{org} ) );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"org"} 2 0 2
50 2 ▶ $self->{region} = undef unless( CORE::exists( $self->{region} ) );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"region"} 2 0 2
51 2 ▶ $self->{reitredate} = undef unless( CORE::exists( $self->{reitredate} ) );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"reitredate"} 2 0 2
52 2 ▶ $self->{rsync} = undef unless( CORE::exists( $self->{rsync} ) );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"rsync"} 2 0 2
53 2 ▶ $self->{src} = undef unless( CORE::exists( $self->{src} ) );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"src"} 2 0 2
54 2 ▶ $self->{tz} = undef unless( CORE::exists( $self->{tz} ) );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"tz"} 2 0 2
55 2 $self->{_init_strict_use_sub} = 1;
56 2 $self->{_exception_class} = 'Net::API::CPAN::Exception';
57 2 ▶ $self->SUPER::init( @_ ) || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->SUPER::init(@_) or return $self->pass_error 0 2 2
58 2 $self->{fields} = [qw(
59 A_or_CNAME aka_name ccode city contact continent country distance dnsrr freq ftp
60 http inceptdate location name note org region reitredate rsync src tz
61 )];
62 2 return( $self );
63 }
64  
65 1 ▶sub A_or_CNAME { return( shift->_set_get_scalar_as_object( 'A_or_CNAME', @_ ) ); }
Subroutine A_or_CNAME: called CC=1 SCAR=0.0
Pod documented
66  
67 1 ▶sub aka_name { return( shift->_set_get_scalar_as_object( 'aka_name', @_ ) ); }
Subroutine aka_name: called CC=1 SCAR=0.0
Pod documented
68  
69 3 ▶sub ccode { return( shift->_set_get_scalar_as_object( 'ccode', @_ ) ); }
Subroutine ccode: called CC=1 SCAR=0.0
Pod documented
70  
71 3 ▶sub city { return( shift->_set_get_scalar_as_object( 'city', @_ ) ); }
Subroutine city: called CC=1 SCAR=0.0
Pod documented
72  
73 3 ▶sub contact { return( shift->_set_get_class_array_object( 'contact', {
Subroutine contact: called CC=1 SCAR=0.0
Pod documented
74 contact_site => "scalar_as_object",
75 contact_user => "scalar_as_object",
76 }, @_ ) ); }
77  
78 3 ▶sub continent { return( shift->_set_get_scalar_as_object( 'continent', @_ ) ); }
Subroutine continent: called CC=1 SCAR=0.0
Pod documented
79  
80 3 ▶sub country { return( shift->_set_get_scalar_as_object( 'country', @_ ) ); }
Subroutine country: called CC=1 SCAR=0.0
Pod documented
81  
82 3 ▶sub distance { return( shift->_set_get_scalar_as_object( 'distance', @_ ) ); }
Subroutine distance: called CC=1 SCAR=0.0
Pod documented
83  
84 3 ▶sub dnsrr { return( shift->_set_get_scalar_as_object( 'dnsrr', @_ ) ); }
Subroutine dnsrr: called CC=1 SCAR=0.0
Pod documented
85  
86 3 ▶sub freq { return( shift->_set_get_scalar_as_object( 'freq', @_ ) ); }
Subroutine freq: called CC=1 SCAR=0.0
Pod documented
87  
88 1 ▶sub ftp { return( shift->_set_get_uri( 'ftp', @_ ) ); }
Subroutine ftp: called CC=1 SCAR=0.0
Pod documented
89  
90 3 ▶sub http { return( shift->_set_get_uri( 'http', @_ ) ); }
Subroutine http: called CC=1 SCAR=0.0
Pod documented
91  
92 3 ▶sub inceptdate { return( shift->_set_get_datetime( 'inceptdate', @_ ) ); }
Subroutine inceptdate: called CC=1 SCAR=0.0
Pod documented
93  
94 3 ▶sub location { return( shift->_set_get_array_as_object( 'location', @_ ) ); }
Subroutine location: called CC=1 SCAR=0.0
Pod documented
95  
96 3 ▶sub name { return( shift->_set_get_scalar_as_object( 'name', @_ ) ); }
Subroutine name: called CC=1 SCAR=0.0
Pod documented
97  
98 1 ▶sub note { return( shift->_set_get_scalar_as_object( 'note', @_ ) ); }
Subroutine note: called CC=1 SCAR=0.0
Pod documented
99  
100 0 ▶sub object { return( shift->_set_get_scalar_as_object( 'object', @_ ) ); }
Subroutine object: not called CC=1 SCAR=6.9
Pod documented
101  
102 3 ▶sub org { return( shift->_set_get_scalar_as_object( 'org', @_ ) ); }
Subroutine org: called CC=1 SCAR=0.0
Pod documented
103  
104 1 ▶sub region { return( shift->_set_get_scalar_as_object( 'region', @_ ) ); }
Subroutine region: called CC=1 SCAR=0.0
Pod documented
105  
106 1 ▶sub reitredate { return( shift->_set_get_datetime( 'reitredate', @_ ) ); }
Subroutine reitredate: called CC=1 SCAR=0.0
Pod documented
107  
108 1 ▶sub rsync { return( shift->_set_get_uri( 'rsync', @_ ) ); }
Subroutine rsync: called CC=1 SCAR=0.0
Pod documented
109  
110 3 ▶sub src { return( shift->_set_get_uri( 'src', @_ ) ); }
Subroutine src: called CC=1 SCAR=0.0
Pod documented
111  
112 3 ▶sub tz { return( shift->_set_get_scalar_as_object( 'tz', @_ ) ); }
Subroutine tz: called CC=1 SCAR=0.0
Pod documented
113  
114 3 1;
115 # NOTE: POD
116 __END__
117  
118 =encoding utf-8
119  
120 =head1 NAME
121  
122 Net::API::CPAN::Mirror - Meta CPAN API Mirror Class
123  
124 =head1 SYNOPSIS
125  
126 use Net::API::CPAN::Mirror;
127 my $obj = Net::API::CPAN::Mirror->new( {
128 ccode => "zz",
129 city => "Everywhere",
130 contact => [
131 {
132 contact_site => "perl.org",
133 contact_user => "cpan",
134 },
135 ],
136 continent => "Global",
137 country => "Global",
138 distance => undef,
139 dnsrr => "N",
140 freq => "instant",
141 http => "http://www.cpan.org/",
142 inceptdate => "2021-04-09T00:00:00",
143 location => [
144 0,
145 0,
146 ],
147 name => "www.cpan.org",
148 org => "Global CPAN CDN",
149 src => "rsync://cpan-rsync.perl.org/CPAN/",
150 tz => 0,
151 } ) || die( Net::API::CPAN::Mirror->error );
152
153 my $string = $obj->A_or_CNAME;
154 my $string = $obj->aka_name;
155 my $string = $obj->ccode;
156 my $string = $obj->city;
157 my $array = $obj->contact;
158 foreach my $this ( @$array )
159 {
160 my $scalar = $this->contact_site;
161 my $scalar = $this->contact_user;
162 }
163 my $string = $obj->continent;
164 my $string = $obj->country;
165 my $string = $obj->distance;
166 my $string = $obj->dnsrr;
167 my $string = $obj->freq;
168 my $uri = $obj->ftp;
169 my $uri = $obj->http;
170 my $date = $obj->inceptdate;
171 my $array = $obj->location;
172 my $string = $obj->name;
173 my $string = $obj->note;
174 my $str = $obj->object;
175 my $string = $obj->org;
176 my $string = $obj->region;
177 my $date = $obj->reitredate;
178 my $uri = $obj->rsync;
179 my $uri = $obj->src;
180 my $string = $obj->tz;
181  
182 =head1 VERSION
183  
184 v0.1.0
185  
186 =head1 DESCRIPTION
187  
188 This class serves to retrieve and manipulate mirrors.
189  
190 It inherits from L<Net::API::CPAN::Generic>
191  
192 =head1 CONSTRUCTOR
193  
194 =head2 new
195  
196 Provided with an hash or hash reference of parameters, and this instantiates a new C<Net::API::CPAN::Mirror> object.
197  
198 The parameters that can be provided bear the same name and supports the same values as the methods below.
199  
200 =head1 METHODS
201  
202 =head2 A_or_CNAME
203  
204 Sets or gets a string and returns a L<scalar object|Module::Generic::Scalar>, even if there is no value.
205  
206 =head2 aka_name
207  
208 Sets or gets a string and returns a L<scalar object|Module::Generic::Scalar>, even if there is no value.
209  
210 =head2 ccode
211  
212 $obj->ccode( "zz" );
213 my $string = $obj->ccode;
214  
215 Sets or gets a string and returns a L<scalar object|Module::Generic::Scalar>, even if there is no value.
216  
217 =head2 city
218  
219 $obj->city( "Everywhere" );
220 my $string = $obj->city;
221  
222 Sets or gets a string and returns a L<scalar object|Module::Generic::Scalar>, even if there is no value.
223  
224 =head2 contact
225  
226 $obj->contact( [
227 {
228 contact_site => "perl.org",
229 contact_user => "cpan",
230 },
231 ] );
232 my $array = $obj->contact;
233 foreach my $this ( @$array )
234 {
235 $this->contact_site( "perl.org" );
236 my $scalar = $this->contact_site;
237 $this->contact_user( "cpan" );
238 my $scalar = $this->contact_user;
239 }
240  
241 Sets or gets an array of dynamic class objects with class name C<Net::API::CPAN::Mirror::Contact> and having the folowing properties also accessible as methods, and returns an L<array object|Module::Generic::Array> even if there is no value.
242  
243 A C<Net::API::CPAN::Mirror::Contact> object will be instantiated with each value from the array provided and replace said value.
244  
245 =over 4
246  
247 =item * C<contact_site> scalar_as_object
248  
249 =item * C<contact_user> scalar_as_object
250  
251 =back
252  
253 =head2 continent
254  
255 $obj->continent( "Global" );
256 my $string = $obj->continent;
257  
258 Sets or gets a string and returns a L<scalar object|Module::Generic::Scalar>, even if there is no value.
259  
260 =head2 country
261  
262 $obj->country( "Global" );
263 my $string = $obj->country;
264  
265 Sets or gets a string and returns a L<scalar object|Module::Generic::Scalar>, even if there is no value.
266  
267 =head2 distance
268  
269 $obj->distance( undef );
270 my $string = $obj->distance;
271  
272 Sets or gets a string and returns a L<scalar object|Module::Generic::Scalar>, even if there is no value.
273  
274 =head2 dnsrr
275  
276 $obj->dnsrr( "N" );
277 my $string = $obj->dnsrr;
278  
279 Sets or gets a string and returns a L<scalar object|Module::Generic::Scalar>, even if there is no value.
280  
281 =head2 freq
282  
283 $obj->freq( "instant" );
284 my $string = $obj->freq;
285  
286 Sets or gets a string and returns a L<scalar object|Module::Generic::Scalar>, even if there is no value.
287  
288 =head2 ftp
289  
290 Sets or gets an L<URI>, and returns an L<URI object|URI> or C<undef> if no value is set.
291  
292 =head2 http
293  
294 $obj->http( "http://www.cpan.org/" );
295 my $uri = $obj->http;
296  
297 Sets or gets an L<URI>, and returns an L<URI object|URI> or C<undef> if no value is set.
298  
299 =head2 inceptdate
300  
301 $obj->inceptdate( "2021-04-09T00:00:00" );
302 my $datetime_obj = $obj->inceptdate;
303  
304 Sets or gets a datetime value, and returns a L<DateTime object|DateTime> that stringifies to the format that was provided with the string set (usally an ISO 8601 datetime format) or C<undef> if no value is set.
305  
306 =head2 location
307  
308 $obj->location( [
309 0,
310 0,
311 ] );
312 my $array = $obj->location;
313  
314 Sets or gets an array of locations and returns an L<array object|Module::Generic::Array>, even if there is no value.
315  
316 =head2 name
317  
318 $obj->name( "www.cpan.org" );
319 my $string = $obj->name;
320  
321 Sets or gets a string and returns a L<scalar object|Module::Generic::Scalar>, even if there is no value.
322  
323 =head2 note
324  
325 Sets or gets a string and returns a L<scalar object|Module::Generic::Scalar>, even if there is no value.
326  
327 =head2 object
328  
329 Returns the object type for this class, which is C<mirror>
330  
331 =head2 org
332  
333 $obj->org( "Global CPAN CDN" );
334 my $string = $obj->org;
335  
336 Sets or gets a string and returns a L<scalar object|Module::Generic::Scalar>, even if there is no value.
337  
338 =head2 region
339  
340 Sets or gets a string and returns a L<scalar object|Module::Generic::Scalar>, even if there is no value.
341  
342 =head2 reitredate
343  
344 Sets or gets a datetime value, and returns a L<DateTime object|DateTime> that stringifies to the format that was provided with the string set (usally an ISO 8601 datetime format) or C<undef> if no value is set.
345  
346 =head2 rsync
347  
348 Sets or gets an L<URI>, and returns an L<URI object|URI> or C<undef> if no value is set.
349  
350 =head2 src
351  
352 $obj->src( "rsync://cpan-rsync.perl.org/CPAN/" );
353 my $uri = $obj->src;
354  
355 Sets or gets an L<URI>, and returns an L<URI object|URI> or C<undef> if no value is set.
356  
357 =head2 tz
358  
359 $obj->tz( 0 );
360 my $string = $obj->tz;
361  
362 Sets or gets a string and returns a L<scalar object|Module::Generic::Scalar>, even if there is no value.
363  
364 =head1 API SAMPLE
365  
366 {
367 "ccode" : "zz",
368 "city" : "Everywhere",
369 "contact" : [
370 {
371 "contact_site" : "perl.org",
372 "contact_user" : "cpan"
373 }
374 ],
375 "continent" : "Global",
376 "country" : "Global",
377 "distance" : null,
378 "dnsrr" : "N",
379 "freq" : "instant",
380 "http" : "http://www.cpan.org/",
381 "inceptdate" : "2021-04-09T00:00:00",
382 "location" : [
383 0,
384 0
385 ],
386 "name" : "www.cpan.org",
387 "org" : "Global CPAN CDN",
388 "src" : "rsync://cpan-rsync.perl.org/CPAN/",
389 "tz" : "0"
390 }
391  
392 =head1 AUTHOR
393  
394 Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
395  
396 =head1 SEE ALSO
397  
398 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>
399  
400 L<MetaCPAN::API>, L<MetaCPAN::Client>
401  
402 L<https://github.com/metacpan/metacpan-api/blob/master/docs/API-docs.md>
403  
404 =head1 COPYRIGHT & LICENSE
405  
406 Copyright(c) 2023 DEGUEST Pte. Ltd.
407  
408 All rights reserved
409  
410 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
411  
412 =cut
413  
« blib/lib/Net/API/CPAN/Release/Suggest.pm ↑ Summary blib/lib/Net/API/CPAN/Generic.pm »