| 1 | 12 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 12 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | package DAIA::Availability; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | #ABSTRACT: Abstract base class of availability information | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 12 | our $VERSION = '0.43'; #VERSION | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 12 | ▶ | use base 'DAIA::Object'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 12 | ▶ | use Carp::Clan; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 12 | ▶ | use Data::Validate::URI qw(is_uri); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 12 | ▶ | use DateTime::Duration; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 12 | ▶ | use DateTime::Format::Duration; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 12 | ▶ | use DateTime; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 12 | ▶ | use base 'Exporter'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 12 | our @EXPORT_OK = qw(parse_duration normalize_duration date_or_datetime); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | our %PROPERTIES = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | service => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | # default => sub { croak 'DAIA::Availability->service is required' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 2 | ▶ | default => sub { undef }, # TODO: configure whether mandatory | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 32 | ▶ | filter => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 32 | my $s = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 32 | ▶ | return $s if $DAIA::Availability::SERVICES{$s}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 6 | ▶ | return $DAIA::Availability::SECIVRES{$s} if $DAIA::Availability::SECIVRES{$s}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | return $s if is_uri($s); return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | href => $DAIA::Object::COMMON_PROPERTIES{href}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | message => $DAIA::Object::COMMON_PROPERTIES{message}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 12 | limitation => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | type => 'DAIA::Limitation', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | repeatable => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | # known services | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 12 | our %SERVICES = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 'presentation' => 'http://purl.org/ontology/daia/Service/Presentation', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 'loan' => 'http://purl.org/ontology/daia/Service/Loan', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 'interloan' => 'http://purl.org/ontology/daia/Service/Interloan', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 'openaccess' => 'http://purl.org/ontology/daia/Service/Openaccess', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | our %SECIVRES = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 12 | map { $SERVICES{$_} => $_ } keys %SERVICES | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 31 | ▶ | sub _buildargs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_buildargs: called CC=13 SCAR=25.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 31 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 31 | my %args = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 31 | ▶ | if ( not (@_ % 2) ) { # even number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 13 | %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 13 | ▶ | if ( not defined $args{status} ) { # $service => $status | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 11 | foreach ( keys %DAIA::Availability::SERVICES ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 44 | ▶ | if ( defined $args{$_} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 3 | $args{status} = $args{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 3 | $args{service} = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 3 | delete $args{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } elsif ( @_ ) { # non empty, uneven number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 18 | ▶ | if ( @_ == 1 and UNIVERSAL::isa( $_[0], 'DAIA::Availability' ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
@_ == 1 and UNIVERSAL::isa($_[0], "DAIA::Availability")
MC/DC100%2/2
@_ == 1 and UNIVERSAL::isa($_[0], "DAIA::Availability")
@_ == 1
UNIVERSAL::isa($_[0], "DAIA::Availability")
Truth table100%3/3
A and B
A= @_ == 1B= UNIVERSAL::isa($_[0], "DAIA::Availability")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 3 | %args = %{ $_[0]->struct }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 3 | $self = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | ▶ | } elsif ( $DAIA::Availability::SERVICES{$_[0]} or is_uri($_[0]) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$DAIA::Availability::SERVICES{$_[0]} or is_uri($_[0])
MC/DC0%0/2
$DAIA::Availability::SERVICES{$_[0]} or is_uri($_[0])
$DAIA::Availability::SERVICES{$_[0]}
is_uri($_[0])
Truth table66%2/3
A or B
A= $DAIA::Availability::SERVICES{$_[0]}B= is_uri($_[0])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 15 | %args = ( service => @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | croak( "could not parse parameters to " . ref($self) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 31 | ▶ | if ( not defined $args{status} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 26 | ▶ | if ( ref($self) eq 'DAIA::Available' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 17 | $args{status} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | } elsif ( ref($self) eq 'DAIA::Unavailable' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 7 | $args{status} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 31 | return %args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 39 | ▶ | sub status { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
status: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 39 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 39 | my $class = ref($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 39 | my $status; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 39 | ▶ | if ( @_ > 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 35 | $status = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 35 | ▶ | if ( $status ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 23 | ▶ | if ( $class eq 'DAIA::Unavailable' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 2 | $self->expected( undef ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 2 | $self->queue( undef ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 23 | bless $self, 'DAIA::Available'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 12 | ▶ | if ( $class eq 'DAIA::Available' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 2 | $self->delay( undef ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 12 | bless $self, 'DAIA::Unavailable'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 4 | $status = $class eq 'DAIA::Available'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 39 | return $status; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | sub rdfhash { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rdfhash: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | my $me = { }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | my $servicetype = $DAIA::Availability::SERVICES{ $self->{service} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | || $self->{service}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$DAIA::Availability::SERVICES{$self->{'service'}} || $self->{'service'}
MC/DC0%0/2
$DAIA::Availability::SERVICES{$self->{'service'}} || $self->{'service'}
$DAIA::Availability::SERVICES{$self->{'service'}}
$self->{'service'}
Truth table0%0/3
A || B
A= $DAIA::Availability::SERVICES{$self->{'service'}}B= $self->{'service'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | $me->{'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'} = [{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | value => $servicetype, type => "uri" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | }] if $servicetype; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | $me->{'http://xmlns.com/foaf/0.1/page'} = [{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | value => $self->{href}, type => "uri" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | }] if $self->{href}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | $me->{'http://purl.org/dc/terms/description'} = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | map { $_->rdfhash } @{$self->{message}} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | ] if $self->{message}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | $me->{'http://purl.org/ontology/daia/expected'} = [{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | value => $self->{expected}, type => 'literal', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | # xsd:date or xsd:dateTime to 'unknown' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | }] if $self->{expected}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | $me->{'http://purl.org/ontology/daia/delay'} = [{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | value => $self->{delay}, type => 'literal', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | # TODO: how to treat delay = "unknown"? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | # datatype => 'http://www.w3.org/2001/XMLSchema#duration', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | }] if $self->{delay}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | $me->{'http://purl.org/ontology/daia/delay'} = [{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | value => $self->{queue}, type => 'literal', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | datatype => 'http://www.w3.org/2001/XMLSchema#integer', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | }] if defined $self->{queue}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | if ($self->{limitation}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | # TODO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | # some limitations may be literal, some may be uri/blank | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | # 'limitedBy' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | my $rdf = { }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | $rdf->{ $self->rdfuri } = $me; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | return $rdf; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 4 | ▶ | sub parse_duration { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_duration: called CC=12 SCAR=25.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 4 | ▶ | return $_[0] if UNIVERSAL::isa( $_[0], 'DateTime::Duration' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 4 | my $duration = "$_[0]"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 4 | my ($neg, $year, $mounth, $day, $hour, $min, $sec, $fsec); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 4 | ▶ | if ($duration =~ /^(-)? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | P | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | ((\d+)Y)? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | ((\d+)M)? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | ((\d+)D)? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | T | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | ((\d+)H)? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | ((\d+)M)? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | (((\d+)(\.(\d+))?)S)? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | )? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | $/x) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 4 | ($neg, $year, $mounth, $day, $hour, $min, $sec, $fsec) = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | ($1, $3, $5, $7, $10, $12, $15, $17); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 4 | ▶ | return unless (grep {defined} ($year, $mounth, $day, $hour, $min, $sec)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 4 | ▶ | $duration = DateTime::Duration->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition91%11/12
$year || 0
$mounth || 0
$day || 0
$hour || 0
$min || 0
$sec || 0
MC/DC100%1/1
$year || 0
$year
MC/DC100%1/1
$mounth || 0
$mounth
MC/DC100%1/1
$day || 0
$day
MC/DC100%1/1
$hour || 0
$hour
MC/DC100%1/1
$min || 0
$min
MC/DC0%0/1
$sec || 0
$sec
Truth table100%2/2
A
A= $year
Truth table100%2/2
A
A= $mounth
Truth table100%2/2
A
A= $day
Truth table100%2/2
A
A= $hour
Truth table100%2/2
A
A= $min
Truth table50%1/2
A
A= $sec
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | years => $year || 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | months => $mounth || 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | days => $day || 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | hours => $hour || 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | minutes => $min || 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | seconds => $sec || 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | nanoseconds => ($fsec ? "0.$fsec" * 1E9 : 0), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 4 | ▶ | $duration = $duration->inverse if $neg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 4 | return $duration; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 4 | ▶ | sub normalize_duration { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
normalize_duration: called CC=23 SCAR=34.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 4 | my $duration = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 4 | ▶ | $duration = parse_duration( $duration ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | unless UNIVERSAL::isa( $duration, 'DateTime::Duration' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 4 | ▶ | return unless defined $duration; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 4 | ▶ | return "P0D" if $duration->is_zero; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | # TODO: replace this | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 3 | my $fmt = DateTime::Format::Duration->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | pattern => '%PP%YY%mM%dDT%HH%MM%S.%NS', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | normalize => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 3 | my %d = $fmt->normalize( $duration ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 3 | ▶ | if (exists $d{seconds} or exists $d{nanoseconds}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $d{"seconds"} or exists $d{"nanoseconds"}
MC/DC0%0/2
exists $d{"seconds"} or exists $d{"nanoseconds"}
exists $d{"seconds"}
exists $d{"nanoseconds"}
Truth table33%1/3
A or B
A= exists $d{"seconds"}B= exists $d{"nanoseconds"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | $d{seconds} = ($d{seconds} || 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 3 | ▶ | + (exists $d{nanoseconds} ? $d{nanoseconds} / 1E9 : 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$d{'seconds'} || 0
MC/DC0%0/1
$d{'seconds'} || 0
$d{'seconds'}
Truth table50%1/2
A
A= $d{'seconds'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 3 | ▶ | my $str = $d{negative} ? "-P" : "P"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 3 | ▶ | $str .= "$d{years}Y" if exists $d{years} and $d{years} > 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $d{"years"} and $d{"years"} > 0
MC/DC50%1/2
exists $d{"years"} and $d{"years"} > 0
exists $d{"years"}
$d{"years"} > 0
Truth table66%2/3
A and B
A= exists $d{"years"}B= $d{"years"} > 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 3 | ▶ | $str .= "$d{months}M" if exists $d{months} and $d{months} > 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $d{"months"} and $d{"months"} > 0
MC/DC50%1/2
exists $d{"months"} and $d{"months"} > 0
exists $d{"months"}
$d{"months"} > 0
Truth table66%2/3
A and B
A= exists $d{"months"}B= $d{"months"} > 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 3 | ▶ | $str .= "$d{days}D" if exists $d{days} and $d{days} > 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $d{"days"} and $d{"days"} > 0
MC/DC0%0/2
exists $d{"days"} and $d{"days"} > 0
exists $d{"days"}
$d{"days"} > 0
Truth table33%1/3
A and B
A= exists $d{"days"}B= $d{"days"} > 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 3 | ▶ | $str .= "T" if grep {exists $d{$_} and $d{$_} > 0} qw(hours minutes seconds); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $d{$_} && $d{$_} > 0
MC/DC50%1/2
exists $d{$_} && $d{$_} > 0
exists $d{$_}
$d{$_} > 0
Truth table66%2/3
A && B
A= exists $d{$_}B= $d{$_} > 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 3 | ▶ | $str .= "$d{hours}H" if exists $d{hours} and $d{hours} > 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $d{"hours"} and $d{"hours"} > 0
MC/DC50%1/2
exists $d{"hours"} and $d{"hours"} > 0
exists $d{"hours"}
$d{"hours"} > 0
Truth table66%2/3
A and B
A= exists $d{"hours"}B= $d{"hours"} > 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 3 | ▶ | $str .= "$d{minutes}M" if exists $d{minutes} and $d{minutes} > 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $d{"minutes"} and $d{"minutes"} > 0
MC/DC50%1/2
exists $d{"minutes"} and $d{"minutes"} > 0
exists $d{"minutes"}
$d{"minutes"} > 0
Truth table66%2/3
A and B
A= exists $d{"minutes"}B= $d{"minutes"} > 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 3 | ▶ | $str .= "$d{seconds}S" if exists $d{seconds} and $d{seconds} > 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $d{"seconds"} and $d{"seconds"} > 0
MC/DC0%0/2
exists $d{"seconds"} and $d{"seconds"} > 0
exists $d{"seconds"}
$d{"seconds"} > 0
Truth table33%1/3
A and B
A= exists $d{"seconds"}B= $d{"seconds"} > 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 3 | return $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 9 | ▶ | sub date_or_datetime { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
date_or_datetime: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 9 | my $dt = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 9 | ▶ | if ( not UNIVERSAL::isa( $dt, 'DateTime' ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | return unless | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 8 | ▶ | $dt =~ /^(-?\d\d\d\d+-\d\d-\d\d)(T\d\d:\d\d:\d\d(\.\d+)?)?([+-]\d\d:\d\d|Z)?$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 7 | my ($date,$time,$tz) = ($1,$2,$4); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 7 | $date =~ /(-?\d\d\d\d+)-(\d\d)-(\d\d)/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 7 | my %p = (year=>$1,month=>$2,day=>$3); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 7 | ▶ | if ($time) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 4 | $time =~ /T(\d\d):(\d\d):(\d\d)(\.\d+)?/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 4 | ($p{hour},$p{minute},$p{second})=($1,$2,$3); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 7 | ▶ | if ($tz) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 1 | $tz =~ s/://; $tz =~ s/Z/UTC/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 1 | $p{time_zone} = $tz; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 7 | ▶ | $dt = eval { DateTime->new(%p) } || return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
eval {
do {
'DateTime'->new(%p)
}
} || (return)
MC/DC100%1/1
eval {
do {
'DateTime'->new(%p)
}
} || (return)
eval {
do {
'DateTime'->new(%p)
}
}
Truth table100%2/2
A
A= eval {
do {
'DateTime'->new(%p)
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 7 | $dt->set_time_zone('floating'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 7 | my $date = $dt->strftime("%FT%T"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 7 | $dt =~ s/T00:00:00$//; # remove time part if is zero | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 7 | return $dt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 12 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||