File Coverage

blib/lib/Catmandu/Fix/rkd_name.pm
Criterion Covered Total %
statement 29 29 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod 0 1 0.0
total 36 37 97.3


line stmt bran cond sub pod time code
1             package Catmandu::Fix::rkd_name;
2              
3 2     2   224841 use strict;
  2         2  
  2         60  
4              
5 2     2   489 use Catmandu::Sane;
  2         115688  
  2         15  
6 2     2   375 use Moo;
  2         2  
  2         11  
7              
8 2     2   1250 use Catmandu::Fix::Has;
  2         1340  
  2         11  
9 2     2   1812 use Catmandu::Fix::Datahub::Util qw(declare_source);
  2         709  
  2         389  
10              
11             with 'Catmandu::Fix::Base';
12              
13             has path => (fix_arg => 1);
14              
15             sub emit {
16 1     1 0 7587 my ($self, $fixer) = @_;
17 1         3 my $perl = '';
18              
19 1         2 $perl .= 'use Catmandu::Store::RKD::API::Name;';
20              
21 1         3 my $name = $fixer->generate_var();
22 1         34 my $rkd = $fixer->generate_var();
23              
24 1         29 $perl .= "my ${name};";
25 1         7 $perl .= declare_source($fixer, $self->path, $name);
26              
27 1         149 $perl .= "my ${rkd} = Catmandu::Store::RKD::API::Name->new(name_to_search => ${name});";
28              
29             $perl .= $fixer->emit_create_path(
30             $fixer->var,
31             $fixer->split_path($self->path),
32             sub {
33 1     1   123 my $root = shift;
34 1         2 my $code = '';
35 1         3 $code .= "${root} = ${rkd}->results;";
36              
37 1         4 return $code;
38             }
39 1         15 );
40              
41 1         10 return $perl;
42             }
43              
44             1;
45             __END__
46              
47             =head1 NAME
48              
49             Catmandu::Fix::rkd_name - Retrieve items from the RKD by name
50              
51             =head1 SYNOPSIS
52              
53             A fix to retrieve a RKD record based on an artist name.
54              
55             =head1 DESCRIPTION
56              
57             The fix takes a name (first name, last name or a combination) and performs a lookup to the RKD artists database. It
58             returns an array of results. Every result is of the form:
59              
60             {
61             'title' => 'Name of the person',
62             'description' => 'Short description, as provided by RKD',
63             'artist_link' => 'Link to the artist using the artist id',
64             'guid' => 'Permalink to the record'
65             }
66              
67             For some names, it can/will return multiple possibilities. You must determine yourself which one is the 'correct' one.
68              
69             =head1 SEE ALSO
70              
71             L<Catmandu>
72             L<Catmandu::Store::RKD>
73              
74             =head1 AUTHORS
75              
76             Pieter De Praetere, C<< pieter at packed.be >>
77              
78             =head1 CONTRIBUTORS
79              
80             Pieter De Praetere, C<< pieter at packed.be >>
81              
82             =head1 COPYRIGHT AND LICENSE
83              
84             This package is copyright (c) 2016 by PACKED vzw.
85             This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
86              
87             =cut