line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MARC::Moose::Formater::Iso2709; |
2
|
|
|
|
|
|
|
# ABSTRACT: MARC::Moose record formater into ISO 2709 format |
3
|
|
|
|
|
|
|
$MARC::Moose::Formater::Iso2709::VERSION = '1.0.44'; |
4
|
4
|
|
|
4
|
|
30
|
use Moose; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
29
|
|
5
|
4
|
|
|
4
|
|
28131
|
use utf8; |
|
4
|
|
|
|
|
60
|
|
|
4
|
|
|
|
|
21
|
|
6
|
4
|
|
|
4
|
|
127
|
use Modern::Perl; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
26
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
extends 'MARC::Moose::Formater'; |
9
|
|
|
|
|
|
|
|
10
|
4
|
|
|
4
|
|
2584
|
use MARC::Moose::Field::Control; |
|
4
|
|
|
|
|
27
|
|
|
4
|
|
|
|
|
169
|
|
11
|
4
|
|
|
4
|
|
2394
|
use MARC::Moose::Field::Std; |
|
4
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
318
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
override 'format' => sub { |
16
|
|
|
|
|
|
|
my ($self, $record) = @_; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my ( $directory, $fields, $from ) = ( '', '', 0 ); |
19
|
4
|
|
|
4
|
|
2501
|
use YAML; |
|
4
|
|
|
|
|
29350
|
|
|
4
|
|
|
|
|
1479
|
|
20
|
|
|
|
|
|
|
for my $field ( @{$record->fields} ) { |
21
|
|
|
|
|
|
|
my $str = do { |
22
|
|
|
|
|
|
|
if ( ref($field) eq 'MARC::Moose::Field::Control' ) { |
23
|
|
|
|
|
|
|
$field->value . "\x1E"; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
else { |
26
|
|
|
|
|
|
|
my $str = ''; |
27
|
|
|
|
|
|
|
$str .= "\x1F" . $_->[0] . $_->[1] for @{$field->subf}; |
28
|
|
|
|
|
|
|
$str = $field->ind1 . $field->ind2 . $str . "\x1E"; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
}; |
31
|
|
|
|
|
|
|
#utf8::encode($str) unless utf8::is_utf8($str); |
32
|
|
|
|
|
|
|
$fields .= $str; |
33
|
|
|
|
|
|
|
#FIXME: Which of this lines is the correct one? |
34
|
|
|
|
|
|
|
my $len = bytes::length($str); |
35
|
|
|
|
|
|
|
#my $len = length($str); |
36
|
|
|
|
|
|
|
$directory .= sprintf( "%03s%04d%05d", $field->tag, $len, $from ); |
37
|
|
|
|
|
|
|
$from += $len; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# Update leader with calculated offset (data begining) and total length of |
41
|
|
|
|
|
|
|
# record |
42
|
|
|
|
|
|
|
my $offset = 24 + 12 * @{$record->fields} + 1; |
43
|
|
|
|
|
|
|
my $length = $offset + $from + 1; |
44
|
|
|
|
|
|
|
$record->set_leader_length( $length, $offset ); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
return $record->leader . $directory . "\x1E" . $fields . "\x1D"; |
47
|
|
|
|
|
|
|
}; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__ |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=pod |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=encoding UTF-8 |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 NAME |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
MARC::Moose::Formater::Iso2709 - MARC::Moose record formater into ISO 2709 format |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 VERSION |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
version 1.0.44 |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 AUTHOR |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Frédéric Demians <f.demians@tamil.fr> |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
This software is copyright (c) 2021 by Frédéric Demians. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
76
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |