Detrans/Name.pm

filter: Statementstmt 100% 19 / 19 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 100% 1 / 1 totaltotal 93.1% 27 / 29 CC 3 SCAR 6.4
CC
3
Cov
91%
new
3.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.9
« Detrans/Names.pm ↑ Summary
1 package MARC::Detrans::Name;
2  
3 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 8 ▶use base qw( Class::Accessor );
Subroutine BEGIN: called CC=1 SCAR=0.0
6 8 ▶use Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 =head1 NAME
9  
10 MARC::Detrans::Name - A single name mapping
11  
12 =head1 SYNOPSIS
13  
14 use MARC::Detrans::Name;
15 my $name = MARC::Detrans::Name->new(
16 from => '$aNicholas $bI, $cEmperor of Russia, $d1796-1855',
17 to => '$a^[(NnIKOLAJ^[s, $bI, $c^[(NiMPERATOR^[s ^[(NwSEROSSIJSKIJ^[s, $d1796-1855'
18 );
19  
20 =head1 DESCRIPTION
21  
22 MARC::Detrans::Rule represents a single non-standard detransliteration mapping
23 for a MARC field. For example personal names often have non-standard
24 transliterations, so to get them back to the original script a non-rules based
25 detransliteration has to occur.
26  
27 MARC::Detrans::Name and MARC::Detrans::Names aid in this process by allowing you
28 to create a single mapping of one field to another, and then adding them to a
29 rule set.
30  
31 =head1 METHODS
32  
33 =head2 new()
34  
35 The constructor which you must pass the from and to parameters, which
36 define what name will be transformed.
37  
38 =cut
39  
40 5 ▶sub new {
Subroutine new: called CC=3 SCAR=11.3
Pod documented
41 5 my ($class,%args) = @_;
42 5 ▶ croak( "must supply from parameter" ) if ! exists $args{from};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $args{"from"} 0 5 5
43 5 ▶ croak( "must supply to parameter" ) if ! exists $args{to};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $args{"to"} 0 5 5
44 ## convert ^ESC to 0x1B since XML can't contain this character
45 5 $args{to} =~ s/\^ESC/\x1B/g;
46 5 return $class->SUPER::new( \%args );
47 }
48  
49 =head2 from()
50  
51 =head2 to()
52  
53 =cut
54  
55 8 MARC::Detrans::Name->mk_accessors( qw(
56 from
57 to
58 ) );
59  
60 8 1;
« Detrans/Names.pm ↑ Summary