cinch-wikipedia 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +1 -2
- data/cinch-wikipedia.gemspec +4 -3
- data/lib/cinch/plugins/wikipedia/version.rb +1 -1
- data/lib/cinch/plugins/wikipedia/wikipedia.rb +3 -3
- data/spec/cinch-wikipedia_spec.rb +8 -7
- data/spec/spec_helper.rb +8 -19
- metadata +25 -9
data/.travis.yml
CHANGED
data/cinch-wikipedia.gemspec
CHANGED
@@ -20,8 +20,9 @@ Gem::Specification.new do |gem|
|
|
20
20
|
gem.add_development_dependency 'rake'
|
21
21
|
gem.add_development_dependency 'rspec'
|
22
22
|
gem.add_development_dependency 'coveralls'
|
23
|
+
gem.add_development_dependency 'cinch-test'
|
23
24
|
|
24
|
-
gem.add_dependency 'cinch', '~> 2.0.
|
25
|
-
gem.add_dependency 'cinch-toolbox', '~> 1.0.
|
26
|
-
gem.add_dependency 'cinch-cooldown', '~> 1.0.
|
25
|
+
gem.add_dependency 'cinch', '~> 2.0.5'
|
26
|
+
gem.add_dependency 'cinch-toolbox', '~> 1.0.3'
|
27
|
+
gem.add_dependency 'cinch-cooldown', '~> 1.0.1'
|
27
28
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
require 'cinch'
|
3
|
-
require 'cinch
|
4
|
-
require 'cinch
|
3
|
+
require 'cinch/toolbox'
|
4
|
+
require 'cinch/cooldown'
|
5
5
|
|
6
6
|
module Cinch::Plugins
|
7
7
|
class Wikipedia
|
@@ -38,7 +38,7 @@ module Cinch::Plugins
|
|
38
38
|
wiki_text = Cinch::Toolbox.get_html_element(url, '#mw-content-text p')
|
39
39
|
|
40
40
|
# Check for search errors
|
41
|
-
return not_found(wiki_text, url) if wiki_text.include?('Help:Searching')
|
41
|
+
return not_found(wiki_text, url) if wiki_text.nil? || wiki_text.include?('Help:Searching')
|
42
42
|
end
|
43
43
|
|
44
44
|
# Truncate text and url if they are too long
|
@@ -1,41 +1,42 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Cinch::Plugins::Wikipedia do
|
4
|
+
include Cinch::Test
|
4
5
|
|
5
6
|
before(:all) do
|
6
|
-
@
|
7
|
+
@bot = make_bot(Cinch::Plugins::Wikipedia)
|
7
8
|
end
|
8
9
|
|
9
10
|
# normal queries
|
10
11
|
it 'should return a definition of a term' do
|
11
|
-
@
|
12
|
+
get_replies(make_message(@bot, '!wiki computer')).first.text.
|
12
13
|
should include("A computer is a general purpose device")
|
13
14
|
end
|
14
15
|
|
15
16
|
it 'should not return multiple lined definitions' do
|
16
|
-
@
|
17
|
+
get_replies(make_message(@bot, '!wiki Teenager')).first.text.
|
17
18
|
should_not include("\n")
|
18
19
|
end
|
19
20
|
|
20
21
|
it 'should not return definitions that are longer than 250 chars' do
|
21
|
-
@
|
22
|
+
get_replies(make_message(@bot, '!wiki Teenager')).first.text.length.
|
22
23
|
should == 334
|
23
24
|
end
|
24
25
|
|
25
26
|
# Not found
|
26
27
|
it 'should return an error message when a term is not found' do
|
27
|
-
@
|
28
|
+
get_replies(make_message(@bot, '!wiki dasdafasfasfasfasafsdfsdfsadf')).first.text.
|
28
29
|
should include("I couldn't find anything for that search, sorry!")
|
29
30
|
end
|
30
31
|
|
31
32
|
it 'should provide suggestions if one is listed on the page' do
|
32
|
-
@
|
33
|
+
get_replies(make_message(@bot, '!wiki smegama')).first.text.
|
33
34
|
should include("I couldn't find anything for that search, did you mean 'smegma'?")
|
34
35
|
end
|
35
36
|
|
36
37
|
# disambiguation
|
37
38
|
it 'should return helful information when a disambuation page' do
|
38
|
-
@
|
39
|
+
get_replies(make_message(@bot, '!wiki hacker')).first.text.
|
39
40
|
should include('is too vague and lead to a disambiguation page')
|
40
41
|
end
|
41
42
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,22 +1,11 @@
|
|
1
1
|
require 'coveralls'
|
2
|
-
|
3
|
-
require 'cinch-wikipedia'
|
2
|
+
require 'simplecov'
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
end
|
4
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
5
|
+
SimpleCov::Formatter::HTMLFormatter,
|
6
|
+
Coveralls::SimpleCov::Formatter
|
7
|
+
]
|
8
|
+
SimpleCov.start
|
11
9
|
|
12
|
-
|
13
|
-
|
14
|
-
def initialize(opts = {})
|
15
|
-
@bot = fake_bot
|
16
|
-
@handlers = []
|
17
|
-
@timers = []
|
18
|
-
# Don't init the bot
|
19
|
-
# __register
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
10
|
+
require 'cinch-wikipedia'
|
11
|
+
require 'cinch/test'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cinch-wikipedia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-08-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -59,6 +59,22 @@ dependencies:
|
|
59
59
|
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: cinch-test
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
62
78
|
- !ruby/object:Gem::Dependency
|
63
79
|
name: cinch
|
64
80
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,7 +82,7 @@ dependencies:
|
|
66
82
|
requirements:
|
67
83
|
- - ~>
|
68
84
|
- !ruby/object:Gem::Version
|
69
|
-
version: 2.0.
|
85
|
+
version: 2.0.5
|
70
86
|
type: :runtime
|
71
87
|
prerelease: false
|
72
88
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -74,7 +90,7 @@ dependencies:
|
|
74
90
|
requirements:
|
75
91
|
- - ~>
|
76
92
|
- !ruby/object:Gem::Version
|
77
|
-
version: 2.0.
|
93
|
+
version: 2.0.5
|
78
94
|
- !ruby/object:Gem::Dependency
|
79
95
|
name: cinch-toolbox
|
80
96
|
requirement: !ruby/object:Gem::Requirement
|
@@ -82,7 +98,7 @@ dependencies:
|
|
82
98
|
requirements:
|
83
99
|
- - ~>
|
84
100
|
- !ruby/object:Gem::Version
|
85
|
-
version: 1.0.
|
101
|
+
version: 1.0.3
|
86
102
|
type: :runtime
|
87
103
|
prerelease: false
|
88
104
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -90,7 +106,7 @@ dependencies:
|
|
90
106
|
requirements:
|
91
107
|
- - ~>
|
92
108
|
- !ruby/object:Gem::Version
|
93
|
-
version: 1.0.
|
109
|
+
version: 1.0.3
|
94
110
|
- !ruby/object:Gem::Dependency
|
95
111
|
name: cinch-cooldown
|
96
112
|
requirement: !ruby/object:Gem::Requirement
|
@@ -98,7 +114,7 @@ dependencies:
|
|
98
114
|
requirements:
|
99
115
|
- - ~>
|
100
116
|
- !ruby/object:Gem::Version
|
101
|
-
version: 1.0.
|
117
|
+
version: 1.0.1
|
102
118
|
type: :runtime
|
103
119
|
prerelease: false
|
104
120
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -106,7 +122,7 @@ dependencies:
|
|
106
122
|
requirements:
|
107
123
|
- - ~>
|
108
124
|
- !ruby/object:Gem::Version
|
109
|
-
version: 1.0.
|
125
|
+
version: 1.0.1
|
110
126
|
description: Cinch plugin that fetches a truncated blurb from the head of a wikipedia
|
111
127
|
page.
|
112
128
|
email:
|
@@ -147,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
147
163
|
version: '0'
|
148
164
|
requirements: []
|
149
165
|
rubyforge_project:
|
150
|
-
rubygems_version: 1.8.
|
166
|
+
rubygems_version: 1.8.25
|
151
167
|
signing_key:
|
152
168
|
specification_version: 3
|
153
169
|
summary: Cinch Wikipedia Plugin
|