lib/lita/handlers/locker_misc.rb in lita-locker-1.0.10 vs lib/lita/handlers/locker_misc.rb in lita-locker-1.1.0
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
module Lita
module Handlers
# Misc Locker handlers
class LockerMisc < Handler
namespace 'Locker'
@@ -8,32 +10,32 @@
include ::Locker::Misc
include ::Locker::Regex
include ::Locker::Resource
route(
- /^locker\sstatus\s#{LABEL_WILDCARD_REGEX}$/,
+ /^locker\sstatus\s#{LABEL_WILDCARD_REGEX}#{COMMENT_REGEX}$/,
:status,
command: true,
help: { t('help.status.syntax') => t('help.status.desc') }
)
route(
- /^locker\slist\s#{USER_REGEX}$/,
+ /^locker\slist\s#{USER_REGEX}#{COMMENT_REGEX}$/,
:list,
command: true,
help: { t('help.list.syntax') => t('help.list.desc') }
)
route(
- /^locker\s(dq|dequeue)\s#{LABEL_REGEX}$/,
+ /^locker\s(dq|dequeue)\s#{LABEL_REGEX}#{COMMENT_REGEX}$/,
:dequeue,
command: true,
help: { t('help.dequeue.syntax') => t('help.dequeue.desc') }
)
route(
- /^locker\slog\s#{LABEL_REGEX}$/,
+ /^locker\slog\s#{LABEL_REGEX}#{COMMENT_REGEX}$/,
:log,
command: true,
help: { t('help.log.syntax.') => t('help.log.desc') }
)
@@ -46,11 +48,11 @@
end
end
def status(response)
name = response.match_data['label']
- unless name =~ /\*/
+ unless name.match?(/\*/)
# Literal query
return response.reply(status_label(name)) if Label.exists?(name)
return response.reply(status_resource(name)) if Resource.exists?(name)
return response.reply(failed(t('status.does_not_exist', name: name)))
end
@@ -88,10 +90,10 @@
private
def status_label(name)
l = Label.new(name)
return unlocked(t('label.desc', name: name, state: l.state.value)) unless l.locked?
- if l.wait_queue.count > 0
+ if l.wait_queue.count.positive?
queue = []
l.wait_queue.each do |u|
usr = Lita::User.find_by_id(u)
queue.push(usr.name)
end