| 1 | package WebService::Libris::Author; | ||||||||||||||||||||
| 2 | 1 | ▶ | use Mojo::Base 'WebService::Libris'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 1 | ▶ | use 5.010; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 5 | ▶ | sub fragments { | ||||||||||||||||||
|
Subroutine
fragments: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 8 | 5 | 'auth', shift->id; | |||||||||||||||||||
| 9 | } | ||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 4 | ▶ | sub _description { | ||||||||||||||||||
|
Subroutine
_description: called CC=2 SCAR=7.6
| |||||||||||||||||||||
| 12 | 4 | my $self = shift; | |||||||||||||||||||
| 13 | 4 | my $url = join '/', $self->fragments; | |||||||||||||||||||
| 14 | 4 | ▶ | $self->dom->at(qq{description[about\$="$url"]}) // Mojo::DOM->new; | ||||||||||||||||||
|
Condition33%1/3
$self->dom->at(qq[description[about\$="$url"]]) // "Mojo::DOM"->new
MC/DC0%0/2
$self->dom->at(qq[description[about\$="$url"]]) // "Mojo::DOM"->new
$self->dom->at(qq[description[about\$="$url"]])
"Mojo::DOM"->new
Truth table33%1/3
A // B
A= $self->dom->at(qq[description[about\$="$url"]])B= "Mojo::DOM"->new
| |||||||||||||||||||||
| 15 | } | ||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 1 | ▶ | sub birthyear { | ||||||||||||||||||
|
Subroutine
birthyear: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||
| 18 | 1 | my $d = shift->_description->at('birthyear'); | |||||||||||||||||||
| 19 | 1 | ▶ | $d && $d->text | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 20 | } | ||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | 1 | ▶ | sub libris_key { | ||||||||||||||||||
|
Subroutine
libris_key: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||
| 23 | 1 | my $d = shift->_description->at('key'); | |||||||||||||||||||
| 24 | 1 | ▶ | $d && $d->text | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 25 | } | ||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | 1 | ▶ | sub same_as { | ||||||||||||||||||
|
Subroutine
same_as: called CC=2 SCAR=7.4
Pod
documented
| |||||||||||||||||||||
| 28 | 1 | my $self = shift; | |||||||||||||||||||
| 29 | 1 | my $sd = $self->_description->at('sameas'); | |||||||||||||||||||
| 30 | 1 | ▶ | if ($sd) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 31 | 0 | return $sd->attr('rdf:resource'); | |||||||||||||||||||
| 32 | } | ||||||||||||||||||||
| 33 | 1 | return; | |||||||||||||||||||
| 34 | } | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 1 | ▶ | sub names { | ||||||||||||||||||
|
Subroutine
names: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 37 | 1 | map $_->text, shift->_description->find('name')->each; | |||||||||||||||||||
| 38 | } | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | 0 | ▶ | sub books { | ||||||||||||||||||
|
Subroutine
books: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 41 | 0 | 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<WebService::Libris::Author> inherits from L<WebService::Libris>, 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 | 1; | |||||||||||||||||||