cinch-urbandict 0.0.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +5 -0
- data/README.md +6 -0
- data/Rakefile +6 -0
- data/cinch-urbandict.gemspec +7 -2
- data/lib/cinch/plugins/urbandict/urbandict.rb +15 -7
- data/lib/cinch/plugins/urbandict/version.rb +1 -1
- data/spec/cinch-urbandict_spec.rb +31 -0
- data/spec/spec_helper.rb +22 -0
- metadata +79 -9
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Cinch::Plugins::Urbandict
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/cinch-urbandict.png)](http://badge.fury.io/rb/cinch-urbandict)
|
4
|
+
[![Dependency Status](https://gemnasium.com/bhaberer/cinch-urbandict.png)](https://gemnasium.com/bhaberer/cinch-urbandict)
|
5
|
+
[![Build Status](https://travis-ci.org/bhaberer/cinch-urbandict.png?branch=master)](https://travis-ci.org/bhaberer/cinch-urbandict)
|
6
|
+
[![Coverage Status](https://coveralls.io/repos/bhaberer/cinch-urbandict/badge.png?branch=master)](https://coveralls.io/r/bhaberer/cinch-urbandict?branch=master)
|
7
|
+
[![Code Climate](https://codeclimate.com/github/bhaberer/cinch-urbandict.png)](https://codeclimate.com/github/bhaberer/cinch-urbandict)
|
8
|
+
|
3
9
|
Simple Cinch Plugin to fetch Urbandictionary defs.
|
4
10
|
|
5
11
|
## Installation
|
data/Rakefile
CHANGED
data/cinch-urbandict.gemspec
CHANGED
@@ -17,6 +17,11 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
18
|
gem.require_paths = ["lib"]
|
19
19
|
|
20
|
-
gem.
|
21
|
-
gem.
|
20
|
+
gem.add_development_dependency 'rake'
|
21
|
+
gem.add_development_dependency 'rspec'
|
22
|
+
gem.add_development_dependency 'coveralls'
|
23
|
+
|
24
|
+
gem.add_dependency 'cinch', '~> 2.0.4'
|
25
|
+
gem.add_dependency 'cinch-toolbox', '>= 1.0.0'
|
26
|
+
gem.add_dependency 'cinch-cooldown', '~> 1.0.0'
|
22
27
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
+
require 'cinch'
|
2
3
|
require 'cinch-cooldown'
|
3
4
|
require 'cinch-toolbox'
|
4
5
|
|
@@ -9,10 +10,11 @@ module Cinch::Plugins
|
|
9
10
|
enforce_cooldown
|
10
11
|
|
11
12
|
self.help = "Use .ud <term> to see the Urban Dictionary definition for that term."
|
13
|
+
|
12
14
|
match /ud (.*)/
|
13
15
|
|
14
16
|
def execute(m, term)
|
15
|
-
m.reply get_def(term)
|
17
|
+
m.reply get_def(term), true
|
16
18
|
end
|
17
19
|
|
18
20
|
private
|
@@ -23,16 +25,22 @@ module Cinch::Plugins
|
|
23
25
|
|
24
26
|
url = "http://www.urbandictionary.com/define.php?term=#{term}"
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
+
if Cinch::Toolbox.get_html_element(url, '#not_defined_yet')
|
29
|
+
return "Urban Dictionary ∴ #{term}: No definition available."
|
30
|
+
else
|
31
|
+
# Grab the element
|
32
|
+
result = Cinch::Toolbox.get_html_element(url, '.definition')
|
33
|
+
|
34
|
+
result.gsub!(/[\n\r]/, ' - ')
|
28
35
|
|
29
|
-
|
30
|
-
|
36
|
+
#Make sure it's not terribly long
|
37
|
+
result = Cinch::Toolbox.truncate(result, 250)
|
38
|
+
url = Cinch::Toolbox.shorten(url)
|
31
39
|
|
32
|
-
|
40
|
+
return "Urban Dictionary ∴ #{term}: #{result} [#{url}]"
|
41
|
+
end
|
33
42
|
rescue NoMethodError
|
34
43
|
debug "Caught a NoMethodError looking up #{term}"
|
35
|
-
return "Sorry I couldn't find that term."
|
36
44
|
end
|
37
45
|
end
|
38
46
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Cinch::Plugins::UrbanDict do
|
5
|
+
|
6
|
+
before(:all) do
|
7
|
+
@plugin = Cinch::Plugins::UrbanDict.new
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should allow users to search for words' do
|
11
|
+
@plugin.send(:get_def, 'dork').
|
12
|
+
should match('Someone who has odd interests')
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should not return nil for valid searches' do
|
16
|
+
@plugin.send(:get_def, 'dong').
|
17
|
+
should_not be_nil
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should return an error for invalid searches' do
|
21
|
+
@plugin.send(:get_def, '7zJ6t8rT8p384My').
|
22
|
+
should == "Urban Dictionary ∴ 7zJ6t8rT8p384My: No definition available."
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should not eturn multiple lines for a definition with breaks' do
|
26
|
+
response = @plugin.send(:get_def, 'dong')
|
27
|
+
response.should_not match("<br")
|
28
|
+
response.should_not match("\r")
|
29
|
+
response.should_not match("\n")
|
30
|
+
end
|
31
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'coveralls'
|
2
|
+
Coveralls.wear!
|
3
|
+
require 'cinch-urbandict'
|
4
|
+
|
5
|
+
def fake_bot
|
6
|
+
bot = Cinch::Bot.new
|
7
|
+
bot.loggers.level = :fatal
|
8
|
+
bot
|
9
|
+
return bot
|
10
|
+
end
|
11
|
+
|
12
|
+
module Cinch
|
13
|
+
module Plugin
|
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
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cinch-urbandict
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,33 +9,33 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-06-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: rake
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0
|
22
|
-
type: :
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0
|
29
|
+
version: '0'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
|
-
name:
|
31
|
+
name: rspec
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
none: false
|
34
34
|
requirements:
|
35
35
|
- - ! '>='
|
36
36
|
- !ruby/object:Gem::Version
|
37
37
|
version: '0'
|
38
|
-
type: :
|
38
|
+
type: :development
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
@@ -43,6 +43,70 @@ dependencies:
|
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: coveralls
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: cinch
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 2.0.4
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 2.0.4
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: cinch-toolbox
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 1.0.0
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 1.0.0
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: cinch-cooldown
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 1.0.0
|
102
|
+
type: :runtime
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 1.0.0
|
46
110
|
description: Cinch Plugin to fetch definition data from Urban Dictionary
|
47
111
|
email:
|
48
112
|
- bhaberer@gmail.com
|
@@ -51,6 +115,7 @@ extensions: []
|
|
51
115
|
extra_rdoc_files: []
|
52
116
|
files:
|
53
117
|
- .gitignore
|
118
|
+
- .travis.yml
|
54
119
|
- Gemfile
|
55
120
|
- LICENSE.txt
|
56
121
|
- README.md
|
@@ -59,6 +124,8 @@ files:
|
|
59
124
|
- lib/cinch-urbandict.rb
|
60
125
|
- lib/cinch/plugins/urbandict/urbandict.rb
|
61
126
|
- lib/cinch/plugins/urbandict/version.rb
|
127
|
+
- spec/cinch-urbandict_spec.rb
|
128
|
+
- spec/spec_helper.rb
|
62
129
|
homepage: https://github.com/bhaberer/cinch-urbandict
|
63
130
|
licenses: []
|
64
131
|
post_install_message:
|
@@ -83,4 +150,7 @@ rubygems_version: 1.8.24
|
|
83
150
|
signing_key:
|
84
151
|
specification_version: 3
|
85
152
|
summary: Cinch Plugin for Urban Dictionary
|
86
|
-
test_files:
|
153
|
+
test_files:
|
154
|
+
- spec/cinch-urbandict_spec.rb
|
155
|
+
- spec/spec_helper.rb
|
156
|
+
has_rdoc:
|