Memento/TimeTravel.pm

filter: Statementstmt 100% 27 / 27 Branchbran 62.5% 5 / 8 Conditioncond 50.0% 3 / 6 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 80.7% 42 / 52 CC 7 SCAR 16.0
CC
7
Cov
85%
find_mementos
7.8
BEGIN
1.0
BEGIN
1.0
CRAP 4.9
↑ Summary Catmandu/Identifier.pm »
1 package Memento::TimeTravel;
2  
3 2 our $VERSION = '0.15';
4  
5 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use LWP::Simple;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 ▶sub find_mementos {
Subroutine find_mementos: called CC=7 SCAR=20.5
Pod undocumented
12 2 my ($self, $uri, $date) = @_;
13  
14 2 ▶ unless (blessed($self)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (builtin::blessed($self)) 2 0 2
15 2 $date = $uri;
16 2 $uri = $self;
17 }
18  
19 2 ▶ die "usage: find_mementos(uri,date)"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $uri and defined $date 0 2 2
Condition33%1/3
defined $uri and defined $date
!ll&&!rl&&r
002
MC/DC0%0/2
defined $uri and defined $date
defined $uri defined $date
Truth table33%1/3
A and B
A= defined $uriB= defined $date
ABresult
0X0
100
111
20 unless defined($uri) && defined($date);
21  
22 2 ▶ die "usage: date =~ YYYYMMDDHHMMSS" unless ($date =~ /^\d{4,14}$/);
Branch: 1 branch
BranchTrueFalseTotal
unless $date =~ /^\d{4,14}$/ 0 2 2
23  
24 2 my $api_call = sprintf "http://timetravel.mementoweb.org/api/json/%s/%s",
25 $date, $uri;
26  
27 2 my $mementos = get($api_call);
28  
29 2 ▶ return undef unless defined($mementos) && length($mementos);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $mementos and length $mementos 1 1 2
Condition66%2/3
defined $mementos and length $mementos
!ll&&!rl&&r
101
MC/DC50%1/2
defined $mementos and length $mementos
defined $mementos length $mementos
Truth table66%2/3
A and B
A= defined $mementosB= length $mementos
ABresult
0X0
100
111
30  
31 1 decode_json($mementos);
32 }
33  
34 =head1 NAME
35  
36 Memento::TimeTravel - A time traveler for URLS
37  
38 =head1 SYNOPSIS
39  
40 use Memento::TimeTravel;
41  
42 my $traveler = Memento::TimeTravel->new();
43  
44 my $mementos = $traveler->find_mementos('http://www.ugent.be/',2013);
45  
46 =head1 AUTHOR
47  
48 Patrick Hochstenbach, C<< <patrick.hochstenbach at ugent.be> >>
49  
50 =head1 LICENSE
51  
52 This program is free software; you can redistribute it and/or modify it
53 under the terms of either: the GNU General Public License as published
54 by the Free Software Foundation; or the Artistic License.
55  
56 See http://dev.perl.org/licenses/ for more information.
57  
58 =cut
59  
60 2 1;
↑ Summary Catmandu/Identifier.pm »