line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Acme::VOYAGEGROUP::ConferenceRoom; |
2
|
2
|
|
|
2
|
|
80153
|
use 5.008005; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
70
|
|
3
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
59
|
|
4
|
2
|
|
|
2
|
|
20
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
62
|
|
5
|
2
|
|
|
2
|
|
43
|
use Carp; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
148
|
|
6
|
2
|
|
|
2
|
|
1199
|
use utf8; |
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
11
|
|
7
|
2
|
|
|
2
|
|
1835
|
use UNIVERSAL::require; |
|
2
|
|
|
|
|
3370
|
|
|
2
|
|
|
|
|
22
|
|
8
|
2
|
|
|
2
|
|
1046
|
use parent 'Exporter'; |
|
2
|
|
|
|
|
306
|
|
|
2
|
|
|
|
|
11
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
binmode STDOUT, ":utf8"; |
11
|
|
|
|
|
|
|
binmode STDERR, ":utf8"; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = "0.01"; |
14
|
|
|
|
|
|
|
our @EXPORT = qw/ conference_room /; |
15
|
|
|
|
|
|
|
|
16
|
2
|
|
|
2
|
|
216
|
use constant FLOOR_PLAN => <<'EOS'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
2221
|
|
17
|
|
|
|
|
|
|
.---------------.---------------------. |
18
|
|
|
|
|
|
|
| | | |
19
|
|
|
|
|
|
|
| | .--.--.----.---| |
20
|
|
|
|
|
|
|
| | | | | | | |
21
|
|
|
|
|
|
|
| |---. | |--| | | |
22
|
|
|
|
|
|
|
| | | '--' '----| | |
23
|
|
|
|
|
|
|
| |---'-. .'---| |
24
|
|
|
|
|
|
|
| | | | | |
25
|
|
|
|
|
|
|
'---------------'-----'.--.--. .'----| |
26
|
|
|
|
|
|
|
| | | | |
27
|
|
|
|
|
|
|
|--.--| |--.--| |
28
|
|
|
|
|
|
|
| | | | | | |
29
|
|
|
|
|
|
|
'--'--' '--'--| |
30
|
|
|
|
|
|
|
| |
31
|
|
|
|
|
|
|
.------------| |
32
|
|
|
|
|
|
|
| | |
33
|
|
|
|
|
|
|
| | |
34
|
|
|
|
|
|
|
'------------' |
35
|
|
|
|
|
|
|
EOS |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my %PROCESS_OF = ( |
38
|
|
|
|
|
|
|
pangea => { |
39
|
|
|
|
|
|
|
lines => [1..7], |
40
|
|
|
|
|
|
|
normalization => qr/^ぱんげあ|パンゲア$/ms, |
41
|
|
|
|
|
|
|
position => qr{ ^(\|/*)\s }x, |
42
|
|
|
|
|
|
|
direction => 'head', |
43
|
|
|
|
|
|
|
}, |
44
|
|
|
|
|
|
|
megallanica => { |
45
|
|
|
|
|
|
|
lines => [3..4], |
46
|
|
|
|
|
|
|
normalization => qr/^めがらにか|メガラニカ$/ms, |
47
|
|
|
|
|
|
|
position => qr{ ^(\|\s+\|[^\|]+\|/*)\s }x, |
48
|
|
|
|
|
|
|
}, |
49
|
|
|
|
|
|
|
mu => { |
50
|
|
|
|
|
|
|
lines => [3], |
51
|
|
|
|
|
|
|
normalization => qr/^むー|ムー$/ms, |
52
|
|
|
|
|
|
|
position => qr{ \s(/*\|\s+\|\s+\|)$ }x, |
53
|
|
|
|
|
|
|
}, |
54
|
|
|
|
|
|
|
ultima => { |
55
|
|
|
|
|
|
|
lines => [5], |
56
|
|
|
|
|
|
|
normalization => qr/^うるてぃま|ウルティマ$/ms, |
57
|
|
|
|
|
|
|
position => qr{ ^(\|\s+\|/*)\s }x, |
58
|
|
|
|
|
|
|
}, |
59
|
|
|
|
|
|
|
atlantis => { |
60
|
|
|
|
|
|
|
lines => [3..4], |
61
|
|
|
|
|
|
|
normalization => qr/^あとらんてぃす|アトランティス$/ms, |
62
|
|
|
|
|
|
|
position => qr{ \s(/*\|\s+\|)$ }x, |
63
|
|
|
|
|
|
|
}, |
64
|
|
|
|
|
|
|
pacifis => { |
65
|
|
|
|
|
|
|
lines => [3..5], |
66
|
|
|
|
|
|
|
normalization => qr/^ぱしふぃす|パシフィス$/ms, |
67
|
|
|
|
|
|
|
position => qr{ \s(/*\|)$ }x, |
68
|
|
|
|
|
|
|
}, |
69
|
|
|
|
|
|
|
zipang => { |
70
|
|
|
|
|
|
|
lines => [7], |
71
|
|
|
|
|
|
|
normalization => qr/^じぱんぐ|ジパング$/ms, |
72
|
|
|
|
|
|
|
position => qr{ ^(\|\s+\|/*)\s }x, |
73
|
|
|
|
|
|
|
}, |
74
|
|
|
|
|
|
|
lemuria => { |
75
|
|
|
|
|
|
|
lines => [7], |
76
|
|
|
|
|
|
|
normalization => qr/^れむりあ|レムリア$/ms, |
77
|
|
|
|
|
|
|
position => qr{ \s(/*\|)$ }x, |
78
|
|
|
|
|
|
|
}, |
79
|
|
|
|
|
|
|
africa => { |
80
|
|
|
|
|
|
|
lines => [9], |
81
|
|
|
|
|
|
|
normalization => qr/^あふりか|アフリカ$/ms, |
82
|
|
|
|
|
|
|
position => qr{ \s(/*\|\s+\|\s+\|)$ }x, |
83
|
|
|
|
|
|
|
}, |
84
|
|
|
|
|
|
|
eurasia => { |
85
|
|
|
|
|
|
|
lines => [9], |
86
|
|
|
|
|
|
|
normalization => qr/^ゆーらしあ|ユーラシア$/ms, |
87
|
|
|
|
|
|
|
position => qr{ \s(/*\|)$ }x, |
88
|
|
|
|
|
|
|
}, |
89
|
|
|
|
|
|
|
north_america => { |
90
|
|
|
|
|
|
|
lines => [11], |
91
|
|
|
|
|
|
|
normalization => qr/^のーすあめりか|ノースアメリカ$/ms, |
92
|
|
|
|
|
|
|
position => qr{ \s(/*\|)$ }x, |
93
|
|
|
|
|
|
|
}, |
94
|
|
|
|
|
|
|
south_america => { |
95
|
|
|
|
|
|
|
lines => [11], |
96
|
|
|
|
|
|
|
normalization => qr/^さうすあめりか|サウスアメリカ$/ms, |
97
|
|
|
|
|
|
|
position => qr{ \s(/*\|\s+\|)$ }x, |
98
|
|
|
|
|
|
|
}, |
99
|
|
|
|
|
|
|
australlia => { |
100
|
|
|
|
|
|
|
lines => [11], |
101
|
|
|
|
|
|
|
normalization => qr/^おーすとらりあ|オーストラリア$/ms, |
102
|
|
|
|
|
|
|
position => qr{ \s(/*\|\s+\|\s+\|\s+\|)$ }x, |
103
|
|
|
|
|
|
|
}, |
104
|
|
|
|
|
|
|
antarctica => { |
105
|
|
|
|
|
|
|
lines => [11], |
106
|
|
|
|
|
|
|
normalization => qr/^あんたーくてぃか|アンタークティカ$/ms, |
107
|
|
|
|
|
|
|
position => qr{ \s(/*\|\s+\|\s+\|\s+\|\s+\|)$ }x, |
108
|
|
|
|
|
|
|
}, |
109
|
|
|
|
|
|
|
ajito => { |
110
|
|
|
|
|
|
|
lines => [15..16], |
111
|
|
|
|
|
|
|
normalization => qr/^あじと|アジト$/ms, |
112
|
|
|
|
|
|
|
position => qr{ \s(/*\|)$ }x, |
113
|
|
|
|
|
|
|
}, |
114
|
|
|
|
|
|
|
); |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
my %OUTPUT_OF = ( |
117
|
|
|
|
|
|
|
color => 'Acme::VOYAGEGROUP::ConferenceRoom::Output::Color', |
118
|
|
|
|
|
|
|
json => 'Acme::VOYAGEGROUP::ConferenceRoom::Output::JSON', |
119
|
|
|
|
|
|
|
xml => 'Acme::VOYAGEGROUP::ConferenceRoom::Output::XML', |
120
|
|
|
|
|
|
|
message_pack => 'Acme::VOYAGEGROUP::ConferenceRoom::Output::MessagePack', |
121
|
|
|
|
|
|
|
); |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub conference_room { |
124
|
15
|
50
|
|
15
|
0
|
24434
|
my $room_name = shift or croak "Conference Room Not Found"; |
125
|
15
|
|
50
|
|
|
37
|
my $output_type = shift || 'color'; |
126
|
|
|
|
|
|
|
|
127
|
15
|
|
|
|
|
33
|
$room_name = _normalize($room_name); |
128
|
15
|
|
|
|
|
32
|
my $process = $PROCESS_OF{$room_name}; |
129
|
15
|
50
|
|
|
|
32
|
croak "Conference Room Not Found: $room_name" unless $process; |
130
|
|
|
|
|
|
|
|
131
|
15
|
50
|
|
|
|
317
|
croak "Mistake Position: $process->{position}" if $process->{position} !~ m/\s(\^?).+?(\$?)\s/xms; |
132
|
15
|
|
|
|
|
231
|
my @lines = split "\n", FLOOR_PLAN; |
133
|
15
|
100
|
|
|
|
66
|
my($head, $tail) = ($1) ? ('', '/') : ('/', ''); |
134
|
15
|
|
|
|
|
16
|
for my $i (@{ $process->{lines} }) { |
|
15
|
|
|
|
|
41
|
|
135
|
26
|
|
|
|
|
1969
|
1 while $lines[$i] =~ s{$process->{position}}{$head$1$tail}; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
15
|
50
|
|
|
|
43
|
if ($output_type ne 'none') { |
139
|
0
|
|
|
|
|
0
|
my $module = $OUTPUT_OF{$output_type}; |
140
|
0
|
0
|
|
|
|
0
|
croak "No Type: $output_type" unless $module; |
141
|
|
|
|
|
|
|
|
142
|
0
|
0
|
|
|
|
0
|
return $module->convert(\@lines) if $module->use; |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
15
|
|
|
|
|
152
|
join "\n", @lines; |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
sub _normalize { |
149
|
15
|
|
|
15
|
|
19
|
my $room_name = shift; |
150
|
|
|
|
|
|
|
|
151
|
15
|
|
|
|
|
67
|
for my $normalized_room_name (keys %PROCESS_OF) { |
152
|
225
|
50
|
|
|
|
1221
|
return $normalized_room_name |
153
|
|
|
|
|
|
|
if $room_name =~ $PROCESS_OF{$normalized_room_name}->{normalization}; |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
15
|
|
|
|
|
61
|
lc($room_name); |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
1; |
160
|
|
|
|
|
|
|
__END__ |