lita-locker 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -0
- data/lib/lita/handlers/locker_misc.rb +13 -4
- data/lib/locker/regex.rb +9 -8
- data/lita-locker.gemspec +1 -1
- data/locales/en.yml +6 -6
- data/spec/lita/handlers/locker_misc_spec.rb +18 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 838b81165b9ea6dc31218d5e149bb9728718dec0
|
4
|
+
data.tar.gz: fbbb65767d43508fe8ad15e20d786a07132ed3c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c0bd826f755585ab3a724a0b3436ba0c49edaba2ec6b52b692308fbc01ebd503c08f8460cc46cf607f149e840576d5076709fa78889579815d1c9cd89268d4c
|
7
|
+
data.tar.gz: c0dd281cae6b579fd077b9394d39af1df10963c1d0781141e7a2d148309f10d74297569f456afa44c9fc1c2bd2b45135d8c290e7e213c1a50da4cb46d1087a76
|
data/README.md
CHANGED
@@ -44,6 +44,15 @@ steal <label> - Force removal of a reservation. This can be don
|
|
44
44
|
locker give <label> to <user> - Transfer ownership of a lock to another user. This can only be done by the lock's current owner. Can have # comments afterwards.
|
45
45
|
```
|
46
46
|
|
47
|
+
### Status
|
48
|
+
```
|
49
|
+
locker status <label or resource> - Show the current state of <label or resource>
|
50
|
+
locker list <username> - Show what locks a user currently holds
|
51
|
+
locker log <label> - Show up to the last 10 activity log entries for <label>
|
52
|
+
locker observe <label> - Get a notification when <label> becomes available
|
53
|
+
locker unobserve <label> - Stop getting notifications when <label> becomes available
|
54
|
+
```
|
55
|
+
|
47
56
|
### Queueing
|
48
57
|
```
|
49
58
|
lock <label> - If <label> is already locked, adds you to a FIFO queue of pending reservations for <label>
|
@@ -10,7 +10,7 @@ module Lita
|
|
10
10
|
include ::Locker::Resource
|
11
11
|
|
12
12
|
route(
|
13
|
-
/^locker\sstatus\s#{
|
13
|
+
/^locker\sstatus\s#{LABEL_WILDCARD_REGEX}$/,
|
14
14
|
:status,
|
15
15
|
command: true,
|
16
16
|
help: { t('help.status.syntax') => t('help.status.desc') }
|
@@ -48,9 +48,18 @@ module Lita
|
|
48
48
|
|
49
49
|
def status(response)
|
50
50
|
name = response.match_data['label']
|
51
|
-
|
52
|
-
|
53
|
-
|
51
|
+
unless name =~ /\*/
|
52
|
+
# Literal query
|
53
|
+
return response.reply(status_label(name)) if Label.exists?(name)
|
54
|
+
return response.reply(status_resource(name)) if Resource.exists?(name)
|
55
|
+
end
|
56
|
+
# Wildcard query
|
57
|
+
matcher = Regexp.new(name.gsub(/\*/, '.*'))
|
58
|
+
labels = Label.list.select { |label| label =~ matcher }
|
59
|
+
return response.reply(failed(t('subject.does_not_exist', name: name))) if labels.empty?
|
60
|
+
labels.each do |n|
|
61
|
+
response.reply(status_label(n))
|
62
|
+
end
|
54
63
|
end
|
55
64
|
|
56
65
|
def dequeue(response)
|
data/lib/locker/regex.rb
CHANGED
@@ -2,13 +2,14 @@
|
|
2
2
|
module Locker
|
3
3
|
# Regex definitions
|
4
4
|
module Regex
|
5
|
-
LABEL_REGEX
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
5
|
+
LABEL_REGEX = /(?<label>[\.\w\s-]+)(\s)?/
|
6
|
+
LABEL_WILDCARD_REGEX = /(?<label>[\.\*\w\s-]+)(\s)?/
|
7
|
+
LABELS_REGEX = /(?<labels>[\.\w\s-]+(?:,\s*[\.\w\s-]+)*)(\s)?/
|
8
|
+
RESOURCE_REGEX = /(?<resource>[\.\w-]+)/
|
9
|
+
RESOURCES_REGEX = /(?<resources>[\.\w-]+(?:,\s*[\.\w-]+)*)/
|
10
|
+
COMMENT_REGEX = /(\s\#.+)?/
|
11
|
+
LOCK_REGEX = /\(lock\)\s/i
|
12
|
+
USER_REGEX = /(?:@)?(?<username>[\w\s-]+)/
|
13
|
+
UNLOCK_REGEX = /(?:\(unlock\)|\(release\))\s/i
|
13
14
|
end
|
14
15
|
end
|
data/lita-locker.gemspec
CHANGED
data/locales/en.yml
CHANGED
@@ -23,22 +23,22 @@ en:
|
|
23
23
|
syntax: locker dequeue <label>
|
24
24
|
desc: Remove yourself from the queue for a label
|
25
25
|
lock:
|
26
|
-
syntax: lock <
|
26
|
+
syntax: lock <label>
|
27
27
|
desc: "Make something unavailable to others. Can have # comments afterwards."
|
28
28
|
unlock:
|
29
|
-
syntax: unlock <
|
29
|
+
syntax: unlock <label>
|
30
30
|
desc: "Make something available to others. Can have # comments afterwards."
|
31
31
|
observe:
|
32
|
-
syntax: locker observe <
|
32
|
+
syntax: locker observe <label>
|
33
33
|
desc: "Get a notification when something becomes available. Can have # comments afterwards."
|
34
34
|
unobserve:
|
35
|
-
syntax: locker unobserve <
|
35
|
+
syntax: locker unobserve <label>
|
36
36
|
desc: "Stop getting notifications when something becomes available. Can have # comments afterwards."
|
37
37
|
steal:
|
38
|
-
syntax: steal <
|
38
|
+
syntax: steal <label>
|
39
39
|
desc: "Force removal of a reservation. Can have # comments afterwards."
|
40
40
|
give:
|
41
|
-
syntax: locker give <
|
41
|
+
syntax: locker give <label> to <username>
|
42
42
|
desc: "Transfer ownership of a lock to another user. Can have # comments afterwards."
|
43
43
|
status:
|
44
44
|
syntax: locker status <label or resource>
|
@@ -17,6 +17,8 @@ describe Lita::Handlers::LockerMisc, lita_handler: true do
|
|
17
17
|
it { is_expected.to route_command("locker status #{r}").to(:status) }
|
18
18
|
end
|
19
19
|
|
20
|
+
it { is_expected.to route_command('locker status foo*').to(:status) }
|
21
|
+
|
20
22
|
it do
|
21
23
|
is_expected.to route_command('locker list @alice').to(:list)
|
22
24
|
is_expected.to route_command('locker list Alice').to(:list)
|
@@ -113,6 +115,22 @@ describe Lita::Handlers::LockerMisc, lita_handler: true do
|
|
113
115
|
expect(replies.last).to eq('Resource: bar, state: locked')
|
114
116
|
end
|
115
117
|
|
118
|
+
it 'allows label wildcard search with an asterisk' do
|
119
|
+
send_command('locker resource create foobarbaz')
|
120
|
+
send_command('locker label create foobar')
|
121
|
+
send_command('locker label add foobarbaz to foobar')
|
122
|
+
send_command('locker resource create foobazbar')
|
123
|
+
send_command('locker label create foobaz')
|
124
|
+
send_command('locker label add foobazbar to foobaz')
|
125
|
+
send_command('locker resource create bazbarluhrmann')
|
126
|
+
send_command('locker label create bazbar')
|
127
|
+
send_command('locker label add bazbarluhrmann to bazbar')
|
128
|
+
send_command('lock foobar')
|
129
|
+
send_command('locker status foo*')
|
130
|
+
expect(replies[-2]).to match(/^foobar is locked by Test User \(taken \d seconds? ago\)$/)
|
131
|
+
expect(replies.last).to match(/^foobaz is unlocked$/)
|
132
|
+
end
|
133
|
+
|
116
134
|
it 'shows an error if nothing exists with that name' do
|
117
135
|
send_command('locker status foo')
|
118
136
|
expect(replies.last).to eq('Sorry, that does not exist')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-locker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Sigler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|