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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 70b559ef8d1386aeed3494ce3457136d7ab67c2a
4
- data.tar.gz: b36e662f929049b22ed1f021bab7e759c1d045c9
3
+ metadata.gz: 838b81165b9ea6dc31218d5e149bb9728718dec0
4
+ data.tar.gz: fbbb65767d43508fe8ad15e20d786a07132ed3c3
5
5
  SHA512:
6
- metadata.gz: 949add8a59be4f7b589f473f13839507bfa5931263aa1ab6df45f78bf69e865d18c99909dbdc8da7c8e0028cb3c149c94fe6c1c8fe694bce0d9228300674e675
7
- data.tar.gz: c59ecc9cd585c9deb66ab2ec95bfe45c93c5414f95946fe57cfe9c25dda60e2a6a2cfee56d80ef0230c7ba10aa00273fc4ac3dee254b4f22eac86c4dd5c11030
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#{LABEL_REGEX}$/,
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
- return response.reply(status_label(name)) if Label.exists?(name)
52
- return response.reply(status_resource(name)) if Resource.exists?(name)
53
- response.reply(failed(t('subject.does_not_exist', name: name)))
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 = /(?<label>[\.\w\s-]+)(\s)?/
6
- LABELS_REGEX = /(?<labels>[\.\w\s-]+(?:,\s*[\.\w\s-]+)*)(\s)?/
7
- RESOURCE_REGEX = /(?<resource>[\.\w-]+)/
8
- RESOURCES_REGEX = /(?<resources>[\.\w-]+(?:,\s*[\.\w-]+)*)/
9
- COMMENT_REGEX = /(\s\#.+)?/
10
- LOCK_REGEX = /\(lock\)\s/i
11
- USER_REGEX = /(?:@)?(?<username>[\w\s-]+)/
12
- UNLOCK_REGEX = /(?:\(unlock\)|\(release\))\s/i
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
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'lita-locker'
3
- spec.version = '1.0.5'
3
+ spec.version = '1.0.6'
4
4
  spec.authors = ['Eric Sigler']
5
5
  spec.email = ['me@esigler.com']
6
6
  spec.description = '"lock" and "unlock" arbitrary subjects'
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 <subject>
26
+ syntax: lock <label>
27
27
  desc: "Make something unavailable to others. Can have # comments afterwards."
28
28
  unlock:
29
- syntax: unlock <subject>
29
+ syntax: unlock <label>
30
30
  desc: "Make something available to others. Can have # comments afterwards."
31
31
  observe:
32
- syntax: locker observe <subject>
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 <subject>
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 <subject>
38
+ syntax: steal <label>
39
39
  desc: "Force removal of a reservation. Can have # comments afterwards."
40
40
  give:
41
- syntax: locker give <subject> to <username>
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.5
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-08-17 00:00:00.000000000 Z
11
+ date: 2015-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita