File Coverage

blib/lib/Data/MARC/Leader/Utils.pm
Criterion Covered Total %
statement 39 60 65.0
branch 3 4 75.0
condition n/a
subroutine 12 22 54.5
pod 0 15 0.0
total 54 101 53.4


line stmt bran cond sub pod time code
1             package Data::MARC::Leader::Utils;
2              
3 7     7   188424 use strict;
  7         15  
  7         285  
4 7     7   40 use warnings;
  7         22  
  7         522  
5              
6 7     7   4263 use Class::Utils qw(set_params);
  7         116387  
  7         176  
7 7     7   695 use English;
  7         48  
  7         50  
8 7     7   4079 use Error::Pure qw(err);
  7         20  
  7         2581  
9 7     7   48 use Readonly;
  7         13  
  7         6402  
10              
11             our $VERSION = 0.07;
12              
13             # Constructor.
14             sub new {
15 10     10 0 1820911 my ($class, @params) = @_;
16              
17             # Create object.
18 10         40 my $self = bless {}, $class;
19              
20             # Language.
21 10         52 $self->{'lang'} = 'eng';
22              
23             # Process parameters.
24 10         53 set_params($self, @params);
25              
26 10         142 $self->{'_lang_class'} = 'Data::MARC::Leader::Utils::'.uc($self->{'lang'});
27 10         877 eval "require $self->{'_lang_class'};";
28 10 100       66 if ($EVAL_ERROR) {
29 1         9 err "Cannot load texts in language '$self->{'lang'}'.",
30             'Error', $EVAL_ERROR,
31             ;
32             }
33              
34 9         82 return $self;
35             }
36              
37             sub desc_bibliographic_level {
38 2     2 0 37 my ($self, $level_code) = @_;
39              
40 2         10 return $self->_text('BIBLIOGRAPHIC_LEVEL', $level_code);
41             }
42              
43             sub desc_char_coding_scheme {
44 2     2 0 18 my ($self, $char_coding_scheme) = @_;
45              
46 2         11 return $self->_text('CHAR_CODING_SCHEME', $char_coding_scheme);
47             }
48              
49             sub desc_descriptive_cataloging_form {
50 2     2 0 16 my ($self, $descriptive_cataloging_form) = @_;
51              
52 2         8 return $self->_text('DESCRIPTIVE_CATALOGING_FORM', $descriptive_cataloging_form);
53             }
54              
55             sub desc_encoding_level {
56 2     2 0 11 my ($self, $encoding_level) = @_;
57              
58 2         6 return $self->_text('ENCODING_LEVEL', $encoding_level);
59             }
60              
61             sub desc_impl_def_portion_len {
62 0     0 0 0 my ($self, $impl_def_portion_len) = @_;
63              
64 0         0 return $self->_text('IMPL_DEF_PORTION_LEN', $impl_def_portion_len);
65             }
66              
67             sub desc_indicator_count {
68 0     0 0 0 my ($self, $indicator_count) = @_;
69              
70 0         0 return $self->_text('INDICATOR_COUNT', $indicator_count);
71             }
72              
73             sub desc_length_of_field_portion_len {
74 0     0 0 0 my ($self, $length_of_field_portion_len) = @_;
75              
76 0         0 return $self->_text('LENGTH_OF_FIELD_PORTION_LEN', $length_of_field_portion_len);
77             }
78              
79             sub desc_multipart_resource_record_level {
80 0     0 0 0 my ($self, $multipart_resource_record_level) = @_;
81              
82 0         0 return $self->_text('MULTIPART_RESOURCE_RECORD_LEVEL', $multipart_resource_record_level);
83             }
84              
85             sub desc_starting_char_pos_portion_len {
86 0     0 0 0 my ($self, $starting_char_pos_portion_len) = @_;
87              
88 0         0 return $self->_text('STARTING_CHAR_POS_PORTION_LEN', $starting_char_pos_portion_len);
89             }
90              
91             sub desc_status {
92 0     0 0 0 my ($self, $status_code) = @_;
93              
94 0         0 return $self->_text('STATUS', $status_code);
95             }
96              
97             sub desc_subfield_code_count {
98 0     0 0 0 my ($self, $subfield_code_count) = @_;
99              
100 0         0 return $self->_text('SUBFIELD_CODE_COUNT', $subfield_code_count);
101             }
102              
103             sub desc_type {
104 0     0 0 0 my ($self, $type_code) = @_;
105              
106 0         0 return $self->_text('TYPE', $type_code);
107             }
108              
109             sub desc_type_of_control {
110 0     0 0 0 my ($self, $type_of_control) = @_;
111              
112 0         0 return $self->_text('TYPE_OF_CONTROL', $type_of_control);
113             }
114              
115             sub desc_undefined {
116 0     0 0 0 my ($self, $undefined) = @_;
117              
118 0         0 return $self->_text('UNDEFINED', $undefined);
119             };
120              
121             sub _text {
122 8     8   21 my ($self, $hash, $key) = @_;
123              
124 8         833 my $text = eval '$'.$self->{'_lang_class'}.'::'.$hash.'{$key};';
125 8 50       172 if ($EVAL_ERROR) {
126 0         0 err "Cannot get text.",
127             'Error', $EVAL_ERROR,
128             ;
129             }
130              
131 8         30 return $text;
132             }
133              
134             1;
135              
136             __END__