lita-message-router 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a6df74772ec177908be54f77b6377c1ee46d0b63
4
- data.tar.gz: 606fda53d7962d4269d782e2522b6aa396dff675
3
+ metadata.gz: 93c11ca67149f3656d6dabffeb814eb668c870f0
4
+ data.tar.gz: da08fab81da0d0a7dd062b699e57f423b3abb921
5
5
  SHA512:
6
- metadata.gz: 7587e5e69a71180033d467fadd8357ac96b941b6ca984c06d84b394677a6d4baa768948c3edcebe74c8ec1251341a4406c242ccf7ba236789b1594916f38da29
7
- data.tar.gz: cf7c69b791efbc89265f01c15631a448cfe8078e6d2515cf15e29270c28bb2de3588d27bd702b8b03f0e4a475ee51bde0c02e69ff0dfd4e40fa945c2d1f6236d
6
+ metadata.gz: a740d74b748bc7d128d8e756fa547ff13d8e8182bf0d33da49781c353e75de3b88ac0a0563a33693847899faeb06bfc75149c1e3e53e47cc06ffe6d18f2345c1
7
+ data.tar.gz: e7cea5b82ee7189e9d68c1eca4ff8fbdaadaf4915c439f8f1839de26fe3e7d102461e9e3f43998d8d036072ee5e549d10d75d03b0ed6f7af8351b4f4206f5b04
@@ -19,7 +19,7 @@ module Lita
19
19
  end
20
20
 
21
21
  def match(message)
22
- regex = Regexp.new('^(' + config.robot_mention_names.join('|') + ') (.+)')
22
+ regex = /^(#{config.robot_mention_names.map { |n| Regexp.escape(n) }.join('|')})\s*(.+)/
23
23
  matches = message.match(regex)
24
24
  matches[2] if matches
25
25
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-message-router"
3
- spec.version = "0.1.5"
3
+ spec.version = "0.1.6"
4
4
  spec.authors = ["Taylor Lapeyre"]
5
5
  spec.email = ["taylorlapeyre@gmail.com"]
6
6
  spec.description = "This handler allows you to specify as many 'mention names' as you want for your Lita robot."
@@ -1,12 +1,39 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Lita::Handlers::MessageRouter, lita_handler: true do
4
+ let(:greetings) do
5
+ Class.new(Lita::Handler) do
6
+ def self.name
7
+ 'Greetings'
8
+ end
9
+
10
+ route(/^hello world/, :hello, command: true)
11
+
12
+ def hello(response)
13
+ response.reply('hi')
14
+ end
15
+ end
16
+ end
17
+
4
18
  before do
5
- registry.config.handlers.message_router.robot_mention_names = ['!', '%']
19
+ registry.register_handler(greetings)
20
+ registry.config.handlers.message_router.robot_mention_names = ['!', '%', '.']
6
21
  end
7
22
 
8
- it 'routes correctly' do
23
+ it 'routes configured mention names correctly' do
9
24
  send_message('! hello world')
10
25
  send_message('% hello world')
26
+ expect(replies.count).to eq 2
27
+ end
28
+
29
+ it 'does not route unspecified mention names' do
30
+ send_message('/ hello world')
31
+ send_message('hello world')
32
+ expect(replies.count).to eq 0
33
+ end
34
+
35
+ it 'routes configured mention names containing special regex characters' do
36
+ send_message('.hello world')
37
+ expect(replies.count).to eq 1
11
38
  end
12
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-message-router
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taylor Lapeyre
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-23 00:00:00.000000000 Z
11
+ date: 2016-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita
@@ -134,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
134
134
  version: '0'
135
135
  requirements: []
136
136
  rubyforge_project:
137
- rubygems_version: 2.4.5.1
137
+ rubygems_version: 2.5.1
138
138
  signing_key:
139
139
  specification_version: 4
140
140
  summary: This handler allows you to specify as many 'mention names' as you want for