| 1 | 4 | package JSON::Feed::Types { | |||||||||||||||||||||||||||
| 2 | 4 | ▶ | use Type::Library -base; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use Type::Utils -all; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use Types::Standard qw<Str Int Bool Dict Optional ArrayRef HashRef>; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use Types::Common::Numeric qw< PositiveOrZeroInt >; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | my $AuthorWithoutExt = declare JSONFeedAuthorWithoutExt => as Dict[ | ||||||||||||||||||||||||||||
| 8 | name => Optional[Str], | ||||||||||||||||||||||||||||
| 9 | url => Optional[Str], | ||||||||||||||||||||||||||||
| 10 | avatar => Optional[Str], | ||||||||||||||||||||||||||||
| 11 | ], where { | ||||||||||||||||||||||||||||
| 12 | exists($_->{name}) || exists($_->{url}) || exists($_->{avatar}) | ||||||||||||||||||||||||||||
| 13 | 273 | ▶ | }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
Branch: 1 branch
Condition100%3/3
exists $_->{"name"} or exists $_->{"url"}
MC/DC100%2/2
exists $_->{"name"} or exists $_->{"url"}
exists $_->{"name"}
exists $_->{"url"}
Truth table100%3/3
A or B
A= exists $_->{"name"}B= exists $_->{"url"}
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | my $Author = declare JSONFeedAuthor => as HashRef, where { | ||||||||||||||||||||||||||||
| 16 | 274 | ▶ | my $val = $_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 274 | my %o = map { $_ => $val->{$_} } grep { ! /^_/ } keys %$val; | |||||||||||||||||||||||||||
| 18 | 274 | $AuthorWithoutExt->check(\%o); | |||||||||||||||||||||||||||
| 19 | 4 | }; | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 4 | my $AttachmentWithoutExt = declare JSONFeedAttachmentWithoutExt => as Dict[ | |||||||||||||||||||||||||||
| 22 | url => Str, | ||||||||||||||||||||||||||||
| 23 | mime_type => Str, | ||||||||||||||||||||||||||||
| 24 | title => Optional[Str], | ||||||||||||||||||||||||||||
| 25 | size_in_bytes => Optional[PositiveOrZeroInt], | ||||||||||||||||||||||||||||
| 26 | duration_in_seconds => Optional[PositiveOrZeroInt], | ||||||||||||||||||||||||||||
| 27 | ]; | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | my $Attachment = declare JSONFeedAttachment => as HashRef, where { | ||||||||||||||||||||||||||||
| 30 | 29 | ▶ | my $val = $_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 31 | 29 | my %o = map { $_ => $val->{$_} } grep { ! /^_/ } keys %$val; | |||||||||||||||||||||||||||
| 32 | 29 | $AttachmentWithoutExt->check(\%o); | |||||||||||||||||||||||||||
| 33 | 4 | }; | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 4 | my $ItemWithoutExt = declare JSONFeedItemWithoutExt => as Dict[ | |||||||||||||||||||||||||||
| 36 | id => Str, | ||||||||||||||||||||||||||||
| 37 | url => Optional[Str], | ||||||||||||||||||||||||||||
| 38 | external_url => Optional[Str], | ||||||||||||||||||||||||||||
| 39 | title => Optional[Str], | ||||||||||||||||||||||||||||
| 40 | content_html => Optional[Str], | ||||||||||||||||||||||||||||
| 41 | content_text => Optional[Str], | ||||||||||||||||||||||||||||
| 42 | summary => Optional[Str], | ||||||||||||||||||||||||||||
| 43 | image => Optional[Str], | ||||||||||||||||||||||||||||
| 44 | banner_image => Optional[Str], | ||||||||||||||||||||||||||||
| 45 | date_published => Optional[Str], | ||||||||||||||||||||||||||||
| 46 | date_modified => Optional[Str], | ||||||||||||||||||||||||||||
| 47 | author => Optional[ $Author ], | ||||||||||||||||||||||||||||
| 48 | tags => Optional[ArrayRef[Str]], | ||||||||||||||||||||||||||||
| 49 | attachments => Optional[ArrayRef[ $Attachment ]], | ||||||||||||||||||||||||||||
| 50 | ]; | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | my $Item = declare JSONFeedItem => as HashRef, where { | ||||||||||||||||||||||||||||
| 53 | 504 | ▶ | my $val = $_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 54 | 504 | my %o = map { $_ => $val->{$_} } grep { ! /^_/ } keys %$val; | |||||||||||||||||||||||||||
| 55 | 504 | $ItemWithoutExt->check(\%o); | |||||||||||||||||||||||||||
| 56 | 4 | }; | |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 4 | my $JSONFeedWithoutExt = declare JSONFeedWithoutExt => as Dict[ | |||||||||||||||||||||||||||
| 59 | version => Str, | ||||||||||||||||||||||||||||
| 60 | title => Str, | ||||||||||||||||||||||||||||
| 61 | description => Optional[Str], | ||||||||||||||||||||||||||||
| 62 | user_comment => Optional[Str], | ||||||||||||||||||||||||||||
| 63 | next_url => Optional[Str], | ||||||||||||||||||||||||||||
| 64 | icon => Optional[Str], | ||||||||||||||||||||||||||||
| 65 | favicon => Optional[Str], | ||||||||||||||||||||||||||||
| 66 | author => Optional[ $Author ], | ||||||||||||||||||||||||||||
| 67 | home_page_url => Optional[Str], | ||||||||||||||||||||||||||||
| 68 | feed_url => Optional[Str], | ||||||||||||||||||||||||||||
| 69 | expired => Optional[Bool], | ||||||||||||||||||||||||||||
| 70 | hub => Optional[ArrayRef], | ||||||||||||||||||||||||||||
| 71 | items => ArrayRef[ $Item ], | ||||||||||||||||||||||||||||
| 72 | ]; | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | declare JSONFeed => as HashRef, where { | ||||||||||||||||||||||||||||
| 75 | 32 | ▶ | my $val = $_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 76 | 32 | my %o = map { $_ => $val->{$_} } grep { ! /^_/ } keys %$val; | |||||||||||||||||||||||||||
| 77 | 32 | $JSONFeedWithoutExt->check(\%o); | |||||||||||||||||||||||||||
| 78 | 4 | }; | |||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 4 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 81 | }; | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 4 | 1; | |||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | =head1 NAME | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | JSON::Feed::Types - The Types for JSON::Feed package. | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | use JSON::Feed::Types; | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | JSONFeedAuthor->assert_validate( $obj1 ); | ||||||||||||||||||||||||||||
| 94 | JSONFeedAttachment->assert_validate( $obj2 ); | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | In this Type library, the following 4 types are defined and exported. | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | =over 4 | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | =item JSONFeed | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | =item JSONFeedItem | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | =item JSONFeedAuthor | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | =item JSONFeedAttachment | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | =back | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | These Types are object defined with L<Type::Tiny|https://metacpan.org/pod/Type::Tiny> and therefore | ||||||||||||||||||||||||||||
| 113 | have methods listed here: L<https://metacpan.org/pod/Type::Tiny#Methods>. | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | Each type corresponds to an object defined in L<jsonfeed spec v1|https://jsonfeed.org/version/1>. | ||||||||||||||||||||||||||||