lita-conferenz 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/lita/handlers/conferenz/chat.rb +3 -3
- data/lita-conferenz.gemspec +1 -1
- data/locales/en.yml +1 -1
- data/spec/lita/handlers/conferenz/chat_spec.rb +6 -6
- metadata +1 -3
- data/spec/lita/handlers/karma/chat_spec.rb +0 -339
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8bc840a09d0293f6970b379a6c2f6d008ea47fd4
|
4
|
+
data.tar.gz: 628b0f02d9a73f7a0c97bc3ecf173049090859bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b19d26b73be4cc5747e69df2cc7188aa8b79af4dde33a0b86733daa9230a15cb2d076ba8d3d5b7e21a9bf603dcad2b6250165f53630655a9e66b73cbb46f86a
|
7
|
+
data.tar.gz: 759de86aaaf8b84429bc836bf935d1f575aedd911930e3313686eace8d41087703323067d8b98dd563b5fd3cf1eafef9b85563442486631e1dcc95a9d62d5575
|
@@ -127,21 +127,21 @@ module Lita::Handlers::Conferenz
|
|
127
127
|
|
128
128
|
def define_static_routes
|
129
129
|
self.class.route(
|
130
|
-
%r{^conferenz\s+
|
130
|
+
%r{^conferenz\s+niche},
|
131
131
|
:list_worst,
|
132
132
|
command: true,
|
133
133
|
help: { t("help.list_worst_key") => t("help.list_worst_value") }
|
134
134
|
)
|
135
135
|
|
136
136
|
self.class.route(
|
137
|
-
%r{^conferenz\s+
|
137
|
+
%r{^conferenz\s+popular},
|
138
138
|
:list_best,
|
139
139
|
command: true,
|
140
140
|
help: { t("help.list_best_key") => t("help.list_best_value") }
|
141
141
|
)
|
142
142
|
|
143
143
|
self.class.route(
|
144
|
-
%r{^conferenz\s+
|
144
|
+
%r{^conferenz\s+attendees\s+.+},
|
145
145
|
:modified,
|
146
146
|
command: true,
|
147
147
|
help: { t("help.modified_key") => t("help.modified_value") }
|
data/lita-conferenz.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "lita-conferenz"
|
3
|
-
spec.version = "1.0.
|
3
|
+
spec.version = "1.0.3"
|
4
4
|
spec.authors = ["Piotr Limanowski"]
|
5
5
|
spec.email = ["plimanowski+conferenz@gmail.com"]
|
6
6
|
spec.description = %q{A Lita handler for tracking conferences attendance.}
|
data/locales/en.yml
CHANGED
@@ -21,7 +21,7 @@ en:
|
|
21
21
|
unlink_key: TERM1 -= TERM2
|
22
22
|
unlink_value: Unlinks TERM2 from TERM1.
|
23
23
|
list_worst_key: "conferenz worst [N]"
|
24
|
-
list_worst_value: Lists the bottom N
|
24
|
+
list_worst_value: Lists the bottom N conferences by conferenz. N defaults to 5.
|
25
25
|
list_best_key: "conferenz best [N]"
|
26
26
|
list_best_value: Lists the top N terms by conferenz. N defaults to 5.
|
27
27
|
modified_key: conferenz modified TERM
|
@@ -18,9 +18,9 @@ describe Lita::Handlers::Conferenz::Chat, lita_handler: true do
|
|
18
18
|
it { is_expected.to route("foo++ bar").to(:increment) }
|
19
19
|
it { is_expected.to route("foo-- bar").to(:decrement) }
|
20
20
|
it { is_expected.to route("foo~~").to(:check) }
|
21
|
-
it { is_expected.to route_command("conferenz
|
22
|
-
it { is_expected.to route_command("conferenz
|
23
|
-
it { is_expected.to route_command("conferenz
|
21
|
+
it { is_expected.to route_command("conferenz popular").to(:list_best) }
|
22
|
+
it { is_expected.to route_command("conferenz niche").to(:list_worst) }
|
23
|
+
it { is_expected.to route_command("conferenz attendees foo").to(:modified) }
|
24
24
|
it do
|
25
25
|
is_expected.to route_command("conferenz delete").with_authorization_for(:karma_admins).to(:delete)
|
26
26
|
end
|
@@ -140,8 +140,8 @@ describe Lita::Handlers::Conferenz::Chat, lita_handler: true do
|
|
140
140
|
MSG
|
141
141
|
end
|
142
142
|
|
143
|
-
it 'lists the bottom 5 terms when passed "
|
144
|
-
send_command("conferenz
|
143
|
+
it 'lists the bottom 5 terms when passed "niche"' do
|
144
|
+
send_command("conferenz niche")
|
145
145
|
expect(replies.last).to eq <<-MSG.chomp
|
146
146
|
1. five (-1)
|
147
147
|
2. four (0)
|
@@ -152,7 +152,7 @@ MSG
|
|
152
152
|
end
|
153
153
|
|
154
154
|
it "limits the list to the count passed as the second argument" do
|
155
|
-
send_command("conferenz
|
155
|
+
send_command("conferenz popular 2")
|
156
156
|
expect(replies.last).to eq <<-MSG.chomp
|
157
157
|
1. one (3)
|
158
158
|
2. two (2)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-conferenz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Limanowski
|
@@ -111,7 +111,6 @@ files:
|
|
111
111
|
- lita-conferenz.gemspec
|
112
112
|
- locales/en.yml
|
113
113
|
- spec/lita/handlers/conferenz/chat_spec.rb
|
114
|
-
- spec/lita/handlers/karma/chat_spec.rb
|
115
114
|
- spec/spec_helper.rb
|
116
115
|
homepage: https://github.com/peel/conferenz
|
117
116
|
licenses:
|
@@ -140,5 +139,4 @@ specification_version: 4
|
|
140
139
|
summary: A Lita handler for tracking conferences attendance.
|
141
140
|
test_files:
|
142
141
|
- spec/lita/handlers/conferenz/chat_spec.rb
|
143
|
-
- spec/lita/handlers/karma/chat_spec.rb
|
144
142
|
- spec/spec_helper.rb
|
@@ -1,339 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
require "spec_helper"
|
3
|
-
|
4
|
-
describe Lita::Handlers::Conferenz::Chat, lita_handler: true do
|
5
|
-
let(:payload) { double("payload") }
|
6
|
-
|
7
|
-
prepend_before { registry.register_handler(Lita::Handlers::Conferenz::Config) }
|
8
|
-
|
9
|
-
before do
|
10
|
-
registry.config.handlers.conferenz.cooldown = nil
|
11
|
-
registry.config.handlers.conferenz.link_karma_threshold = nil
|
12
|
-
described_class.routes.clear
|
13
|
-
subject.define_routes(payload)
|
14
|
-
end
|
15
|
-
|
16
|
-
it { is_expected.to route("foo++").to(:increment) }
|
17
|
-
it { is_expected.to route("foo--").to(:decrement) }
|
18
|
-
it { is_expected.to route("foo++ bar").to(:increment) }
|
19
|
-
it { is_expected.to route("foo-- bar").to(:decrement) }
|
20
|
-
it { is_expected.to route("foo~~").to(:check) }
|
21
|
-
it { is_expected.to route_command("conferenz best").to(:list_best) }
|
22
|
-
it { is_expected.to route_command("conferenz worst").to(:list_worst) }
|
23
|
-
it { is_expected.to route_command("conferenz modified foo").to(:modified) }
|
24
|
-
it do
|
25
|
-
is_expected.to route_command("conferenz delete").with_authorization_for(:karma_admins).to(:delete)
|
26
|
-
end
|
27
|
-
it { is_expected.to route_command("conferenz").to(:list_best) }
|
28
|
-
it { is_expected.to route_command("foo += bar").to(:link) }
|
29
|
-
it { is_expected.to route_command("foo += bar++").to(:link) }
|
30
|
-
it { is_expected.to route_command("foo += bar--").to(:link) }
|
31
|
-
it { is_expected.to route_command("foo += bar~~").to(:link) }
|
32
|
-
it { is_expected.to route_command("foo -= bar").to(:unlink) }
|
33
|
-
it { is_expected.to route_command("foo -= bar++").to(:unlink) }
|
34
|
-
it { is_expected.to route_command("foo -= bar--").to(:unlink) }
|
35
|
-
it { is_expected.to route_command("foo -= bar~~").to(:unlink) }
|
36
|
-
it { is_expected.not_to route("+++++").to(:increment) }
|
37
|
-
it { is_expected.not_to route("-----").to(:decrement) }
|
38
|
-
it { is_expected.not_to route("foo++bar").to(:increment) }
|
39
|
-
it { is_expected.not_to route("foo--bar").to(:decrement) }
|
40
|
-
|
41
|
-
describe "#increment" do
|
42
|
-
it "increases the term's score by one and says the new score" do
|
43
|
-
send_message("foo++")
|
44
|
-
expect(replies.last).to eq("foo: 1")
|
45
|
-
end
|
46
|
-
|
47
|
-
it "matches multiple terms in one message" do
|
48
|
-
send_message("foo++ bar++")
|
49
|
-
expect(replies.last).to eq("foo: 1; bar: 1")
|
50
|
-
end
|
51
|
-
|
52
|
-
it "doesn't start from zero if the term already has a positive score" do
|
53
|
-
send_message("foo++")
|
54
|
-
send_message("foo++")
|
55
|
-
expect(replies.last).to eq("foo: 2")
|
56
|
-
end
|
57
|
-
|
58
|
-
it "replies with a warning if term increment is on cooldown" do
|
59
|
-
registry.config.handlers.karma.cooldown = 10
|
60
|
-
send_message("foo++")
|
61
|
-
send_message("foo++")
|
62
|
-
expect(replies.last).to match(/cannot modify foo/)
|
63
|
-
end
|
64
|
-
|
65
|
-
it "is case insensitive" do
|
66
|
-
send_message("foo++")
|
67
|
-
send_message("FOO++")
|
68
|
-
expect(replies.last).to eq("foo: 2")
|
69
|
-
end
|
70
|
-
|
71
|
-
it "handles Unicode word characters" do
|
72
|
-
send_message("föö++")
|
73
|
-
expect(replies.last).to eq("föö: 1")
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
describe "#decrement" do
|
78
|
-
it "decreases the term's score by one and says the new score" do
|
79
|
-
send_message("foo--")
|
80
|
-
expect(replies.last).to eq("foo: -1")
|
81
|
-
end
|
82
|
-
|
83
|
-
it "matches multiple terms in one message" do
|
84
|
-
send_message("foo-- bar--")
|
85
|
-
expect(replies.last).to eq("foo: -1; bar: -1")
|
86
|
-
end
|
87
|
-
|
88
|
-
it "doesn't start from zero if the term already has a positive score" do
|
89
|
-
send_message("foo++")
|
90
|
-
send_message("foo--")
|
91
|
-
expect(replies.last).to eq("foo: 0")
|
92
|
-
end
|
93
|
-
|
94
|
-
it "replies with a warning if term increment is on cooldown" do
|
95
|
-
registry.config.handlers.karma.cooldown = 10
|
96
|
-
send_message("foo--")
|
97
|
-
send_message("foo--")
|
98
|
-
expect(replies.last).to match(/cannot modify foo/)
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
describe "#check" do
|
103
|
-
it "says the term's current score" do
|
104
|
-
send_message("foo~~")
|
105
|
-
expect(replies.last).to eq("foo: 0")
|
106
|
-
end
|
107
|
-
|
108
|
-
it "matches multiple terms in one message" do
|
109
|
-
send_message("foo~~ bar~~")
|
110
|
-
expect(replies.last).to eq("foo: 0; bar: 0")
|
111
|
-
end
|
112
|
-
|
113
|
-
it "doesn't match the same term multiple times in one message" do
|
114
|
-
send_message("foo~~ foo~~")
|
115
|
-
expect(replies.size).to eq(1)
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
describe "#list" do
|
120
|
-
it "replies with a warning if there are no terms" do
|
121
|
-
send_command("conferenz")
|
122
|
-
expect(replies.last).to match(/no terms being tracked/)
|
123
|
-
end
|
124
|
-
|
125
|
-
context "with modified terms" do
|
126
|
-
before do
|
127
|
-
send_message(
|
128
|
-
"one++ one++ one++ two++ two++ three++ four++ four-- five--"
|
129
|
-
)
|
130
|
-
end
|
131
|
-
|
132
|
-
it "lists the top 5 terms by default" do
|
133
|
-
send_command("conferenz")
|
134
|
-
expect(replies.last).to eq <<-MSG.chomp
|
135
|
-
1. one (3)
|
136
|
-
2. two (2)
|
137
|
-
3. three (1)
|
138
|
-
4. four (0)
|
139
|
-
5. five (-1)
|
140
|
-
MSG
|
141
|
-
end
|
142
|
-
|
143
|
-
it 'lists the bottom 5 terms when passed "worst"' do
|
144
|
-
send_command("conferenz worst")
|
145
|
-
expect(replies.last).to eq <<-MSG.chomp
|
146
|
-
1. five (-1)
|
147
|
-
2. four (0)
|
148
|
-
3. three (1)
|
149
|
-
4. two (2)
|
150
|
-
5. one (3)
|
151
|
-
MSG
|
152
|
-
end
|
153
|
-
|
154
|
-
it "limits the list to the count passed as the second argument" do
|
155
|
-
send_command("conferenz best 2")
|
156
|
-
expect(replies.last).to eq <<-MSG.chomp
|
157
|
-
1. one (3)
|
158
|
-
2. two (2)
|
159
|
-
MSG
|
160
|
-
end
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
describe "#link" do
|
165
|
-
it "says that it's linked term 2 to term 1" do
|
166
|
-
send_command("foo += bar")
|
167
|
-
expect(replies.last).to eq("bar has been linked to foo.")
|
168
|
-
end
|
169
|
-
|
170
|
-
it "says that term 2 was already linked to term 1 if it was" do
|
171
|
-
send_command("foo += bar")
|
172
|
-
send_command("foo += bar")
|
173
|
-
expect(replies.last).to eq("bar is already linked to foo.")
|
174
|
-
end
|
175
|
-
|
176
|
-
it "causes term 1's score to be modified by term 2's" do
|
177
|
-
send_message("foo++ bar++ baz++")
|
178
|
-
send_command("foo += bar")
|
179
|
-
send_command("foo += baz")
|
180
|
-
send_message("foo~~")
|
181
|
-
expect(replies.last).to match(
|
182
|
-
/foo: 3 \(1\), linked to: ba[rz]: 1, ba[rz]: 1/
|
183
|
-
)
|
184
|
-
end
|
185
|
-
|
186
|
-
context "when link_karma_threshold is set" do
|
187
|
-
before do
|
188
|
-
registry.config.handlers.karma.link_karma_threshold = 1
|
189
|
-
end
|
190
|
-
|
191
|
-
it "doesn't allow a term to be linked if both are below the threshold" do
|
192
|
-
send_command("foo += bar")
|
193
|
-
expect(replies.last).to include("must have less than")
|
194
|
-
end
|
195
|
-
|
196
|
-
it "doesn't allow a term to be linked if it's below the threshold" do
|
197
|
-
send_command("foo++")
|
198
|
-
send_command("foo += bar")
|
199
|
-
expect(replies.last).to include("must have less than")
|
200
|
-
end
|
201
|
-
|
202
|
-
it "doesn't allow a term to be linked to another term below the threshold" do
|
203
|
-
send_command("bar++")
|
204
|
-
send_command("foo += bar")
|
205
|
-
expect(replies.last).to include("must have less than")
|
206
|
-
end
|
207
|
-
|
208
|
-
it "allows links if both terms meet the threshold" do
|
209
|
-
send_command("foo++ bar++")
|
210
|
-
send_command("foo += bar")
|
211
|
-
expect(replies.last).to include("has been linked")
|
212
|
-
send_command("bar += foo")
|
213
|
-
expect(replies.last).to include("has been linked")
|
214
|
-
end
|
215
|
-
|
216
|
-
it "uses the absolute value for terms with negative karma" do
|
217
|
-
send_command("foo-- bar--")
|
218
|
-
send_command("foo += bar")
|
219
|
-
expect(replies.last).to include("has been linked")
|
220
|
-
send_command("bar += foo")
|
221
|
-
expect(replies.last).to include("has been linked")
|
222
|
-
end
|
223
|
-
end
|
224
|
-
end
|
225
|
-
|
226
|
-
describe "#unlink" do
|
227
|
-
it "says that it's unlinked term 2 from term 1" do
|
228
|
-
send_command("foo += bar")
|
229
|
-
send_command("foo -= bar")
|
230
|
-
expect(replies.last).to eq("bar has been unlinked from foo.")
|
231
|
-
end
|
232
|
-
|
233
|
-
it "says that term 2 was not linked to term 1 if it wasn't" do
|
234
|
-
send_command("foo -= bar")
|
235
|
-
expect(replies.last).to eq("bar is not linked to foo.")
|
236
|
-
end
|
237
|
-
|
238
|
-
it "causes term 1's score to stop being modified by term 2's" do
|
239
|
-
send_message("foo++ bar++")
|
240
|
-
send_command("foo += bar")
|
241
|
-
send_command("foo -= bar")
|
242
|
-
send_message("foo~~")
|
243
|
-
expect(replies.last).to eq("foo: 1")
|
244
|
-
end
|
245
|
-
end
|
246
|
-
|
247
|
-
describe "#modified" do
|
248
|
-
it "replies with a message if the term hasn't been modified" do
|
249
|
-
send_command("conferenz modified foo")
|
250
|
-
expect(replies.last).to match(/never been modified/)
|
251
|
-
end
|
252
|
-
|
253
|
-
it "lists users who have modified the given term in count order" do
|
254
|
-
other_user = Lita::User.create("2", name: "Other User")
|
255
|
-
send_message("foo++", as: user)
|
256
|
-
send_message("foo++", as: user)
|
257
|
-
send_message("foo++", as: other_user)
|
258
|
-
send_command("conferenz modified foo")
|
259
|
-
expect(replies.last).to eq("#{user.name}, #{other_user.name}")
|
260
|
-
end
|
261
|
-
end
|
262
|
-
|
263
|
-
describe "#delete" do
|
264
|
-
before do
|
265
|
-
robot.auth.add_user_to_group!(user, :karma_admins)
|
266
|
-
end
|
267
|
-
|
268
|
-
it "deletes the term" do
|
269
|
-
send_message("foo++")
|
270
|
-
send_command("conferenz delete foo")
|
271
|
-
expect(replies.last).to eq("foo has been deleted.")
|
272
|
-
send_message("foo~~")
|
273
|
-
expect(replies.last).to eq("foo: 0")
|
274
|
-
end
|
275
|
-
|
276
|
-
it "matches terms exactly, including leading whitespace" do
|
277
|
-
term = " 'foo bar* 'baz''/ :"
|
278
|
-
subject.redis.zincrby("terms", 1, term)
|
279
|
-
send_command("conferenz delete #{term}")
|
280
|
-
expect(replies.last).to include("has been deleted")
|
281
|
-
end
|
282
|
-
|
283
|
-
it "clears the modification list" do
|
284
|
-
send_message("foo++")
|
285
|
-
send_command("conferenz delete foo")
|
286
|
-
send_command("conferenz modified foo")
|
287
|
-
expect(replies.last).to eq("foo has never been modified.")
|
288
|
-
end
|
289
|
-
|
290
|
-
it "clears the deleted term's links" do
|
291
|
-
send_command("foo += bar")
|
292
|
-
send_command("foo += baz")
|
293
|
-
send_command("conferenz delete foo")
|
294
|
-
send_message("foo++")
|
295
|
-
expect(replies.last).to eq("foo: 1")
|
296
|
-
end
|
297
|
-
|
298
|
-
it "clears links from other terms connected to the deleted term" do
|
299
|
-
send_command("bar += foo")
|
300
|
-
send_command("baz += foo")
|
301
|
-
send_command("conferenz delete foo")
|
302
|
-
send_message("bar++")
|
303
|
-
expect(replies.last).to eq("bar: 1")
|
304
|
-
send_message("baz++")
|
305
|
-
expect(replies.last).to eq("baz: 1")
|
306
|
-
end
|
307
|
-
end
|
308
|
-
|
309
|
-
describe "custom term patterns and normalization" do
|
310
|
-
before do
|
311
|
-
registry.config.handlers.karma.term_pattern = /[<:]([^>:]+)[>:]/
|
312
|
-
registry.config.handlers.karma.term_normalizer = lambda do |term|
|
313
|
-
term.to_s.downcase.strip.sub(/[<:]([^>:]+)[>:]/, '\1')
|
314
|
-
end
|
315
|
-
described_class.routes.clear
|
316
|
-
subject.define_routes(payload)
|
317
|
-
end
|
318
|
-
|
319
|
-
it "increments multi-word terms bounded by delimeters" do
|
320
|
-
send_message(":Some Thing:++")
|
321
|
-
expect(replies.last).to eq("some thing: 1")
|
322
|
-
end
|
323
|
-
|
324
|
-
it "increments terms with symbols that are bounded by delimeters" do
|
325
|
-
send_message("<C++>++")
|
326
|
-
expect(replies.last).to eq("c++: 1")
|
327
|
-
end
|
328
|
-
|
329
|
-
it "decrements multi-word terms bounded by delimeters" do
|
330
|
-
send_message(":Some Thing:--")
|
331
|
-
expect(replies.last).to eq("some thing: -1")
|
332
|
-
end
|
333
|
-
|
334
|
-
it "checks multi-word terms bounded by delimeters" do
|
335
|
-
send_message(":Some Thing:~~")
|
336
|
-
expect(replies.last).to eq("some thing: 0")
|
337
|
-
end
|
338
|
-
end
|
339
|
-
end
|