| 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
| |||||||||||||||||||||||||||||
| 15 | 2 | $date = $uri; | |||||||||||||||||||||||||||
| 16 | 2 | $uri = $self; | |||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 2 | ▶ | die "usage: find_mementos(uri,date)" | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $uri and defined $date
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
| |||||||||||||||||||||||||||||
| 20 | unless defined($uri) && defined($date); | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 2 | ▶ | die "usage: date =~ YYYYMMDDHHMMSS" unless ($date =~ /^\d{4,14}$/); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
Condition66%2/3
defined $mementos and length $mementos
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
| |||||||||||||||||||||||||||||
| 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; | |||||||||||||||||||||||||||