| 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 | use strict; | ||
| 20 | use warnings; | ||
| 21 | use parent qw( Net::API::CPAN::Generic ); | ||
| 22 | use vars qw( $VERSION ); | ||
| 23 | our $VERSION = 'v0.1.0'; | ||
| 24 | }; | ||
| 25 | |||
| 26 | use strict; | ||
| 27 | use warnings; | ||
| 28 | |||
| 29 | sub init | ||
| 30 | { | ||
| 31 | my $self = shift( @_ ); | ||
| 32 | $self->{author} = undef unless( CORE::exists( $self->{author} ) ); | ||
| 33 | $self->{dist_version} = undef unless( CORE::exists( $self->{dist_version} ) ); | ||
| 34 | $self->{distribution} = undef unless( CORE::exists( $self->{distribution} ) ); | ||
| 35 | $self->{file} = undef unless( CORE::exists( $self->{file} ) ); | ||
| 36 | $self->{module_name} = undef unless( CORE::exists( $self->{module_name} ) ); | ||
| 37 | $self->{object} = 'package'; | ||
| 38 | $self->{version} = '' unless( CORE::exists( $self->{version} ) ); | ||
| 39 | $self->{_init_strict_use_sub} = 1; | ||
| 40 | $self->{_exception_class} = 'Net::API::CPAN::Exception'; | ||
| 41 | $self->SUPER::init( @_ ) || return( $self->pass_error ); | ||
| 42 | $self->{fields} = [qw( | ||
| 43 | author dist_version distribution file module_name version | ||
| 44 | )]; | ||
| 45 | return( $self ); | ||
| 46 | } | ||
| 47 | |||
| 48 | sub author { return( shift->_set_get_scalar_as_object( 'author', @_ ) ); } | ||
| 49 | |||
| 50 | sub dist_version { return( shift->_set_get_version( { class => "Changes::Version", field => "dist_version" }, @_ ) ); } | ||
| 51 | |||
| 52 | sub distribution { return( shift->_set_get_scalar_as_object( 'distribution', @_ ) ); } | ||
| 53 | |||
| 54 | sub file { return( shift->_set_get_scalar_as_object( 'file', @_ ) ); } | ||
| 55 | |||
| 56 | sub module_name { return( shift->_set_get_scalar_as_object( 'module_name', @_ ) ); } | ||
| 57 | |||
| 58 | sub object { return( shift->_set_get_scalar_as_object( 'object', @_ ) ); } | ||
| 59 | |||
| 60 | 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 |