line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Memento::TimeTravel; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.14'; |
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
17
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
63
|
|
6
|
2
|
|
|
2
|
|
10
|
use Moo; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
12
|
|
7
|
2
|
|
|
2
|
|
2045
|
use JSON; |
|
2
|
|
|
|
|
16649
|
|
|
2
|
|
|
|
|
13
|
|
8
|
2
|
|
|
2
|
|
286
|
use Scalar::Util qw(blessed); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
108
|
|
9
|
2
|
|
|
2
|
|
895
|
use LWP::Simple; |
|
2
|
|
|
|
|
26161
|
|
|
2
|
|
|
|
|
14
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub find_mementos { |
12
|
2
|
|
|
2
|
0
|
8731
|
my ($self, $uri, $date) = @_; |
13
|
|
|
|
|
|
|
|
14
|
2
|
50
|
|
|
|
13
|
unless (blessed($self)) { |
15
|
2
|
|
|
|
|
6
|
$date = $uri; |
16
|
2
|
|
|
|
|
4
|
$uri = $self; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
2
|
50
|
33
|
|
|
15
|
die "usage: find_mementos(uri,date)" |
20
|
|
|
|
|
|
|
unless defined($uri) && defined($date); |
21
|
|
|
|
|
|
|
|
22
|
2
|
50
|
|
|
|
16
|
die "usage: date =~ YYYYMMDDHHMMSS" unless ($date =~ /^\d{4,14}$/); |
23
|
|
|
|
|
|
|
|
24
|
2
|
|
|
|
|
13
|
my $api_call = sprintf "http://timetravel.mementoweb.org/api/json/%s/%s", |
25
|
|
|
|
|
|
|
$date, $uri; |
26
|
|
|
|
|
|
|
|
27
|
2
|
|
|
|
|
11
|
my $mementos = get($api_call); |
28
|
|
|
|
|
|
|
|
29
|
2
|
100
|
66
|
|
|
23891
|
return undef unless defined($mementos) && length($mementos); |
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
|
|
83
|
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
|
|
|
|
|
|
|
1; |