line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MARC::Spec; |
2
|
|
|
|
|
|
|
|
3
|
13
|
|
|
13
|
|
217383
|
use Carp qw(croak); |
|
13
|
|
|
|
|
1024
|
|
|
13
|
|
|
|
|
1071
|
|
4
|
13
|
|
|
13
|
|
6193
|
use Moo; |
|
13
|
|
|
|
|
150049
|
|
|
13
|
|
|
|
|
87
|
|
5
|
13
|
|
|
13
|
|
26258
|
use MARC::Spec::Parser; |
|
13
|
|
|
|
|
54
|
|
|
13
|
|
|
|
|
503
|
|
6
|
13
|
|
|
13
|
|
724
|
use namespace::clean; |
|
13
|
|
|
|
|
14166
|
|
|
13
|
|
|
|
|
73
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '1.0.0'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has field => ( |
11
|
|
|
|
|
|
|
is => 'rw', |
12
|
|
|
|
|
|
|
isa => sub { |
13
|
|
|
|
|
|
|
croak('Field is not an instance of MARC::Spec::Field') |
14
|
|
|
|
|
|
|
if(ref $_[0] ne 'MARC::Spec::Field') |
15
|
|
|
|
|
|
|
}, |
16
|
|
|
|
|
|
|
required => 1 |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has subfields => ( |
20
|
|
|
|
|
|
|
is => 'rwp', |
21
|
|
|
|
|
|
|
isa => sub { |
22
|
|
|
|
|
|
|
croak('Subfield is not an instance of MARC::Spec::Subfield.') |
23
|
|
|
|
|
|
|
if(grep {ref $_ ne 'MARC::Spec::Subfield'} @{$_[0]}) |
24
|
|
|
|
|
|
|
}, |
25
|
|
|
|
|
|
|
predicate => 1 |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub BUILDARGS { |
29
|
40
|
|
|
40
|
0
|
21344
|
my ($class, @args) = @_; |
30
|
40
|
50
|
|
|
|
204
|
if (@args % 2 == 1) { unshift @args, "field" } |
|
40
|
|
|
|
|
130
|
|
31
|
40
|
|
|
|
|
845
|
return { @args }; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub add_subfield { |
35
|
2
|
|
|
2
|
0
|
30
|
my ($self, $subfield) = @_; |
36
|
2
|
50
|
|
|
|
15
|
if(!$self->has_subfields) { |
37
|
2
|
|
|
|
|
46
|
$self->_set_subfields([$subfield]); |
38
|
|
|
|
|
|
|
} else { |
39
|
0
|
|
|
|
|
0
|
my @subfields = ( @{$self->subfields}, $subfield ); |
|
0
|
|
|
|
|
0
|
|
40
|
0
|
|
|
|
|
0
|
$self->_set_subfields( \@subfields ); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub add_subfields { |
45
|
23
|
|
|
23
|
0
|
77
|
my ($self, $subfields) = @_; |
46
|
23
|
50
|
|
|
|
106
|
if (ref $subfields ne 'ARRAY') { |
47
|
0
|
|
|
|
|
0
|
croak('Subfields is not an ARRAYRef!') |
48
|
|
|
|
|
|
|
} |
49
|
23
|
100
|
|
|
|
130
|
if(!$self->has_subfields) { |
50
|
22
|
|
|
|
|
475
|
$self->_set_subfields($subfields); |
51
|
|
|
|
|
|
|
} else { |
52
|
1
|
|
|
|
|
4
|
my @merged = ( @{$self->subfields}, @{$subfields} ); |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
4
|
|
53
|
1
|
|
|
|
|
31
|
$self->_set_subfields( \@merged ) |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub parse { |
58
|
30
|
|
|
30
|
1
|
15899
|
my ($spec) = @_; |
59
|
30
|
|
|
|
|
592
|
my $parser = MARC::Spec::Parser->new($spec); |
60
|
19
|
|
|
|
|
391
|
return $parser->marcspec; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub to_string { |
64
|
9
|
|
|
9
|
0
|
59
|
my ($self) = @_; |
65
|
9
|
|
|
|
|
148
|
my $string = $self->field->to_string(); |
66
|
9
|
100
|
|
|
|
28
|
if($self->has_subfields) { |
67
|
5
|
|
|
|
|
8
|
foreach my $sf (@{$self->subfields}) { |
|
5
|
|
|
|
|
15
|
|
68
|
5
|
|
|
|
|
17
|
$string .= $sf->to_string() |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
9
|
|
|
|
|
83
|
return $string; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
1; |
74
|
|
|
|
|
|
|
__END__ |