lita-envy 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -2
- data/lib/lita/handlers/envy.rb +19 -19
- data/lita-envy.gemspec +1 -1
- data/spec/lita/handlers/envy_spec.rb +49 -49
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b6d149d6bff191a044dc53a59962548260a27d9
|
4
|
+
data.tar.gz: fcafab3b1480b4eace38dff345b45abb54d27cbd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af80d2fc2484482c0ba3046454d9e8fbaf9c14470458af905c241f0909c5403386549c119f0a3c1f320448828cdce04370a47bc5106eccca665cdc4d75d7c0dd
|
7
|
+
data.tar.gz: bfb11685eb3467ac104099e8e8a05b93014d4858ecd60e64e5cdf7655536520ac11b76cf38bfd058b5098b6c4e4ffae2d32eb0de05d81bd5329d737ee2acf749
|
data/README.md
CHANGED
data/lib/lita/handlers/envy.rb
CHANGED
@@ -2,35 +2,35 @@ module Lita
|
|
2
2
|
module Handlers
|
3
3
|
class Envy < Handler
|
4
4
|
|
5
|
-
route /\
|
6
|
-
route /\
|
7
|
-
route /\
|
8
|
-
route /\
|
9
|
-
route /\Awrestle
|
5
|
+
route /\Aclaim ([A-Za-z0-9_]+)\Z/, :claim_environment, help: { "claim [ENV ID]" => "Mark environment as in use by you"}, command: true
|
6
|
+
route /\Arelease ([A-Za-z0-9_]+)\Z/, :release_environment, help: { "release [ENV ID]" => "Mark environment as available"}, command: true
|
7
|
+
route /\Aenvs\Z/, :list_environments, help: { "envs" => "List environments"}, command: true
|
8
|
+
route /\Aforget ([A-Za-z0-9_]+)\Z/, :forget_environment, help: { "forget [ENV ID]" => "Forget environment"}, command: true
|
9
|
+
route /\Awrestle ([A-Za-z0-9_]+) from (.*)\Z/, :claim_used_environment, help: { "wrestle [ENV ID] from [USER]" => "Mark environment as in use by you, even though it is currently in use by another user"}, command: true
|
10
10
|
|
11
|
-
def
|
11
|
+
def claim_environment(response)
|
12
12
|
env_id = response.matches.first.first
|
13
13
|
current_user = redis.hget(['environments', env_id].join(':'), 'user')
|
14
14
|
if current_user.nil? || current_user.empty?
|
15
15
|
redis.hset(['environments', env_id].join(':'), 'user', response.user.name)
|
16
16
|
response.reply('ok')
|
17
17
|
elsif current_user == response.user.name
|
18
|
-
response.reply("
|
18
|
+
response.reply("Hmm, you are already using #{env_id}")
|
19
19
|
else
|
20
|
-
response.reply("
|
20
|
+
response.reply("Hmm, #{env_id} is currently in use by #{current_user}")
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
24
|
+
def release_environment(response)
|
25
25
|
env_id = response.matches.first.first
|
26
26
|
current_user = redis.hget(['environments', env_id].join(':'), 'user')
|
27
27
|
if current_user == response.user.name
|
28
28
|
redis.hset(['environments', env_id].join(':'), 'user', nil)
|
29
29
|
response.reply('ok')
|
30
30
|
elsif current_user.nil? || current_user.empty?
|
31
|
-
response.reply("
|
31
|
+
response.reply("Hmm, you are not currently using #{env_id}")
|
32
32
|
else
|
33
|
-
response.reply("
|
33
|
+
response.reply("Hmm, you are not currently using #{env_id} (#{current_user} is)")
|
34
34
|
end
|
35
35
|
|
36
36
|
end
|
@@ -47,33 +47,33 @@ module Lita
|
|
47
47
|
response.reply(lines.join("\n"))
|
48
48
|
end
|
49
49
|
|
50
|
-
def
|
50
|
+
def forget_environment(response)
|
51
51
|
env_id = response.matches.first.first
|
52
52
|
current_user = redis.hget(['environments', env_id].join(':'), 'user')
|
53
53
|
if current_user == response.user.name
|
54
|
-
response.reply("
|
54
|
+
response.reply("Hmm, you are currently using #{env_id}")
|
55
55
|
elsif current_user.nil?
|
56
|
-
response.reply("I do not know about
|
56
|
+
response.reply("Hmm, I do not know about #{env_id}")
|
57
57
|
elsif current_user.empty?
|
58
58
|
redis.del(['environments', env_id].join(':'))
|
59
59
|
response.reply('ok')
|
60
60
|
else
|
61
|
-
response.reply("
|
61
|
+
response.reply("Hmm, #{env_id} is currently in use by #{current_user}")
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
-
def
|
65
|
+
def claim_used_environment(response)
|
66
66
|
env_id, specified_user = response.matches.first
|
67
67
|
current_user = redis.hget(['environments', env_id].join(':'), 'user')
|
68
68
|
if specified_user == current_user
|
69
69
|
redis.hset(['environments', env_id].join(':'), 'user', response.user.name)
|
70
70
|
response.reply('ok')
|
71
71
|
elsif current_user.nil? or current_user.empty?
|
72
|
-
response.reply("
|
72
|
+
response.reply("Hmm, #{env_id} is not currently in use")
|
73
73
|
elsif current_user == response.user.name
|
74
|
-
response.reply("
|
74
|
+
response.reply("Hmm, you are already using #{env_id}")
|
75
75
|
else
|
76
|
-
response.reply("
|
76
|
+
response.reply("Hmm, #{env_id} is currently in use by #{current_user}, not #{specified_user}")
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
data/lita-envy.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "lita-envy"
|
3
|
-
spec.version = "0.1.
|
3
|
+
spec.version = "0.1.3"
|
4
4
|
spec.authors = ["Ingo Weiss"]
|
5
5
|
spec.email = ["ingo.weiss@lab49.com"]
|
6
6
|
spec.description = "Mark environments as in use. Mark environments as available. List environments"
|
@@ -4,11 +4,11 @@ describe Lita::Handlers::Envy, lita_handler: true do
|
|
4
4
|
|
5
5
|
describe 'Routing' do
|
6
6
|
|
7
|
-
it { is_expected.to route_command("
|
8
|
-
it { is_expected.to route_command("
|
9
|
-
it { is_expected.to route_command("
|
10
|
-
it { is_expected.to route_command("
|
11
|
-
it { is_expected.to route_command("wrestle
|
7
|
+
it { is_expected.to route_command("claim ENV123").to(:claim_environment) }
|
8
|
+
it { is_expected.to route_command("release ENV123").to(:release_environment) }
|
9
|
+
it { is_expected.to route_command("envs").to(:list_environments) }
|
10
|
+
it { is_expected.to route_command("forget ENV123").to(:forget_environment) }
|
11
|
+
it { is_expected.to route_command("wrestle ENV123 from Alicia").to(:claim_used_environment) }
|
12
12
|
|
13
13
|
end
|
14
14
|
|
@@ -22,12 +22,12 @@ describe Lita::Handlers::Envy, lita_handler: true do
|
|
22
22
|
|
23
23
|
it "should mark environment as in use by user" do
|
24
24
|
carl = Lita::User.create(123, name: "Carl")
|
25
|
-
send_command('
|
25
|
+
send_command('claim ENV123', :as => carl)
|
26
26
|
expect(subject.redis.hget('environments:ENV123', 'user')).to eq("Carl")
|
27
27
|
end
|
28
28
|
|
29
29
|
it "should reply with confirmation" do
|
30
|
-
send_command('
|
30
|
+
send_command('claim ENV123')
|
31
31
|
expect(replies.first).to eq("ok")
|
32
32
|
end
|
33
33
|
|
@@ -41,12 +41,12 @@ describe Lita::Handlers::Envy, lita_handler: true do
|
|
41
41
|
|
42
42
|
it "should mark environment as in use by user" do
|
43
43
|
carl = Lita::User.create(123, name: "Carl")
|
44
|
-
send_command('
|
44
|
+
send_command('claim ENV123', :as => carl)
|
45
45
|
expect(subject.redis.hget('environments:ENV123', 'user')).to eq("Carl")
|
46
46
|
end
|
47
47
|
|
48
48
|
it "should reply with confirmation" do
|
49
|
-
send_command('
|
49
|
+
send_command('claim ENV123')
|
50
50
|
expect(replies.first).to eq("ok")
|
51
51
|
end
|
52
52
|
|
@@ -60,15 +60,15 @@ describe Lita::Handlers::Envy, lita_handler: true do
|
|
60
60
|
|
61
61
|
it "should leave the environment untouched" do
|
62
62
|
carl = Lita::User.create(123, name: "Carl")
|
63
|
-
send_command('
|
63
|
+
send_command('claim ENV123', :as => carl)
|
64
64
|
expect(subject.redis.hget('environments:ENV123', 'user')).to eq("Alicia")
|
65
65
|
end
|
66
66
|
|
67
67
|
it "should reply with notification" do
|
68
68
|
subject.redis.hset('environments:ENV123', 'user', 'Alicia')
|
69
69
|
carl = Lita::User.create(123, name: "Carl")
|
70
|
-
send_command('
|
71
|
-
expect(replies.first).to eq("
|
70
|
+
send_command('claim ENV123', :as => carl)
|
71
|
+
expect(replies.first).to eq("Hmm, ENV123 is currently in use by Alicia")
|
72
72
|
end
|
73
73
|
|
74
74
|
end
|
@@ -81,15 +81,15 @@ describe Lita::Handlers::Envy, lita_handler: true do
|
|
81
81
|
|
82
82
|
it "should leave the environment untouched" do
|
83
83
|
carl = Lita::User.create(123, name: "Carl")
|
84
|
-
send_command('
|
84
|
+
send_command('claim ENV123', :as => carl)
|
85
85
|
expect(subject.redis.hget('environments:ENV123', 'user')).to eq("Carl")
|
86
86
|
end
|
87
87
|
|
88
88
|
it "should reply with notification" do
|
89
89
|
subject.redis.hset('environments:ENV123', 'user', 'Carl')
|
90
90
|
carl = Lita::User.create(123, name: "Carl")
|
91
|
-
send_command('
|
92
|
-
expect(replies.first).to eq("
|
91
|
+
send_command('claim ENV123', :as => carl)
|
92
|
+
expect(replies.first).to eq("Hmm, you are already using ENV123")
|
93
93
|
end
|
94
94
|
|
95
95
|
end
|
@@ -106,13 +106,13 @@ describe Lita::Handlers::Envy, lita_handler: true do
|
|
106
106
|
|
107
107
|
it "should mark environment as available" do
|
108
108
|
alicia = Lita::User.create(123, name: "Alicia")
|
109
|
-
send_command('
|
109
|
+
send_command('release ENV234', :as => alicia)
|
110
110
|
expect(subject.redis.hget('environments:ENV234', 'user')).to be_empty
|
111
111
|
end
|
112
112
|
|
113
113
|
it "should reply with confirmation" do
|
114
114
|
alicia = Lita::User.create(123, name: "Alicia")
|
115
|
-
send_command('
|
115
|
+
send_command('release ENV234', :as => alicia)
|
116
116
|
expect(replies.first).to eq("ok")
|
117
117
|
end
|
118
118
|
|
@@ -126,14 +126,14 @@ describe Lita::Handlers::Envy, lita_handler: true do
|
|
126
126
|
|
127
127
|
it "should leave the environment untouched" do
|
128
128
|
alicia = Lita::User.create(123, name: "Alicia")
|
129
|
-
send_command('
|
129
|
+
send_command('release ENV234', :as => alicia)
|
130
130
|
expect(subject.redis.hget('environments:ENV234', 'user')).to eq('Carl')
|
131
131
|
end
|
132
132
|
|
133
133
|
it "should reply with notification" do
|
134
134
|
alicia = Lita::User.create(123, name: "Alicia")
|
135
|
-
send_command('
|
136
|
-
expect(replies.first).to eq("
|
135
|
+
send_command('release ENV234', :as => alicia)
|
136
|
+
expect(replies.first).to eq("Hmm, you are not currently using ENV234 (Carl is)")
|
137
137
|
end
|
138
138
|
|
139
139
|
end
|
@@ -146,14 +146,14 @@ describe Lita::Handlers::Envy, lita_handler: true do
|
|
146
146
|
|
147
147
|
it "should leave the environment untouched" do
|
148
148
|
alicia = Lita::User.create(123, name: "Alicia")
|
149
|
-
send_command('
|
149
|
+
send_command('release ENV234', :as => alicia)
|
150
150
|
expect(subject.redis.hget('environments:ENV234', 'user')).to eq('')
|
151
151
|
end
|
152
152
|
|
153
153
|
it "should reply with notification" do
|
154
154
|
alicia = Lita::User.create(123, name: "Alicia")
|
155
|
-
send_command('
|
156
|
-
expect(replies.first).to eq("
|
155
|
+
send_command('release ENV234', :as => alicia)
|
156
|
+
expect(replies.first).to eq("Hmm, you are not currently using ENV234")
|
157
157
|
end
|
158
158
|
|
159
159
|
end
|
@@ -166,14 +166,14 @@ describe Lita::Handlers::Envy, lita_handler: true do
|
|
166
166
|
|
167
167
|
it "should leave the environment untouched" do
|
168
168
|
alicia = Lita::User.create(123, name: "Alicia")
|
169
|
-
send_command('
|
169
|
+
send_command('release ENV234', :as => alicia)
|
170
170
|
expect(subject.redis.hget('environments:ENV234', 'user')).to be_nil
|
171
171
|
end
|
172
172
|
|
173
173
|
it "should reply with notification" do
|
174
174
|
alicia = Lita::User.create(123, name: "Alicia")
|
175
|
-
send_command('
|
176
|
-
expect(replies.first).to eq("
|
175
|
+
send_command('release ENV234', :as => alicia)
|
176
|
+
expect(replies.first).to eq("Hmm, you are not currently using ENV234")
|
177
177
|
end
|
178
178
|
|
179
179
|
end
|
@@ -186,7 +186,7 @@ describe Lita::Handlers::Envy, lita_handler: true do
|
|
186
186
|
subject.redis.hset('environments:ENV123', 'user', 'Alicia')
|
187
187
|
subject.redis.hset('environments:ENV234', 'user', 'Carl')
|
188
188
|
subject.redis.hset('environments:ENV345', 'user', '')
|
189
|
-
send_command('
|
189
|
+
send_command('envs')
|
190
190
|
expect(replies.first.split("\n")).to eq([
|
191
191
|
"ENV123 (Alicia)",
|
192
192
|
"ENV234 (Carl)",
|
@@ -204,13 +204,13 @@ describe Lita::Handlers::Envy, lita_handler: true do
|
|
204
204
|
subject.redis.hset('environments:ENV345', 'user', '')
|
205
205
|
end
|
206
206
|
|
207
|
-
it "should
|
208
|
-
send_command('
|
207
|
+
it "should forgetironments" do
|
208
|
+
send_command('forget ENV345')
|
209
209
|
expect(subject.redis.keys).to_not include('environments:ENV345')
|
210
210
|
end
|
211
211
|
|
212
212
|
it "should confirm" do
|
213
|
-
send_command('
|
213
|
+
send_command('forget ENV345')
|
214
214
|
expect(replies.first).to eq("ok")
|
215
215
|
end
|
216
216
|
|
@@ -223,8 +223,8 @@ describe Lita::Handlers::Envy, lita_handler: true do
|
|
223
223
|
end
|
224
224
|
|
225
225
|
it "should reply with notification" do
|
226
|
-
send_command('
|
227
|
-
expect(replies.first).to eq("I do not know about
|
226
|
+
send_command('forget ENV345')
|
227
|
+
expect(replies.first).to eq("Hmm, I do not know about ENV345")
|
228
228
|
end
|
229
229
|
|
230
230
|
end
|
@@ -237,13 +237,13 @@ describe Lita::Handlers::Envy, lita_handler: true do
|
|
237
237
|
|
238
238
|
it "should leave the environment untouched" do
|
239
239
|
alicia = Lita::User.create(123, name: "Alicia")
|
240
|
-
send_command('
|
240
|
+
send_command('forget ENV345', :as => alicia)
|
241
241
|
expect(subject.redis.hget('environments:ENV345', 'user')).to eq('Carl')
|
242
242
|
end
|
243
243
|
|
244
244
|
it "should reply with notification" do
|
245
|
-
send_command('
|
246
|
-
expect(replies.first).to eq("
|
245
|
+
send_command('forget ENV345')
|
246
|
+
expect(replies.first).to eq("Hmm, ENV345 is currently in use by Carl")
|
247
247
|
end
|
248
248
|
|
249
249
|
end
|
@@ -256,14 +256,14 @@ describe Lita::Handlers::Envy, lita_handler: true do
|
|
256
256
|
|
257
257
|
it "should leave the environment untouched" do
|
258
258
|
alicia = Lita::User.create(123, name: "Alicia")
|
259
|
-
send_command('
|
259
|
+
send_command('forget ENV345', :as => alicia)
|
260
260
|
expect(subject.redis.hget('environments:ENV345', 'user')).to eq('Alicia')
|
261
261
|
end
|
262
262
|
|
263
263
|
it "should reply with notification" do
|
264
264
|
alicia = Lita::User.create(123, name: "Alicia")
|
265
|
-
send_command('
|
266
|
-
expect(replies.first).to eq("
|
265
|
+
send_command('forget ENV345', :as => alicia)
|
266
|
+
expect(replies.first).to eq("Hmm, you are currently using ENV345")
|
267
267
|
end
|
268
268
|
|
269
269
|
end
|
@@ -280,12 +280,12 @@ describe Lita::Handlers::Envy, lita_handler: true do
|
|
280
280
|
|
281
281
|
it "should mark environment as in use" do
|
282
282
|
carl = Lita::User.create(123, name: "Carl")
|
283
|
-
send_command('wrestle
|
283
|
+
send_command('wrestle ENV123 from Alicia', :as => carl)
|
284
284
|
expect(subject.redis.hget('environments:ENV123', 'user')).to eq("Carl")
|
285
285
|
end
|
286
286
|
|
287
287
|
it "should reply with confirmation" do
|
288
|
-
send_command('wrestle
|
288
|
+
send_command('wrestle ENV123 from Alicia')
|
289
289
|
expect(replies.first).to eq("ok")
|
290
290
|
end
|
291
291
|
|
@@ -299,13 +299,13 @@ describe Lita::Handlers::Envy, lita_handler: true do
|
|
299
299
|
|
300
300
|
it "should leave the environment untouched" do
|
301
301
|
carl = Lita::User.create(123, name: "Carl")
|
302
|
-
send_command('wrestle
|
302
|
+
send_command('wrestle ENV123 from Ben', :as => carl)
|
303
303
|
expect(subject.redis.hget('environments:ENV123', 'user')).to eq("Alicia")
|
304
304
|
end
|
305
305
|
|
306
306
|
it "should reply with notification" do
|
307
|
-
send_command('wrestle
|
308
|
-
expect(replies.first).to eq("
|
307
|
+
send_command('wrestle ENV123 from Ben')
|
308
|
+
expect(replies.first).to eq("Hmm, ENV123 is currently in use by Alicia, not Ben")
|
309
309
|
end
|
310
310
|
|
311
311
|
end
|
@@ -318,13 +318,13 @@ describe Lita::Handlers::Envy, lita_handler: true do
|
|
318
318
|
|
319
319
|
it "should leave the environment untouched" do
|
320
320
|
carl = Lita::User.create(123, name: "Carl")
|
321
|
-
send_command('wrestle
|
321
|
+
send_command('wrestle ENV123 from Ben', :as => carl)
|
322
322
|
expect(subject.redis.hget('environments:ENV123', 'user')).to be_empty
|
323
323
|
end
|
324
324
|
|
325
325
|
it "should reply with notification" do
|
326
|
-
send_command('wrestle
|
327
|
-
expect(replies.first).to eq("
|
326
|
+
send_command('wrestle ENV123 from Ben')
|
327
|
+
expect(replies.first).to eq("Hmm, ENV123 is not currently in use")
|
328
328
|
end
|
329
329
|
|
330
330
|
end
|
@@ -337,14 +337,14 @@ describe Lita::Handlers::Envy, lita_handler: true do
|
|
337
337
|
|
338
338
|
it "should leave the environment untouched" do
|
339
339
|
carl = Lita::User.create(123, name: "Carl")
|
340
|
-
send_command('wrestle
|
340
|
+
send_command('wrestle ENV123 from Ben', :as => carl)
|
341
341
|
expect(subject.redis.hget('environments:ENV123', 'user')).to eq('Carl')
|
342
342
|
end
|
343
343
|
|
344
344
|
it "should reply with notification" do
|
345
345
|
carl = Lita::User.create(123, name: "Carl")
|
346
|
-
send_command('wrestle
|
347
|
-
expect(replies.first).to eq("
|
346
|
+
send_command('wrestle ENV123 from Ben', :as => carl)
|
347
|
+
expect(replies.first).to eq("Hmm, you are already using ENV123")
|
348
348
|
end
|
349
349
|
|
350
350
|
end
|