urbandict 1.0.2 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +6 -0
- data/lib/urbandict.rb +15 -2
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 934b74ffaf40fbd3777aa02996131b8c3776bbf19f828cb023d3eaee4cebe380
|
4
|
+
data.tar.gz: 2855ee7125f40af14b7e974086a6b029fa2628a00c3981f48a8a56c8d45f881b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94ad97e8f2d22572e5a3ec12af53a35aaec168aae552a6a1e0fb302c8ed2cae403f135ff0a45c8570e5a7baa6c2de01f69cc8cd03c3223c5b03ae2261d549d7d
|
7
|
+
data.tar.gz: b9afd808b9c76dae011163c091707d6b5f90bc285ce97a59647d459ff1c5ddcf52d4726315c114930fe0a91d9d1640c9ccbc1783672df5d880cc7f16a7e74a8d
|
data/CHANGELOG.md
CHANGED
data/lib/urbandict.rb
CHANGED
@@ -5,21 +5,34 @@ require_relative 'slang'
|
|
5
5
|
module UrbanDictionary
|
6
6
|
module_function
|
7
7
|
|
8
|
-
URL = '
|
8
|
+
URL = 'https://api.urbandictionary.com/v0/define'
|
9
9
|
|
10
10
|
# Gets the definitions for the word.
|
11
11
|
# @param word [String] The word to define.
|
12
12
|
# @return [Array<Slang>] An array of #{Slang} objects.
|
13
|
+
# @raise [UrbanDictError]
|
13
14
|
def define(word)
|
14
15
|
params = {
|
15
16
|
term: word
|
16
17
|
}
|
17
18
|
@client = HTTPClient.new if @client.nil?
|
18
19
|
response = JSON.parse(@client.get(URI.parse(URL), params).body)
|
20
|
+
if response.key?('error')
|
21
|
+
raise UrbanDictError.new
|
22
|
+
end
|
19
23
|
ret = []
|
20
24
|
response['list'].each do |hash|
|
21
25
|
ret << Slang.new(hash)
|
22
26
|
end
|
23
27
|
ret
|
24
28
|
end
|
25
|
-
|
29
|
+
|
30
|
+
# Urban Dictionary does not provide any useful information, so we provide a note about alphanumeric characters which
|
31
|
+
# is the only error I have encountered to date (1/18/2021).
|
32
|
+
class UrbanDictError < StandardError
|
33
|
+
def message
|
34
|
+
'An error occurred. This could be because of issues with non-alphanumeric characters which are not handled ' \
|
35
|
+
'properly by the Urban Dictionary API.'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: urbandict
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eli Foster
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|
@@ -38,7 +38,7 @@ licenses:
|
|
38
38
|
- MIT
|
39
39
|
metadata:
|
40
40
|
issue_tracker: https://github.com/elifoster/urbandict-rb/issues
|
41
|
-
post_install_message:
|
41
|
+
post_install_message:
|
42
42
|
rdoc_options: []
|
43
43
|
require_paths:
|
44
44
|
- lib
|
@@ -53,9 +53,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
requirements: []
|
56
|
-
|
57
|
-
|
58
|
-
signing_key:
|
56
|
+
rubygems_version: 3.5.3
|
57
|
+
signing_key:
|
59
58
|
specification_version: 4
|
60
59
|
summary: An interface to the Urban Dictionary API
|
61
60
|
test_files: []
|