File Coverage

blib/lib/Datahub/Factory/PIDS.pm
Criterion Covered Total %
statement 6 6 100.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 8 8 100.0


line stmt bran cond sub pod time code
1             package Datahub::Factory::PIDS;
2              
3             our $VERSION = '0.0.1';
4              
5 1     1   53564 use strict;
  1         2  
  1         26  
6 1     1   3 use warnings;
  1         1  
  1         25  
7              
8              
9              
10             1;
11              
12             __END__
13              
14             =encoding utf-8
15              
16             =head1 NAME
17              
18             Datahub::Factory::Importer::PIDS - Insert PIDS from an external source
19              
20             =head1 SYNOPSIS
21              
22             use Datahub::Factory::Importer::PIDS;
23             use Data::Dumper qw(Dumper);
24              
25             my $pids = Datahub::Factory::Importer::PIDS->new(
26             username => 'datahub',
27             api_key => 'datahub',
28             container_name => 'datahub'
29             );
30              
31             $pids->temporary_table($pids->get_object('test.csv'), 'id');
32              
33             =head1 DESCRIPTION
34              
35             The module uses L<Catmandu> to create a SQLite database from a CSV containing an export
36             of the L<Resolver|https://github.com/PACKED-vzw/resolver> that can be used in Catmandu fixes
37             to insert PIDS (Persistent Identifiers).
38              
39             The CSV's are stored on a protected Rackspace cloud files instance.
40              
41             It has absolutely no use outside of the L<Datahub|https://github.com/thedatahub/> use case.
42              
43             =head1 PARAMETERS
44              
45             =over
46              
47             =item C<username>
48              
49             Rackspace Cloud Files username to access the files.
50              
51             =item C<api_key>
52              
53             API key for the Cloud Files user.
54              
55             =item C<container_name>
56              
57             Name of the container where the files are stored. Optional, defaults to I<datahub>.
58              
59             =back
60              
61             =head1 METHODS
62              
63             =over
64              
65             =item C<get_object($filename)>
66              
67             Get the object called C<$filename> from the Cloud files instance and store it in C</tmp>.
68             Only accepts CSV's.
69              
70             Returns the local path of the object it just fetched.
71              
72             =item C<temporary_table($csv_location, $id_column)>
73              
74             Create a SQLite database (in C</tmp>) that stores the CSV that is stored in C<$csv_location>.
75             Create an C<_id> column (as expected by L<Catmandu::Fix::lookup_in_store>) in the database
76             from the column in the CSV called C<$id_column>.
77              
78             Returns nothing.
79              
80             =back
81              
82             =head1 AUTHOR
83              
84             Pieter De Praetere E<lt>pieter at packed.be E<gt>
85              
86             =head1 COPYRIGHT
87              
88             Copyright 2017- PACKED vzw
89              
90             =head1 LICENSE
91              
92             This library is free software; you can redistribute it and/or modify
93             it under the same terms as Perl itself.
94              
95             =head1 SEE ALSO
96              
97             L<Datahub::Factory>
98             L<Catmandu>
99              
100             =cut