/
tranzlate.rb
116 lines (108 loc) · 3.89 KB
/
tranzlate.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# -*- encoding : utf-8 -*-
# Adapted and expanded from https://github.com/rwtnorton/moar-lolspeak
# which was largely taken from an old Perl script and is sadly is not
# available via rubygems
module Lolspeak
LOL_DICTIONARY = {
/what/ => %w(wut whut),
/you\b/ => %w(yu yous yoo u yooz),
/cture/ => %w(kshur),
/ss\b/ => %w(s zz z),
/the\b/ => %w(teh),
/more/ => %w(moar),
/my/ => %w(mah mai),
/are/ => %w(is ar),
/eese/ => %w(eez),
/ph/ => %w(f),
/as\b/ => %w(az),
/seriously/ => %w(srsly),
/sion/ => %w(shun),
/just/ => %w(jus),
/ose\b/ => %w(oze),
/eady/ => %w(eddy),
/ome?\b/ => %w(um),
/of\b/ => %w(of ov of),
/uestion/ => %w(wesjun),
/want/ => %w(wants),
/ead\b/ => %w(edd),
/ck/ => %w(kk kkk),
/sion/ => %w(shun),
/cat|kitten|kitty/ => %w(kitteh kittehz cat fuzzeh fuzzyrumpus foozles fuzzbut fluffernutter beast mew),
/eak/ => %w(ekk),
/age/ => %w(uj),
/like/ => %w(likez liek licks),
/love/ => %w(lovez lub lubs luv lurve lurves),
/\bis\b/ => ['ar teh', 'ar'],
/nd\b/ => %w(n n'),
/who/ => %w(hoo),
/'/ => [''],
/ese\b/ => %w(eez),
/outh/ => %w(owf),
/scio/ => %w(shu),
/esque/ => %w(esk),
/ture/ => %w(chur),
/\btoo?\b/ => %w(to t 2 to t),
/tious/ => %w(shus),
/sure\b/ => %w(shur),
/tty\b/ => %w(tteh),
/were/ => %w(was),
/ok\b|okay/ => %w(kthxbye!),
/\ba\b/ => %w(uh),
/ym/ => %w(im),
/fish/ => %w(ghoti),
/thy\b/ => %w(fee),
/\wly\w/ => %w(li),
/que\w/ => %w(kwe),
/\both/ => %w(udd),
/though\b/ => %w(tho),
/(t|r|en)ough/ => %w(\1uff),
/ought/ => %w(awt),
/ease/ => %w(eez),
/ing\b/ => %w(in ins ng ing in'),
/have/ => ['haz', 'hav', 'haz a'],
/has/ => %w(haz gots),
/your/ => %w(yur ur yore yoar),
/ove\b/ => %w(oov ove uuv uv oove),
/for/ => %w(for 4 fr fur for foar),
/thank/ => %w(fank tank thx thnx),
/good/ => %w(gud goed guud gude gewd goot gut),
/really/ => %w(rly rily rilly rilleh),
/world/ => %w(wurrld whirld wurld wrld),
/i'?m\b/ => ['im', 'i yam', 'i iz'],
/(?!e)ight/ => %w(ite),
/(?!ues)tion/ => %w(shun),
/you'?re/ => %w(yore yr),
/er\b|are|ere/ => %w(r),
/y\b|ey\b/ => %w(eh),
/ea/ => %w(ee),
/can\si\s(?:ple(?:a|e)(?:s|z)e?)?\s?have\sa/ => ['i can haz'],
/(?:hello|\bhi\b|\bhey\b|howdy|\byo\b),?/ => ['oh hai,'],
/(?:god\b|allah|buddah?|diety|lord)/ => ['ceiling cat']
}
def tranzlate(str)
lolstr = str.dup
LOL_DICTIONARY.each do |english, lolspeak|
# ghetto ruby1.8/1.9 agnostic version of choice vs sample
lolstr.gsub!(english, lolspeak.sample)
end
lolstr << '! kthxbye!' if rand(10) == 2
lolstr.gsub!(/(\?|!|,|\.)+/, '!')
lolstr.upcase
end
end
module Lolcommits
class Tranzlate < Plugin
extend Lolspeak
def run_precapture
debug "Commit message before: #{runner.message}"
runner.message = self.class.tranzlate(runner.message)
debug "Commit message after: #{runner.message}"
end
def self.name
'tranzlate'
end
def self.runner_order
:precapture
end
end
end