File Coverage

lib/Net/API/CPAN/Mirror.pm
Criterion Covered Total %
statement 70 71 98.5
branch 23 46 50.0
condition n/a
subroutine 30 31 96.7
pod 24 24 100.0
total 147 172 85.4


line stmt bran cond sub pod time code
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/25
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     3   233198 use strict;
  3         14  
  3         95  
20 3     3   14 use warnings;
  3         5  
  3         101  
21 3     3   15 use parent qw( Net::API::CPAN::Generic );
  3         7  
  3         24  
22 3     3   180 use vars qw( $VERSION );
  3         6  
  3         129  
23 3     3   76 our $VERSION = 'v0.1.0';
24             };
25              
26 3     3   17 use strict;
  3         7  
  3         50  
27 3     3   12 use warnings;
  3         14  
  3         2509  
28              
29             sub init
30             {
31 2     2 1 9411 my $self = shift( @_ );
32 2 50       138 $self->{A_or_CNAME} = undef unless( CORE::exists( $self->{A_or_CNAME} ) );
33 2 50       8 $self->{aka_name} = undef unless( CORE::exists( $self->{aka_name} ) );
34 2 50       11 $self->{ccode} = undef unless( CORE::exists( $self->{ccode} ) );
35 2 50       7 $self->{city} = undef unless( CORE::exists( $self->{city} ) );
36 2 50       7 $self->{contact} = [] unless( CORE::exists( $self->{contact} ) );
37 2 50       9 $self->{continent} = undef unless( CORE::exists( $self->{continent} ) );
38 2 50       8 $self->{country} = undef unless( CORE::exists( $self->{country} ) );
39 2 50       7 $self->{distance} = undef unless( CORE::exists( $self->{distance} ) );
40 2 50       8 $self->{dnsrr} = undef unless( CORE::exists( $self->{dnsrr} ) );
41 2 50       7 $self->{freq} = undef unless( CORE::exists( $self->{freq} ) );
42 2 50       7 $self->{ftp} = undef unless( CORE::exists( $self->{ftp} ) );
43 2 50       7 $self->{http} = undef unless( CORE::exists( $self->{http} ) );
44 2 50       9 $self->{inceptdate} = undef unless( CORE::exists( $self->{inceptdate} ) );
45 2 50       8 $self->{location} = [] unless( CORE::exists( $self->{location} ) );
46 2 50       6 $self->{name} = undef unless( CORE::exists( $self->{name} ) );
47 2 50       7 $self->{note} = undef unless( CORE::exists( $self->{note} ) );
48 2         6 $self->{object} = 'mirror';
49 2 50       6 $self->{org} = undef unless( CORE::exists( $self->{org} ) );
50 2 50       5 $self->{region} = undef unless( CORE::exists( $self->{region} ) );
51 2 50       7 $self->{reitredate} = undef unless( CORE::exists( $self->{reitredate} ) );
52 2 50       6 $self->{rsync} = undef unless( CORE::exists( $self->{rsync} ) );
53 2 50       6 $self->{src} = undef unless( CORE::exists( $self->{src} ) );
54 2 50       6 $self->{tz} = undef unless( CORE::exists( $self->{tz} ) );
55 2         5 $self->{_init_strict_use_sub} = 1;
56 2         3 $self->{_exception_class} = 'Net::API::CPAN::Exception';
57 2 50       19 $self->SUPER::init( @_ ) || return( $self->pass_error );
58 2         16 $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         8 return( $self );
63             }
64              
65 1     1 1 8521 sub A_or_CNAME { return( shift->_set_get_scalar_as_object( 'A_or_CNAME', @_ ) ); }
66              
67 1     1 1 1053 sub aka_name { return( shift->_set_get_scalar_as_object( 'aka_name', @_ ) ); }
68              
69 3     3 1 2839 sub ccode { return( shift->_set_get_scalar_as_object( 'ccode', @_ ) ); }
70              
71 3     3 1 2698946 sub city { return( shift->_set_get_scalar_as_object( 'city', @_ ) ); }
72              
73 3     3 1 2415 sub contact { return( shift->_set_get_class_array_object( 'contact', {
74             contact_site => "scalar_as_object",
75             contact_user => "scalar_as_object",
76             }, @_ ) ); }
77              
78 3     3 1 4530 sub continent { return( shift->_set_get_scalar_as_object( 'continent', @_ ) ); }
79              
80 3     3 1 2999 sub country { return( shift->_set_get_scalar_as_object( 'country', @_ ) ); }
81              
82 3     3 1 2962 sub distance { return( shift->_set_get_scalar_as_object( 'distance', @_ ) ); }
83              
84 3     3 1 2709 sub dnsrr { return( shift->_set_get_scalar_as_object( 'dnsrr', @_ ) ); }
85              
86 3     3 1 2634780 sub freq { return( shift->_set_get_scalar_as_object( 'freq', @_ ) ); }
87              
88 1     1 1 1238 sub ftp { return( shift->_set_get_uri( 'ftp', @_ ) ); }
89              
90 3     3 1 3235 sub http { return( shift->_set_get_uri( 'http', @_ ) ); }
91              
92 3     3 1 7574 sub inceptdate { return( shift->_set_get_datetime( 'inceptdate', @_ ) ); }
93              
94 3     3 1 4479 sub location { return( shift->_set_get_array_as_object( 'location', @_ ) ); }
95              
96 3     3 1 20330 sub name { return( shift->_set_get_scalar_as_object( 'name', @_ ) ); }
97              
98 1     1 1 1325 sub note { return( shift->_set_get_scalar_as_object( 'note', @_ ) ); }
99              
100 0     0 1 0 sub object { return( shift->_set_get_scalar_as_object( 'object', @_ ) ); }
101              
102 3     3 1 17965 sub org { return( shift->_set_get_scalar_as_object( 'org', @_ ) ); }
103              
104 1     1 1 1288 sub region { return( shift->_set_get_scalar_as_object( 'region', @_ ) ); }
105              
106 1     1 1 1001 sub reitredate { return( shift->_set_get_datetime( 'reitredate', @_ ) ); }
107              
108 1     1 1 1277 sub rsync { return( shift->_set_get_uri( 'rsync', @_ ) ); }
109              
110 3     3 1 2954 sub src { return( shift->_set_get_uri( 'src', @_ ) ); }
111              
112 3     3 1 3689 sub tz { return( shift->_set_get_scalar_as_object( 'tz', @_ ) ); }
113              
114             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