File Coverage

lib/Net/API/CPAN/DownloadUrl.pm
Criterion Covered Total %
statement 40 41 97.5
branch 8 16 50.0
condition n/a
subroutine 15 16 93.7
pod 9 9 100.0
total 72 82 87.8


line stmt bran cond sub pod time code
1             ##----------------------------------------------------------------------------
2             ## Meta CPAN API - ~/lib/Net/API/CPAN/DownloadUrl.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::DownloadUrl;
17             BEGIN
18             {
19 2     2   223005 use strict;
  2         11  
  2         70  
20 2     2   12 use warnings;
  2         3  
  2         68  
21 2     2   10 use parent qw( Net::API::CPAN::Generic );
  2         4  
  2         11  
22 2     2   125 use vars qw( $VERSION );
  2         5  
  2         89  
23 2     2   38 our $VERSION = 'v0.1.0';
24             };
25              
26 2     2   11 use strict;
  2         3  
  2         44  
27 2     2   10 use warnings;
  2         5  
  2         741  
28              
29             sub init
30             {
31 1     1 1 9048 my $self = shift( @_ );
32 1 50       61 $self->{checksum_md5} = undef unless( CORE::exists( $self->{checksum_md5} ) );
33 1 50       4 $self->{checksum_sha256} = undef unless( CORE::exists( $self->{checksum_sha256} ) );
34 1 50       4 $self->{date} = undef unless( CORE::exists( $self->{date} ) );
35 1 50       3 $self->{download_url} = undef unless( CORE::exists( $self->{download_url} ) );
36 1         2 $self->{object} = 'download_url';
37 1 50       20 $self->{release} = undef unless( CORE::exists( $self->{release} ) );
38 1 50       3 $self->{status} = undef unless( CORE::exists( $self->{status} ) );
39 1 50       8 $self->{version} = '' unless( CORE::exists( $self->{version} ) );
40 1         2 $self->{_init_strict_use_sub} = 1;
41 1         2 $self->{_exception_class} = 'Net::API::CPAN::Exception';
42 1 50       7 $self->SUPER::init( @_ ) || return( $self->pass_error );
43 1         6 $self->{fields} = [qw(
44             checksum_md5 checksum_sha256 date download_url release status version
45             )];
46 1         3 return( $self );
47             }
48              
49 2     2 1 4734 sub checksum_md5 { return( shift->_set_get_scalar_as_object( 'checksum_md5', @_ ) ); }
50              
51 2     2 1 2631147 sub checksum_sha256 { return( shift->_set_get_scalar_as_object( 'checksum_sha256', @_ ) ); }
52              
53 2     2 1 1450 sub date { return( shift->_set_get_datetime( 'date', @_ ) ); }
54              
55 2     2 1 2625664 sub download_url { return( shift->_set_get_uri( 'download_url', @_ ) ); }
56              
57 0     0 1 0 sub object { return( shift->_set_get_scalar_as_object( 'object', @_ ) ); }
58              
59 2     2 1 2864 sub release { return( shift->_set_get_scalar_as_object( 'release', @_ ) ); }
60              
61 2     2 1 2166 sub status { return( shift->_set_get_scalar_as_object( 'status', @_ ) ); }
62              
63 2     2 1 17227 sub version { return( shift->_set_get_version( { class => "Changes::Version", field => "version" }, @_ ) ); }
64              
65             1;
66             # NOTE: POD
67             __END__
68              
69             =encoding utf-8
70              
71             =head1 NAME
72              
73             Net::API::CPAN::DownloadUrl - Meta CPAN API DownloadUrl Class
74              
75             =head1 SYNOPSIS
76              
77             use Net::API::CPAN::DownloadUrl;
78             my $obj = Net::API::CPAN::DownloadUrl->new( {
79             checksum_md5 => "71682907d95a4b0a4b74da8c16e88d2d",
80             checksum_sha256 => "27d4da9e772bc1922618b36fdefa768344d92c3d65a5e3cc427218cfc8d7491d",
81             date => "2023-07-29T05:10:12",
82             download_url => "https://cpan.metacpan.org/authors/id/M/MO/MOMOTARO/Folklore-Japan-v1.2.3.tar.gz",
83             release => "Folklore-Japan-v1.2.3",
84             status => "latest",
85             version => "v1.2.3",
86             } ) || die( Net::API::CPAN::DownloadUrl->error );
87            
88             my $string = $obj->checksum_md5;
89             my $string = $obj->checksum_sha256;
90             my $date = $obj->date;
91             my $uri = $obj->download_url;
92             my $str = $obj->object;
93             my $string = $obj->release;
94             my $string = $obj->status;
95             my $vers = $obj->version;
96              
97             =head1 VERSION
98              
99             v0.1.0
100              
101             =head1 DESCRIPTION
102              
103             This class serves to retrieve and manipulate download_urls.
104              
105             It inherits from L<Net::API::CPAN::Generic>
106              
107             =head1 CONSTRUCTOR
108              
109             =head2 new
110              
111             Provided with an hash or hash reference of parameters, and this instantiates a new C<Net::API::CPAN::DownloadUrl> object.
112              
113             The parameters that can be provided bear the same name and supports the same values as the methods below.
114              
115             =head1 METHODS
116              
117             =head2 checksum_md5
118              
119             $obj->checksum_md5( "71682907d95a4b0a4b74da8c16e88d2d" );
120             my $string = $obj->checksum_md5;
121              
122             Sets or gets a string and returns a L<scalar object|Module::Generic::Scalar>, even if there is no value.
123              
124             =head2 checksum_sha256
125              
126             $obj->checksum_sha256( "27d4da9e772bc1922618b36fdefa768344d92c3d65a5e3cc427218cfc8d7491d" );
127             my $string = $obj->checksum_sha256;
128              
129             Sets or gets a string and returns a L<scalar object|Module::Generic::Scalar>, even if there is no value.
130              
131             =head2 date
132              
133             $obj->date( "2023-07-29T05:10:12" );
134             my $datetime_obj = $obj->date;
135              
136             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.
137              
138             =head2 download_url
139              
140             $obj->download_url( "https://cpan.metacpan.org/authors/id/M/MO/MOMOTARO/Folklore-Japan-v1.2.3.tar.gz" );
141             my $uri = $obj->download_url;
142              
143             Sets or gets an L<URI>, and returns an L<URI object|URI> or C<undef> if no value is set.
144              
145             =head2 object
146              
147             Returns the object type for this class, which is C<download_url>
148              
149             =head2 release
150              
151             $obj->release( "Folklore-Japan-v1.2.3" );
152             my $string = $obj->release;
153              
154             Sets or gets a string and returns a L<scalar object|Module::Generic::Scalar>, even if there is no value.
155              
156             =head2 status
157              
158             $obj->status( "latest" );
159             my $string = $obj->status;
160              
161             Sets or gets a string and returns a L<scalar object|Module::Generic::Scalar>, even if there is no value.
162              
163             =head2 version
164              
165             $obj->version( "v1.2.3" );
166             my $version = $obj->version;
167              
168             Sets or gets a version value and returns a version object using L<Changes::Version>.
169              
170             =head1 API SAMPLE
171              
172             {
173             "checksum_md5" : "71682907d95a4b0a4b74da8c16e88d2d",
174             "checksum_sha256" : "27d4da9e772bc1922618b36fdefa768344d92c3d65a5e3cc427218cfc8d7491d",
175             "date" : "2023-07-29T05:10:12",
176             "download_url" : "https://cpan.metacpan.org/authors/id/M/MO/MOMOTARO/Folklore-Japan-v1.2.3.tar.gz",
177             "release" : "Folklore-Japan-v1.2.3",
178             "status" : "latest",
179             "version" : "v1.2.3",
180             }
181              
182             =head1 AUTHOR
183              
184             Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
185              
186             =head1 SEE ALSO
187              
188             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>
189              
190             L<MetaCPAN::API>, L<MetaCPAN::Client>
191              
192             L<https://github.com/metacpan/metacpan-api/blob/master/docs/API-docs.md>
193              
194             =head1 COPYRIGHT & LICENSE
195              
196             Copyright(c) 2023 DEGUEST Pte. Ltd.
197              
198             All rights reserved
199              
200             This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
201              
202             =cut
203