Catmandu/Fix/Condition/is_archived_web_uri.pm

filter: Statementstmt 100% 24 / 24 Branchbran 50.0% 1 / 2 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 84.2% 32 / 38 CC 3 SCAR 6.3
CC
3
Cov
90%
emit_test
3.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.9
« Catmandu/Identifier.pm ↑ Summary Catmandu/Fix/Condition/is_live_orcid.pm »
1 package Catmandu::Fix::Condition::is_archived_web_uri;
2  
3 1 our $VERSION = '0.15';
4  
5 1 ▶use Catmandu::Sane;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Data::Validate::URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Memento::TimeTravel;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Catmandu::Fix::Has;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 has path => (fix_arg => 1);
12 1 has date => (fix_arg => 1);
13  
14 1 with 'Catmandu::Fix::Condition::SimpleAllTest';
15  
16 5 ▶sub emit_test {
Subroutine emit_test: called CC=3 SCAR=12.0
Pod undocumented
17 5 my ($self, $var) = @_;
18 5 my $date = $self->date;
19 5 ▶ $date = [localtime]->[5] + 1900 unless defined($date) && length($date);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $date and length $date 0 5 5
Condition33%1/3
defined $date and length $date
!ll&&!rl&&r
005
MC/DC0%0/2
defined $date and length $date
defined $date length $date
Truth table33%1/3
A and B
A= defined $dateB= length $date
ABresult
0X0
100
111
20  
21 5 "(is_value(${var}) && Data::Validate::URI::is_web_uri(${var}) && Memento::TimeTravel::find_mementos(${var},${date}))";
22 }
23  
24 =head1 NAME
25  
26 Catmandu::Fix::Condition::is_archived_web_uri - check of a field contains an HTTP or HTTPS URI which is archived in a web archive
27  
28 =head1 SYNOPSIS
29  
30 # Check if an archived version is available for any year...
31 if is_archived_web_uri(uri_field,'')
32 ...
33 else
34 ...
35 end
36  
37 # Check if an archived version is available for a year...
38 if is_archived_web_uri(uri_field,2013)
39 ...
40 else
41 ...
42 end
43  
44 =head1 SEE ALSO
45  
46 L<Catmandu::Fix>
47  
48 =cut
49  
50 1 1;
« Catmandu/Identifier.pm ↑ Summary Catmandu/Fix/Condition/is_live_orcid.pm »