lita-web-title 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 +8 -0
- data/lib/lita/handlers/web_title.rb +7 -4
- data/lita-web-title.gemspec +1 -1
- data/spec/lita/handlers/web_title_spec.rb +13 -1
- 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: 60f05b4eff1085a1af11eb524681cbd79716e9ae
|
4
|
+
data.tar.gz: 1a529fdcf37a9ee1bf254cd25b46da3723729342
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b148d683874d8194cba52441b190ca891b4f0a07d8986703b6863bbd28aadc3f1c1b2dfc8ff03f161f7897c2951799eb75378fc3390bae9047f78f320e904b0
|
7
|
+
data.tar.gz: 9c96a3fa27c4a975259ecd918c17280eb5f2e5c0f507e7f751d7594828024e543d0179ad97d5a1aca3ae2e7fb560efa7743e463d19b3a185c7c38260a4161da0
|
data/README.md
CHANGED
@@ -10,6 +10,14 @@ Add lita-web-title to your Lita instance's Gemfile:
|
|
10
10
|
gem "lita-web-title"
|
11
11
|
```
|
12
12
|
|
13
|
+
## Configuration
|
14
|
+
|
15
|
+
### Required attributes
|
16
|
+
None
|
17
|
+
|
18
|
+
### Optional attributes
|
19
|
+
* ```ignore_patterns``` (String or Array) - A pattern or list of patterns. When a URL matches any of these patterns, Lita will silently ignore it. Default: ```nil```. Example: ```config.handlers.web_title.ignore_patterns = ["rpm.newrelic.com","example.com","my(dev|stg|prd).com"]```
|
20
|
+
|
13
21
|
## Usage
|
14
22
|
|
15
23
|
``` no-hilight
|
@@ -12,11 +12,14 @@ module Lita
|
|
12
12
|
|
13
13
|
def parse_uri_request(request)
|
14
14
|
requestUri = URI::extract(request.message.body, URI_PROTOCOLS).first
|
15
|
-
if config.ignore_patterns
|
16
|
-
|
15
|
+
if config.ignore_patterns then
|
16
|
+
if config.ignore_patterns.kind_of?(String) then
|
17
|
+
Array(config.ignore_patterns)
|
18
|
+
end
|
19
|
+
config.ignore_patterns.each do |pattern|
|
20
|
+
return if requestUri.match(%r{#{pattern}})
|
21
|
+
end
|
17
22
|
end
|
18
|
-
re = Regexp.union(%r(#{config.ignore_patterns}))
|
19
|
-
return if requestUri.match(re)
|
20
23
|
result = parse_uri(requestUri)
|
21
24
|
request.reply(result.delete("\n").strip) unless result.nil?
|
22
25
|
end
|
data/lita-web-title.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "lita-web-title"
|
3
|
-
spec.version = "1.0.
|
3
|
+
spec.version = "1.0.6"
|
4
4
|
spec.authors = ["Chris Baker"]
|
5
5
|
spec.email = ["dosman711@gmail.com"]
|
6
6
|
spec.description = "A Lita plugin to parse URIs and post the <title> of the page"
|
@@ -1,6 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Lita::Handlers::WebTitle, lita_handler: true do
|
4
|
+
before :each do
|
5
|
+
registry.config.handlers.web_title.tap do |config|
|
6
|
+
config.ignore_patterns = ["example.com","github.com"]
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
4
10
|
let(:robot) { Lita::Robot.new(registry) }
|
5
11
|
subject(:handler) { described_class.new(robot) }
|
6
12
|
|
@@ -24,7 +30,13 @@ describe Lita::Handlers::WebTitle, lita_handler: true do
|
|
24
30
|
send_command('This is the logo https://www.google.com/images/srpr/logo11w.png')
|
25
31
|
expect(replies.last).to be_nil
|
26
32
|
end
|
27
|
-
|
33
|
+
|
34
|
+
it 'ignores example.com links' do
|
35
|
+
send_command('I hate http://www.example.com/')
|
36
|
+
expect(replies.last).to be_nil
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
28
40
|
|
29
41
|
describe '.parse_uri' do
|
30
42
|
it 'returns the title' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-web-title
|
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
|
- Chris Baker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|