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   231978 use strict;
  2         4  
  2         61  
4              
5 2     2   360 use Catmandu::Sane;
  2         113089  
  2         15  
6 2     2   445 use Moo;
  2         3  
  2         12  
7              
8 2     2   1185 use Catmandu::Fix::Has;
  2         1275  
  2         10  
9 2     2   2097 use Catmandu::Fix::Datahub::Util qw(declare_source);
  2         727  
  2         358  
10              
11             with 'Catmandu::Fix::Base';
12              
13             has path => (fix_arg => 1);
14              
15             sub emit {
16 1     1 0 8268 my ($self, $fixer) = @_;
17 1         3 my $perl = '';
18              
19 1         3 $perl .= 'use Catmandu::Store::RKD::API::Name;';
20              
21 1         3 my $name = $fixer->generate_var();
22 1         33 my $rkd = $fixer->generate_var();
23              
24 1         30 $perl .= "my ${name};";
25 1         7 $perl .= declare_source($fixer, $self->path, $name);
26              
27 1         158 $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   130 my $root = shift;
34 1         1 my $code = '';
35 1         4 $code .= "${root} = ${rkd}->results;";
36              
37 1         3 return $code;
38             }
39 1         16 );
40              
41 1         9 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