line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Hubot::Scripts::macboogi; |
2
|
|
|
|
|
|
|
$Hubot::Scripts::macboogi::VERSION = '0.1.9'; |
3
|
1
|
|
|
1
|
|
1215
|
use utf8; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
4
|
1
|
|
|
1
|
|
25
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
29
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
24
|
|
|
1
|
|
|
|
|
43
|
|
6
|
1
|
|
|
1
|
|
5
|
use Encode qw/decode_utf8 encode_utf8/; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
71
|
|
7
|
1
|
|
|
1
|
|
4648
|
use Lingua::KO::Hangul::Util qw(:all); |
|
1
|
|
|
|
|
19243
|
|
|
1
|
|
|
|
|
869
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my $JONGSUNG_BEGIN = 0x11A8; |
10
|
|
|
|
|
|
|
my $JONGSUNG_END = 0x11FF; |
11
|
|
|
|
|
|
|
my $JONGSUNG_DIGEUG = 0x11AE; # ã· |
12
|
|
|
|
|
|
|
my $JONGSUNG_BIEUP = 0x11B8; # ã
|
13
|
|
|
|
|
|
|
my $JONGSUNG_JIEUT = 0x11BD; # ã
|
14
|
|
|
|
|
|
|
my $SELLABLE_BEGIN = 0x3131; |
15
|
|
|
|
|
|
|
my $INTERVAL = $SELLABLE_BEGIN - $JONGSUNG_BEGIN; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub load { |
18
|
0
|
|
|
0
|
0
|
|
my ( $class, $robot ) = @_; |
19
|
|
|
|
|
|
|
$robot->hear( |
20
|
|
|
|
|
|
|
qr/^(.*)\.mac$/i, |
21
|
|
|
|
|
|
|
sub { |
22
|
0
|
|
|
0
|
|
|
my $msg = shift; |
23
|
0
|
|
|
|
|
|
macboogify( $msg, $msg->match->[0] ); |
24
|
|
|
|
|
|
|
} |
25
|
0
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub macboogify { |
29
|
0
|
|
|
0
|
0
|
|
my ( $res, $msg ) = @_; |
30
|
0
|
|
|
|
|
|
my @chars = split //, $msg; |
31
|
0
|
|
|
|
|
|
my @mac_chars; |
32
|
0
|
|
|
|
|
|
for my $char (@chars) { |
33
|
0
|
|
|
|
|
|
my $ord = ord $char; |
34
|
0
|
0
|
0
|
|
|
|
if ( $ord >= 97 && $ord <= 122 ) { # a..z |
|
|
0
|
0
|
|
|
|
|
35
|
0
|
|
|
|
|
|
push @mac_chars, uc $char; |
36
|
0
|
|
|
|
|
|
next; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
elsif ( $ord >= 65 && $ord <= 90 ) { # A..Z |
39
|
0
|
|
|
|
|
|
push @mac_chars, $char; |
40
|
0
|
|
|
|
|
|
next; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
my @jamo = split //, decomposeSyllable($char); |
44
|
0
|
|
|
|
|
|
for (@jamo) { |
45
|
0
|
|
|
|
|
|
my $code = unpack 'U*', $_; |
46
|
0
|
0
|
0
|
|
|
|
if ( $code >= $JONGSUNG_BEGIN && $code <= $JONGSUNG_DIGEUG ) { |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
47
|
0
|
|
|
|
|
|
$code += $INTERVAL; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
elsif ( $code > $JONGSUNG_DIGEUG && $code <= $JONGSUNG_BIEUP ) { |
50
|
0
|
|
|
|
|
|
$code += $INTERVAL + 1; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
elsif ( $code > $JONGSUNG_BIEUP && $code <= $JONGSUNG_JIEUT ) { |
53
|
0
|
|
|
|
|
|
$code += $INTERVAL + 2; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
elsif ( $code > $JONGSUNG_JIEUT && $code <= $JONGSUNG_END ) { |
56
|
0
|
|
|
|
|
|
$code += $INTERVAL + 3; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
$_ = pack 'U*', $code; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
push @mac_chars, composeSyllable( join '', @jamo ); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
my $macboogify = join '', @mac_chars; |
66
|
0
|
|
|
|
|
|
$res->send($macboogify); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 NAME |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Hubot::Scripts::macboogi |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 VERSION |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
version 0.1.9 |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 SYNOPSIS |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
<text>.mac - print macboogified <text> |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 AUTHOR |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Hyungsuk Hong <hshong@perl.kr> |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut |