| 1 | ##---------------------------------------------------------------------------- | ||||||||||
| 2 | ## Meta CPAN API - ~/lib/Net/API/CPAN/Rating.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::Rating; | ||||||||||
| 17 | BEGIN | ||||||||||
| 18 | { | ||||||||||
| 19 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | 2 | ▶ | use parent qw( Net::API::CPAN::Generic ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | 2 | ▶ | use vars qw( $VERSION ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 23 | 2 | ▶ | our $VERSION = 'v0.1.0'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 24 | }; | ||||||||||
| 25 | |||||||||||
| 26 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 27 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 28 | |||||||||||
| 29 | sub init | ||||||||||
| 30 | { | ||||||||||
| 31 | 1 | ▶ | my $self = shift( @_ ); | ||||||||
|
Subroutine
init: called CC=10 SCAR=24.9
Pod
documented
| |||||||||||
| 32 | 1 | ▶ | $self->{author} = undef unless( CORE::exists( $self->{author} ) ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | 1 | ▶ | $self->{date} = undef unless( CORE::exists( $self->{date} ) ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | 1 | ▶ | $self->{details} = undef unless( CORE::exists( $self->{details} ) ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | 1 | ▶ | $self->{distribution} = undef unless( CORE::exists( $self->{distribution} ) ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | 1 | ▶ | $self->{helpful} = [] unless( CORE::exists( $self->{helpful} ) ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | 1 | $self->{object} = 'rating'; | |||||||||
| 38 | 1 | ▶ | $self->{rating} = undef unless( CORE::exists( $self->{rating} ) ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | 1 | ▶ | $self->{release} = undef unless( CORE::exists( $self->{release} ) ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | 1 | ▶ | $self->{user} = undef unless( CORE::exists( $self->{user} ) ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | 1 | $self->{_init_strict_use_sub} = 1; | |||||||||
| 42 | 1 | $self->{_exception_class} = 'Net::API::CPAN::Exception'; | |||||||||
| 43 | 1 | ▶ | $self->SUPER::init( @_ ) || return( $self->pass_error ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 44 | 1 | $self->{fields} = [qw( | |||||||||
| 45 | author date details distribution helpful rating release user | ||||||||||
| 46 | )]; | ||||||||||
| 47 | 1 | return( $self ); | |||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | 2 | ▶ | sub author { return( shift->_set_get_scalar_as_object( 'author', @_ ) ); } | ||||||||
|
Subroutine
author: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 51 | |||||||||||
| 52 | 2 | ▶ | sub date { return( shift->_set_get_datetime( 'date', @_ ) ); } | ||||||||
|
Subroutine
date: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 53 | |||||||||||
| 54 | 1 | ▶ | sub details { return( shift->_set_get_class( 'details', { | ||||||||
|
Subroutine
details: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 55 | description => { type => "scalar" }, | ||||||||||
| 56 | }, @_ ) ); } | ||||||||||
| 57 | |||||||||||
| 58 | 2 | ▶ | sub distribution { return( shift->_set_get_scalar_as_object( 'distribution', @_ ) ); } | ||||||||
|
Subroutine
distribution: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 59 | |||||||||||
| 60 | 1 | ▶ | sub helpful { return( shift->_set_get_class_array_object( 'helpful', { user => "scalar_as_object", value => "boolean" }, @_ ) ); } | ||||||||
|
Subroutine
helpful: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 61 | |||||||||||
| 62 | 0 | ▶ | sub object { return( shift->_set_get_scalar_as_object( 'object', @_ ) ); } | ||||||||
|
Subroutine
object: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 63 | |||||||||||
| 64 | 2 | ▶ | sub rating { return( shift->_set_get_number( 'rating', @_ ) ); } | ||||||||
|
Subroutine
rating: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 65 | |||||||||||
| 66 | 2 | ▶ | sub release { return( shift->_set_get_scalar_as_object( 'release', @_ ) ); } | ||||||||
|
Subroutine
release: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 67 | |||||||||||
| 68 | 2 | ▶ | sub user { return( shift->_set_get_scalar_as_object( 'user', @_ ) ); } | ||||||||
|
Subroutine
user: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 69 | |||||||||||
| 70 | 2 | 1; | |||||||||
| 71 | # NOTE: POD | ||||||||||
| 72 | __END__ | ||||||||||
| 73 | |||||||||||
| 74 | =encoding utf-8 | ||||||||||
| 75 | |||||||||||
| 76 | =head1 NAME | ||||||||||
| 77 | |||||||||||
| 78 | Net::API::CPAN::Rating - Meta CPAN API Rating Class | ||||||||||
| 79 | |||||||||||
| 80 | =head1 SYNOPSIS | ||||||||||
| 81 | |||||||||||
| 82 | use Net::API::CPAN::Rating; | ||||||||||
| 83 | my $obj = Net::API::CPAN::Rating->new( { | ||||||||||
| 84 | author => "PLACEHOLDER", | ||||||||||
| 85 | date => "2018-05-31T09:20:07", | ||||||||||
| 86 | distribution => "Japan-Folklore", | ||||||||||
| 87 | rating => "5.0", | ||||||||||
| 88 | release => "PLACEHOLDER", | ||||||||||
| 89 | user => "CPANRatings", | ||||||||||
| 90 | } ) || die( Net::API::CPAN::Rating->error ); | ||||||||||
| 91 | |||||||||||
| 92 | my $string = $obj->author; | ||||||||||
| 93 | my $date = $obj->date; | ||||||||||
| 94 | my $this = $obj->details; | ||||||||||
| 95 | my $description_obj = $obj->details->description; | ||||||||||
| 96 | my $string = $obj->distribution; | ||||||||||
| 97 | my $array = $obj->helpful; | ||||||||||
| 98 | foreach my $this ( @$array ) | ||||||||||
| 99 | { | ||||||||||
| 100 | my $scalar = $this->user; | ||||||||||
| 101 | my $boolean = $this->value; | ||||||||||
| 102 | } | ||||||||||
| 103 | my $str = $obj->object; | ||||||||||
| 104 | my $num = $obj->rating; | ||||||||||
| 105 | my $string = $obj->release; | ||||||||||
| 106 | my $string = $obj->user; | ||||||||||
| 107 | |||||||||||
| 108 | =head1 VERSION | ||||||||||
| 109 | |||||||||||
| 110 | v0.1.0 | ||||||||||
| 111 | |||||||||||
| 112 | =head1 DESCRIPTION | ||||||||||
| 113 | |||||||||||
| 114 | This class serves to retrieve and manipulate ratings. | ||||||||||
| 115 | |||||||||||
| 116 | It inherits from L<Net::API::CPAN::Generic> | ||||||||||
| 117 | |||||||||||
| 118 | =head1 CONSTRUCTOR | ||||||||||
| 119 | |||||||||||
| 120 | =head2 new | ||||||||||
| 121 | |||||||||||
| 122 | Provided with an hash or hash reference of parameters, and this instantiates a new C<Net::API::CPAN::Rating> object. | ||||||||||
| 123 | |||||||||||
| 124 | The parameters that can be provided bear the same name and supports the same values as the methods below. | ||||||||||
| 125 | |||||||||||
| 126 | =head1 METHODS | ||||||||||
| 127 | |||||||||||
| 128 | =head2 author | ||||||||||
| 129 | |||||||||||
| 130 | $obj->author( "PLACEHOLDER" ); | ||||||||||
| 131 | my $string = $obj->author; | ||||||||||
| 132 | |||||||||||
| 133 | Sets or gets a string and returns a L<scalar object|Module::Generic::Scalar>, even if there is no value. | ||||||||||
| 134 | |||||||||||
| 135 | =head2 date | ||||||||||
| 136 | |||||||||||
| 137 | $obj->date( "2018-05-31T09:20:07" ); | ||||||||||
| 138 | my $datetime_obj = $obj->date; | ||||||||||
| 139 | |||||||||||
| 140 | 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. | ||||||||||
| 141 | |||||||||||
| 142 | =head2 details | ||||||||||
| 143 | |||||||||||
| 144 | Sets or gets a dynamic class object with class name C<Net::API::CPAN::Rating::Details> and having the folowing properties also accessible as methods, and returns an object from such class, or C<undef> if no value was provided. | ||||||||||
| 145 | |||||||||||
| 146 | =over 4 | ||||||||||
| 147 | |||||||||||
| 148 | =item * C<description> string (L<scalar object|Module::Generic::Scalar>) | ||||||||||
| 149 | |||||||||||
| 150 | =back | ||||||||||
| 151 | |||||||||||
| 152 | =head2 distribution | ||||||||||
| 153 | |||||||||||
| 154 | $obj->distribution( "Japan-Folklore" ); | ||||||||||
| 155 | my $string = $obj->distribution; | ||||||||||
| 156 | |||||||||||
| 157 | Sets or gets a string and returns a L<scalar object|Module::Generic::Scalar>, even if there is no value. | ||||||||||
| 158 | |||||||||||
| 159 | =head2 helpful | ||||||||||
| 160 | |||||||||||
| 161 | Sets or gets an array of dynamic class objects with class name C<Net::API::CPAN::Rating::Helpful> and having the folowing properties also accessible as methods, and returns an L<array object|Module::Generic::Array> even if there is no value. | ||||||||||
| 162 | |||||||||||
| 163 | A C<Net::API::CPAN::Rating::Helpful> object will be instantiated with each value from the array provided and replace said value. | ||||||||||
| 164 | |||||||||||
| 165 | =over 4 | ||||||||||
| 166 | |||||||||||
| 167 | =item * C<user> scalar_as_object | ||||||||||
| 168 | |||||||||||
| 169 | =item * C<value> boolean (L<boolean object|Module::Generic::Boolean>) | ||||||||||
| 170 | |||||||||||
| 171 | =back | ||||||||||
| 172 | |||||||||||
| 173 | =head2 object | ||||||||||
| 174 | |||||||||||
| 175 | Returns the object type for this class, which is C<rating> | ||||||||||
| 176 | |||||||||||
| 177 | =head2 rating | ||||||||||
| 178 | |||||||||||
| 179 | $obj->rating("5.0"); | ||||||||||
| 180 | my $number = $obj->rating; | ||||||||||
| 181 | |||||||||||
| 182 | Sets or gets a float value, and returns a L<number object|Module::Generic::Number> or C<undef> if no value is set. | ||||||||||
| 183 | |||||||||||
| 184 | =head2 release | ||||||||||
| 185 | |||||||||||
| 186 | $obj->release( "PLACEHOLDER" ); | ||||||||||
| 187 | my $string = $obj->release; | ||||||||||
| 188 | |||||||||||
| 189 | Sets or gets a string and returns a L<scalar object|Module::Generic::Scalar>, even if there is no value. | ||||||||||
| 190 | |||||||||||
| 191 | =head2 user | ||||||||||
| 192 | |||||||||||
| 193 | $obj->user( "CPANRatings" ); | ||||||||||
| 194 | my $string = $obj->user; | ||||||||||
| 195 | |||||||||||
| 196 | Sets or gets a string and returns a L<scalar object|Module::Generic::Scalar>, even if there is no value. | ||||||||||
| 197 | |||||||||||
| 198 | =head1 API SAMPLE | ||||||||||
| 199 | |||||||||||
| 200 | { | ||||||||||
| 201 | "rating" : "5.0", | ||||||||||
| 202 | "user" : "CPANRatings", | ||||||||||
| 203 | "distribution" : "Japan-Folklore", | ||||||||||
| 204 | "release" : "PLACEHOLDER", | ||||||||||
| 205 | "date" : "2018-05-31T09:20:07", | ||||||||||
| 206 | "author" : "PLACEHOLDER" | ||||||||||
| 207 | } | ||||||||||
| 208 | |||||||||||
| 209 | =head1 AUTHOR | ||||||||||
| 210 | |||||||||||
| 211 | Jacques Deguest E<lt>F<jack@deguest.jp>E<gt> | ||||||||||
| 212 | |||||||||||
| 213 | =head1 SEE ALSO | ||||||||||
| 214 | |||||||||||
| 215 | 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> | ||||||||||
| 216 | |||||||||||
| 217 | L<MetaCPAN::API>, L<MetaCPAN::Client> | ||||||||||
| 218 | |||||||||||
| 219 | L<https://github.com/metacpan/metacpan-api/blob/master/docs/API-docs.md> | ||||||||||
| 220 | |||||||||||
| 221 | =head1 COPYRIGHT & LICENSE | ||||||||||
| 222 | |||||||||||
| 223 | Copyright(c) 2023 DEGUEST Pte. Ltd. | ||||||||||
| 224 | |||||||||||
| 225 | All rights reserved | ||||||||||
| 226 | |||||||||||
| 227 | This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. | ||||||||||
| 228 | |||||||||||
| 229 | =cut | ||||||||||
| 230 | |||||||||||