File Coverage

lib/Net/API/CPAN/Package.pm
Criterion Covered Total %
statement 38 39 97.4
branch 7 14 50.0
condition n/a
subroutine 14 15 93.3
pod 8 8 100.0
total 67 76 88.1


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