| 1 | package Atompub::Util; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 5 | ▶ | use Atompub; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 5 | ▶ | use Atompub::MediaType qw(media_type); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 5 | ▶ | use Perl6::Export::Attrs; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 5 | ▶ | use XML::Atom::Category; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 14 | ▶ | sub is_acceptable_media_type :Export { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_acceptable_media_type: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 14 | my($coll, $content_type) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 14 | ▶ | return 1 unless $coll; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 14 | my @accepts = map { split /[\s,]+/ } $coll->accept; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 14 | ▶ | @accepts = (media_type('entry')) unless @accepts; # assign default type | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 14 | grep { media_type($content_type)->is_a($_) } @accepts; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 5 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 11 | ▶ | sub is_allowed_category :Export { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_allowed_category: called CC=12 SCAR=24.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 11 | my($coll, @tests) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 11 | ▶ | return 1 unless $coll; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 11 | ▶ | return 1 unless $coll->categories; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 10 | ▶ | return 1 if grep { ! $_->fixed || $_->fixed ne 'yes' } $coll->categories; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
!$_->fixed || $_->fixed ne 'yes'
MC/DC50%1/2
!$_->fixed || $_->fixed ne 'yes'
!$_->fixed
$_->fixed ne 'yes'
Truth table66%2/3
not(A) || B
A= !$_->fixedB= $_->fixed ne 'yes'
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 9 | my @allowed; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 9 | for my $cats ($coll->categories) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 9 | push @allowed, map { my $cat = XML::Atom::Category->new; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 9 | ▶ | my $scheme = $_->scheme || $cats->scheme; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$_->scheme || $cats->scheme
MC/DC100%2/2
$_->scheme || $cats->scheme
$_->scheme
$cats->scheme
Truth table100%3/3
A || B
A= $_->schemeB= $cats->scheme
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 9 | $cat->term($_->term); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 9 | ▶ | $cat->scheme($scheme) if $scheme; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 9 | $cat } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | $cats->category; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 9 | ▶ | return 0 if ! @allowed && @tests; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not @allowed and @tests
MC/DC50%1/2
not @allowed and @tests
not @allowed
@tests
Truth table66%2/3
not(A) and B
A= not @allowedB= @tests
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 8 | for my $t (@tests) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 10 | ▶ | return 0 unless grep { _match_category($_, $t) } @allowed; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 5 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 12 | ▶ | sub _match_category { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_match_category: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 12 | my($allowed, $test) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 12 | ▶ | return $allowed->term eq $test->term | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition88%8/9
$allowed->term eq $test->term && (!$allowed->scheme || $test->scheme && $allowed->scheme eq $test->scheme)
not $allowed->scheme or $test->scheme and $allowed->scheme eq $test->scheme
$test->scheme and $allowed->scheme eq $test->scheme
MC/DC75%3/4
$allowed->term eq $test->term && (!$allowed->scheme || $test->scheme && $allowed->scheme eq $test->scheme)
$allowed->term eq $test->term
not $allowed->scheme
$test->scheme
$allowed->scheme eq $test->scheme
Truth table80%4/5
A && not(B) or C and D
A= $allowed->term eq $test->termB= not $allowed->schemeC= $test->schemeD= $allowed->scheme eq $test->scheme
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | && (!$allowed->scheme || $test->scheme && $allowed->scheme eq $test->scheme); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||