Skip to content

Commit

Permalink
Allow for capitalization in emoji
Browse files Browse the repository at this point in the history
Fixes #20
  • Loading branch information
esigler committed Jul 31, 2014
1 parent df9ec95 commit f4aecd3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/lita/handlers/locker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ class Locker < Handler
LABEL_REGEX = /([\.\w\s-]+)/
RESOURCE_REGEX = /([\.\w-]+)/
COMMENT_REGEX = /(\s\#.+)?/
LOCK_REGEX = /\(lock\)\s/i
UNLOCK_REGEX = /(?:\(unlock\)|\(release\))\s/i

route(
/^\(lock\)\s#{LABEL_REGEX}#{COMMENT_REGEX}$/,
/^#{LOCK_REGEX}#{LABEL_REGEX}#{COMMENT_REGEX}$/,
:lock
)

route(
/^(?:\(unlock\)|\(release\))\s#{LABEL_REGEX}#{COMMENT_REGEX}$/,
/^#{UNLOCK_REGEX}#{LABEL_REGEX}#{COMMENT_REGEX}$/,
:unlock
)

Expand Down
4 changes: 4 additions & 0 deletions spec/lita/handlers/locker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
it { routes("(unlock) #{l}").to(:unlock) }
it { routes("(release) #{l}").to(:unlock) }

it { routes("(Lock) #{l}").to(:lock) }
it { routes("(Unlock) #{l}").to(:unlock) }
it { routes("(Release) #{l}").to(:unlock) }

it { routes("(lock) #{l} #this is a comment").to(:lock) }
it { routes("(unlock) #{l} #this is a comment").to(:unlock) }
it { routes("(release) #{l} #this is a comment").to(:unlock) }
Expand Down

0 comments on commit f4aecd3

Please sign in to comment.