MRC/Variables.pm

filter: Statementstmt 100% 54 / 54 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod n/a totaltotal 100% 64 / 64 CC 20 SCAR 16.6
CC
20
Cov
100%
_get_correct_caps
9.0
_get_allowed
5.0
_get_legal_in
5.0
CRAP 5.3
« MRC.pm ↑ Summary
1 #
2 # This file is part of Convert-MRC
3 #
4 # This software is copyright (c) 2013 by Alan K. Melby.
5 #
6 # This is free software; you can redistribute it and/or modify it under
7 # the same terms as the Perl 5 programming language system itself.
8 #
9 package Convert::MRC::Variables;
10  
11 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 # ABSTRACT: Provide global constants used by Convert::MRC
14 7 our $VERSION = '4.03'; # VERSION
15 7 ▶use base 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
16 ## no critic (ProhibitAutomaticExportation)
17 7 our @EXPORT = qw(
18 %corresp
19 $langCode
20 %correctCaps
21 %allowed
22 %legalIn
23 %position
24 %meta
25 );
26  
27 # reference variables
28 7 our %corresp = _get_corresp();
29 7 our $langCode = _get_lang_code();
30 7 our %correctCaps = _get_correct_caps();
31 7 our %allowed = _get_allowed();
32 7 our %legalIn = _get_legal_in();
33 7 our %position = _get_position();
34 7 our %meta = _get_meta();
35  
36 # How does the data category from a header row relate to the header?
37 # (This is also a validity check.)
38 7 ▶sub _get_corresp {
Subroutine _get_corresp: called CC=1 SCAR=0.0
39 7 my %corresp = (
40 workingLanguage => 'Language',
41 sourceDesc => 'Source',
42 subjectField => 'Subject',
43 );
44 7 return %corresp;
45 }
46  
47 # ISO 639 language code, and optionally region code: fr, eng-US
48 # case-insensitive; values are smashed to lowercase when parsed
49 7 ▶sub _get_lang_code {
Subroutine _get_lang_code: called CC=1 SCAR=0.0
50 7 return qr/[a-zA-Z]{2,3}(?:-[a-zA-Z]{2})?/;
51 }
52  
53 # What is the proper capitalization for each data category/picklist item?
54 # A hash from a case-smashed version to the correct version, which will be
55 # used to recognize and fix user input.
56 7 ▶sub _get_correct_caps {
Subroutine _get_correct_caps: called CC=9 SCAR=22.0
57 7 my %correct_caps;
58 7 $correct_caps{'DatCat'}{ lc($_) } = $_ foreach qw (
59 sourceDesc workingLanguage subjectField xGraphic definition
60 term partOfSpeech administrativeStatus context geographicalUsage
61 grammaticalGender termLocation termType note source
62 crossReference externalCrossReference customerSubset projectSubset
63 transactionType fn org title role email uid tel adr type
64 );
65 7 $correct_caps{'partOfSpeech'}{ lc($_) } = $_ foreach qw (
66 noun verb adjective adverb properNoun other
67 );
68 7 $correct_caps{'administrativeStatus'}{ lc($_) } = $_ foreach qw (
69 preferredTerm-admn-sts admittedTerm-admn-sts
70 deprecatedTerm-admn-sts supersededTerm-admn-sts
71 );
72 7 $correct_caps{'grammaticalGender'}{ lc($_) } = $_ foreach qw (
73 masculine feminine neuter other
74 );
75 7 $correct_caps{'termLocation'}{ lc($_) } = $_ foreach qw (
76 menuItem dialogBox groupBox textBox comboBox comboBoxElement
77 checkBox tab pushButton radioButton spinBox progressBar slider
78 informativeMessage interactiveMessage toolTip tableText
79 userDefinedType
80 );
81 7 $correct_caps{'termType'}{ lc($_) } = $_ foreach qw (
82 fullForm acronym abbreviation shortForm variant phrase
83 );
84 7 $correct_caps{'transactionType'}{ lc($_) } = $_ foreach qw (
85 origination modification
86 );
87 7 $correct_caps{'type'}{ lc($_) } = $_ foreach qw (
88 person organization
89 );
90 7 return %correct_caps;
91 }
92  
93 # Which additional fields are allowed on which data categories?
94 7 ▶sub _get_allowed {
Subroutine _get_allowed: called CC=5 SCAR=16.1
95 7 my %allowed;
96 7 $allowed{$_}{'Note'} = 1 foreach qw ();
97 7 $allowed{$_}{'Source'} = 1 foreach qw (
98 definition subjectField context
99 );
100 7 $allowed{$_}{'Link'} = 1 foreach qw (
101 transactionType crossReference externalCrossReference xGraphic
102 );
103 $allowed{'transactionType'}{'Date'} =
104 7 $allowed{'transactionType'}{'Responsibility'} = 1;
105 7 $allowed{$_}{'FieldLang'} = 1 foreach qw (Source Note Responsibility);
106 7 return %allowed;
107 }
108  
109 # which data categories are allowed at which level?
110 7 ▶sub _get_legal_in {
Subroutine _get_legal_in: called CC=5 SCAR=16.1
111 7 $legalIn{'Concept'}{$_} = 1 foreach qw (
112 transactionType crossReference externalCrossReference
113 customerSubset projectSubset xGraphic subjectField note
114 source
115 );
116 7 $legalIn{'LangSet'}{$_} = 1 foreach qw (transactionType crossReference
117 externalCrossReference customerSubset projectSubset
118 definition note source
119 );
120 $legalIn{'Term'}{$_} = 1
121 7 foreach qw (transactionType crossReference externalCrossReference
122 customerSubset projectSubset context grammaticalGender
123 geographicalUsage partOfSpeech termLocation termType
124 administrativeStatus note source term
125 );
126 7 $legalIn{'Party'}{$_} = 1 foreach qw (email title role org uid tel adr fn);
127 7 return %legalIn;
128 }
129  
130 # what part of the term structure does each data category go in?
131 7 ▶sub _get_position {
Subroutine _get_position: called CC=1 SCAR=0.0
132 7 my %position = map { $_ => 'termGrp' } qw (
133 administrativeStatus geographicalUsage grammaticalGender
134 partOfSpeech termLocation termType
135 );
136 %position = (
137 %position,
138 7 map { $_ => 'auxInfo' }
139 qw (
140 context customerSubset projectSubset crossReference note
141 source transactionType externalCrossReference xGraphic
142 )
143 );
144 7 return %position;
145 }
146  
147 # which TBX meta data category does each data category print as?
148 7 ▶sub _get_meta {
Subroutine _get_meta: called CC=4 SCAR=13.9
149 7 my %meta;
150 7 $meta{$_} = 'admin' foreach qw (customerSubset projectSubset);
151 7 $meta{$_} = 'descrip' foreach qw (definition subjectField context);
152 $meta{$_} = 'termNote'
153 7 foreach
154 qw (grammaticalGender geographicalUsage partOfSpeech termLocation termType administrativeStatus);
155 7 return %meta;
156 }
157  
158 7 1;
159  
160 __END__
« MRC.pm ↑ Summary