blib/lib/Acme/MetaSyntactic/soviet.pm

filter: Statementstmt 100% 33 / 33 Branchbran 91.6% 11 / 12 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 98.1% 54 / 55 SCAR 20.8
CC
8
Cov
98%
_load_data_from_pod
6.0
_flush_category
3.0
BEGIN
1.0
CRAP 8.0
« Build ↑ Summary
1 # -*- encoding: utf-8; indent-tabs-mode: nil -*-
2 #
3 # Acme::MetaSyntactic::soviet -- NATO codenames for Soviet-designed equipment
4 # Copyright (C) 2008, 2012, 2016 Jean Forget
5 #
6 # See the license in the embedded documentation below.
7 #
8 package Acme::MetaSyntactic::soviet;
9  
10 14 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 14 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 14 ▶use Acme::MetaSyntactic::MultiList;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 14 our @ISA = qw( Acme::MetaSyntactic::MultiList );
15 14 our $VERSION = '0.04';
16  
17 14 my $data = { default => 'electronic' };
18 14 my ($category2, $category3);
19 14 my %seen;
20  
21 14 _load_data_from_pod();
22  
23 14 __PACKAGE__->init($data);
24  
25 sub _load_data_from_pod {
26  
27 14 ▶ while (<DATA>) {
Subroutine _load_data_from_pod: called CC=6 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline DATA)) 22190 0 22190
28 22190 ▶ if (/^=head2\s+(.*)/) {
Branch: 4 branches
BranchTrueFalseTotal
if (/^=head2\s+(.*)/) { } 28 22162 22190
elsif (/^=head3\s+(.*)/) { } 98 22064 22162
elsif (/=item\s+(.*?)\s*$/) { } 5278 16786 22064
elsif (/^=head1/) { } 14 16772 16786
29 28 _flush_category();
30 28 $category2 = lc($1);
31 28 $category3 = '';
32 }
33 elsif (/^=head3\s+(.*)/) {
34 98 _flush_category();
35 98 $category3 = lc($1);
36 }
37 elsif (/=item\s+(.*?)\s*$/) {
38 5278 my $name = $1;
39 5278 $name =~ s/\s+/_/g;
40 5278 $name =~ s/_+/_/g;
41 5278 $seen{$name} = 1;
42 }
43 elsif (/^=head1/) {
44 14 last;
45 }
46 }
47 14 _flush_category();
48 }
49  
50 sub _flush_category {
51 140 ▶ if ($category2 and %seen) {
Subroutine _flush_category: called CC=3 SCAR=11.0
Branch: 1 branch
BranchTrueFalseTotal
if ($category2 and %seen) 98 42 140
Condition100%3/3
$category2 and %seen
!ll&&!rl&&r
142898
MC/DC100%2/2
$category2 and %seen
$category2 %seen
Truth table100%3/3
A and B
A= $category2B= %seen
ABresult
0X0
100
111
52 98 $data->{names}{$category2}{$category3} = join ' ', sort keys %seen;
53 }
54 140 %seen = ();
55 }
56  
57 14 38;
58 # Why 38? Hint: s/r$/t/
59  
60 =encoding utf8
61  
62 =head1 NAME
63  
64 Acme::MetaSyntactic::soviet -- NATO codenames for Soviet-designed equipment
65  
66 =head1 DESCRIPTION
67  
68 Some codenames given by NATO to Soviet-designed aircraft, missiles,
69 submarines, radars and other electronic systems. The various
70 categories and sub-categories are
71  
72 =over 4
73  
74 =item *
75  
76 electronic
77  
78 =item *
79  
80 electronic/radars
81  
82 =item *
83  
84 electronic/misc
85  
86 =item *
87  
88 vehicles
89  
90 =item *
91  
92 vehicles/aircraft
93  
94 =item *
95  
96 vehicles/helicopters
97  
98 =item *
99  
100 vehicles/missiles
101  
102 =item *
103  
104 vehicles/submarines
105  
106 =item *
107  
108 vehicles/error
109  
110 =back
111  
112 The default category is 'electronic'.
113  
114 =head1 VERSION
115  
116 This is version 0.04, the "Guideline" version, released on the 56th
117 anniversary of the downing of Gary Power's U-2 by a SA-2 Guideline.
118  
119 =head1 SYNOPSIS
120  
121 use Acme::MetaSyntactic;
122  
123 my $meta = Acme::MetaSyntactic->new( 'soviet' );
124
125 print $meta->name(); # return a single name
126 my @names = $meta->name( 4 ); # return 4 distinct names (if possible)
127  
128 If you want some category other than 'electronic', the second line should
129 read:
130  
131 my $meta = Acme::MetaSyntactic->new( 'soviet', category => 'vehicle/aircraft' );
132  
133 If C<meta> from L<Acme::MetaSyntactic> is installed, you can use it
134 from the command line:
135  
136 meta soviet
137  
138 meta soviet/vehicles/submarines
139  
140 =head1 CONTRIBUTOR
141  
142 Jean Forget
143  
144 =head1 SOURCES
145  
146 Note: I have used only sources published I<before> the fall of the
147 Soviet Union. Therefore, the module name is C<A::MS::soviet>, with no
148 "ex-" prefix. For each entry, the sources are listed, with page
149 numbers for the books. The games use data cards, which are unnumbered.
150  
151 Some sources, especially early sources, may contain some errors. Some
152 equipment may appear with faulty intelligence reports which give a
153 wrong code or description. And a later intelligence report would
154 correct it. The best example is the Backfire, first given the code
155 "Tu-26" and then the code "Tu-22M".
156  
157 =head2 Main Sources
158  
159 These sources contain extensive lists or extensive tables of soviet
160 equipment.
161  
162 =over 4
163  
164 =item *
165  
166 I<Pat-Led-1>
167 written by J-J Patry and P. Lederer
168 published by Editions Presse & Recherche
169 abbreviated as I<PL>.
170  
171 =item *
172  
173 I<Jane's World Aircraft Recognition Handbook>
174 written by Derek Wood
175 published by Janes in 1987
176 (ISBN 0-7106-0343-6)
177 abbreviated as I<JWARH>.
178  
179 =item *
180  
181 I<Air Superiority>
182 designed by J.D. Webster
183 and published by GDW in 1987
184 (ISBN 0-943580-19-6)
185 abbreviated as I<ASu>.
186  
187 =item *
188  
189 I<Air Strike>
190 designed by J.D. Webster
191 and published by GDW in 1987
192 (ISBN 0-943580-30-7)
193 abbreviated as I<ASt>.
194  
195 =item *
196  
197 I<Desert Falcons>
198 designed by J.D. Webster
199 and published by GDW in 1988
200 (ISBN 0-943580-97-8)
201 abbreviated as I<DF>.
202  
203 =item *
204  
205 I<Les Flottes de Combat 1968>
206 written by H. Le Masson
207 published by Editions Maritimes et Outre-Mer
208 (no ISBN)
209 abbreviated as I<LFDC>.
210  
211 =item *
212  
213 I<Flottes de Combat 1990>
214 written by B. Prézelin
215 published by Editions Maritimes et Outre-Mer
216 (ISBN 2.7373.0485.7)
217 abbreviated as I<FDC>.
218  
219 Note: these last two books are actually the same book, updated and
220 published every other year. You can notice that the title has been
221 shortened between the 1968 issue and the 1990 issue (FDC vs. LFDC).
222  
223 =item *
224  
225 I<Air Wars and Aircraft>
226 written by Victor Flintham
227 published by Arms and Armour in 1989
228 (ISBN 0-85368-779-X)
229 abreviated as I<AWA>.
230  
231 =item *
232  
233 I<Air War>
234 designed by David Isby
235 published in 1977 by SPI and then in 1983 by TSR
236 (no ISBN)
237 abreviated as I<SPIAW>.
238  
239 =back
240  
241 =head2 Minor Sources
242  
243 These sources mention some NATO codes for soviet equipment, but
244 without trying to give an exhaustive list of some category or other.
245  
246 =over 4
247  
248 =item *
249  
250 I<Rolling Thunder>
251 designed by Steve Weiss
252 published by Group Three Games in 1985
253 (no ISBN)
254 abreviated as I<RT>.
255  
256 =item *
257  
258 I<Fox Two>
259 by Randy Cunningham with Jeff Ethell
260 published by Warner Books in 1984
261 ISBN 0-446-35458-9
262 abreviated as I<F2>.
263  
264 =item *
265  
266 I<The Hunt for Red October>
267 by Tom Clancy,
268 first published by Naval Institute Press in 1984
269 published by Fontana in 1987
270 ISBN 0-00-617276-8
271 abreviated at I<THFRO>.
272  
273 =back
274  
275 =head1 SOVIET EQUIPMENT
276  
277 =cut
278  
279 __DATA__
« Build ↑ Summary