line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::Libris::Author; |
2
|
1
|
|
|
1
|
|
6
|
use Mojo::Base 'WebService::Libris'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
10
|
|
3
|
1
|
|
|
1
|
|
220
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
5
|
1
|
|
|
1
|
|
34
|
use 5.010; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
541
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub fragments { |
8
|
5
|
|
|
5
|
1
|
131
|
'auth', shift->id; |
9
|
|
|
|
|
|
|
} |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub _description { |
12
|
4
|
|
|
4
|
|
9
|
my $self = shift; |
13
|
4
|
|
|
|
|
16
|
my $url = join '/', $self->fragments; |
14
|
4
|
|
33
|
|
|
82
|
$self->dom->at(qq{description[about\$="$url"]}) // Mojo::DOM->new; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub birthyear { |
18
|
1
|
|
|
1
|
1
|
4932
|
my $d = shift->_description->at('birthyear'); |
19
|
1
|
50
|
|
|
|
2689
|
$d && $d->text |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub libris_key { |
23
|
1
|
|
|
1
|
1
|
5
|
my $d = shift->_description->at('key'); |
24
|
1
|
50
|
|
|
|
3046
|
$d && $d->text |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub same_as { |
28
|
1
|
|
|
1
|
1
|
652
|
my $self = shift; |
29
|
1
|
|
|
|
|
5
|
my $sd = $self->_description->at('sameas'); |
30
|
1
|
50
|
|
|
|
2938
|
if ($sd) { |
31
|
1
|
|
|
|
|
11
|
return $sd->attr('rdf:resource'); |
32
|
|
|
|
|
|
|
} |
33
|
0
|
|
|
|
|
0
|
return; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub names { |
37
|
1
|
|
|
1
|
1
|
855
|
map $_->text, shift->_description->find('name')->each; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub books { |
41
|
0
|
|
|
0
|
1
|
|
shift->list_from_dom('description[about^="http://libris.kb.se/resource/bib/"]'); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 NAME |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
WebService::Libris::Author - Author objects for WebService::Libris |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 SYNOSPIS |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
use 5.010; |
51
|
|
|
|
|
|
|
use WebService::Libris; |
52
|
|
|
|
|
|
|
my $author = WebService::Libris->new( |
53
|
|
|
|
|
|
|
type => 'autho', |
54
|
|
|
|
|
|
|
id => '246603', |
55
|
|
|
|
|
|
|
); |
56
|
|
|
|
|
|
|
say $author->libris_key; # main name entry in the db |
57
|
|
|
|
|
|
|
for ($author->names) { |
58
|
|
|
|
|
|
|
say " name variant: $_"; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
say " identification URL: ", $author->same_as if $author->same_as; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 DESCRIPTIONO |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Author objects as returned from the libris.kb.se API search. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
All of the following methods can return undef or the empty list if the |
67
|
|
|
|
|
|
|
information is not available. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 METHODS |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
C inherits from L, and thus has all of its methods. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head2 libris_key |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Returns the canonical name of the author, as stored in libris. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 names |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Returns a list of alternative names used for that author. Often includes |
80
|
|
|
|
|
|
|
spelling variations and translations into other languages. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 birthyear |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Returns the birth year of the author. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 same_as |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Returns an URL that uniquely identifies the author. Those URLs typically |
89
|
|
|
|
|
|
|
point to viaf.org or dbpedia.org |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head2 books |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Returns a list of books written by this author. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |