line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Exporter::RIS; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.12'; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
59525
|
use namespace::clean; |
|
1
|
|
|
|
|
13380
|
|
|
1
|
|
|
|
|
5
|
|
6
|
1
|
|
|
1
|
|
603
|
use Catmandu::Sane; |
|
1
|
|
|
|
|
172333
|
|
|
1
|
|
|
|
|
6
|
|
7
|
1
|
|
|
1
|
|
260
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
3
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
with 'Catmandu::Exporter'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $TAGS = [qw(TY A1 A2 A3 A4 AB AD AN AU AV BT C1 C2 C3 C4 C5 C6 C7 C8 CA CN |
12
|
|
|
|
|
|
|
CP CT CY DA DB DO DP ED EP ET ID IS J1 J2 JA JF JO KW L1 L2 L3 L4 |
13
|
|
|
|
|
|
|
LA LB LK M1 M2 M3 N1 N2 NV OP PB PP PY RI RN RP SE SN SP ST T1 T2 |
14
|
|
|
|
|
|
|
T3 TA TI TT U1 U2 U3 U4 U5 UR VL VO Y1 Y2)]; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $SMALL_TAG = qr/A2|AU|ED|EP|KW|PB|SP/; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub add { |
19
|
|
|
|
|
|
|
my ($self, $data) = @_; |
20
|
|
|
|
|
|
|
my $fh = $self->fh; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
for my $tag (@$TAGS) { |
23
|
|
|
|
|
|
|
if (my $vals = $data->{$tag}) { |
24
|
|
|
|
|
|
|
$vals = [$vals] unless ref $vals; |
25
|
|
|
|
|
|
|
for my $val (@$vals) { |
26
|
|
|
|
|
|
|
$val = substr($val, 255) if length($val) > 255 && $tag =~ $SMALL_TAG; |
27
|
|
|
|
|
|
|
print $fh "$tag - $val\r\n"; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
print $fh "ER - \r\n"; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
1; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
__END__ |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=pod |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 NAME |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Catmandu::Exporter::RIS - a RIS exporter |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 SYNOPSIS |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
use Catmandu::Exporter::RIS; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
my $exporter = Catmandu::Exporter::RIS->new(fix => 'myfix.txt'); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
$exporter->add_many($arrayref); |
52
|
|
|
|
|
|
|
$exporter->add_many($iterator); |
53
|
|
|
|
|
|
|
$exporter->add_many(sub { }); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
$exporter->add($hashref); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
$exporter->add({ |
58
|
|
|
|
|
|
|
TI => 'the Zen of CSS design', |
59
|
|
|
|
|
|
|
AU => ['Dave Shea','Molley E. Holzschlag'], |
60
|
|
|
|
|
|
|
IS => '0-321-30347-4' |
61
|
|
|
|
|
|
|
}); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
printf "exported %d objects\n" , $exporter->count; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 DESCRIPTION |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
The RIS exporter requires as input a Perl hash (or a fix) containing RIS |
68
|
|
|
|
|
|
|
fields and values as a string or array reference. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 SUPPORTED FIELDS |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
TY ID T1 TI CT T2 BT T3 A1 AU A2 ED A3 Y1 PY Y2 N1 AB N2 KW RP |
73
|
|
|
|
|
|
|
JF JO JA J1 J2 VL IS CP SP EP CY PB SN AD AV M1 M2 M3 U1 U2 U3 U4 U5 |
74
|
|
|
|
|
|
|
UR L1 L2 L3 L4 |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 SEE ALSO |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
L<Catmandu::Exporter> |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |