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.45'; |
4
|
4
|
|
|
4
|
|
35
|
use Moose; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
29
|
|
5
|
4
|
|
|
4
|
|
30365
|
use utf8; |
|
4
|
|
|
|
|
77
|
|
|
4
|
|
|
|
|
23
|
|
6
|
4
|
|
|
4
|
|
144
|
use Modern::Perl; |
|
4
|
|
|
|
|
19
|
|
|
4
|
|
|
|
|
28
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
extends 'MARC::Moose::Formater'; |
9
|
|
|
|
|
|
|
|
10
|
4
|
|
|
4
|
|
2464
|
use MARC::Moose::Field::Control; |
|
4
|
|
|
|
|
27
|
|
|
4
|
|
|
|
|
168
|
|
11
|
4
|
|
|
4
|
|
2612
|
use MARC::Moose::Field::Std; |
|
4
|
|
|
|
|
14
|
|
|
4
|
|
|
|
|
348
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
override 'format' => sub { |
16
|
|
|
|
|
|
|
my ($self, $record) = @_; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my ( $directory, $fields, $from ) = ( '', '', 0 ); |
19
|
4
|
|
|
4
|
|
2571
|
use YAML; |
|
4
|
|
|
|
|
32309
|
|
|
4
|
|
|
|
|
1526
|
|
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.45 |
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) 2022 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 |