urbandict 1.0.1 → 1.1.1

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.
Files changed (4) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +11 -1
  3. data/lib/urbandict.rb +15 -2
  4. metadata +10 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 490c93accab2849db78e5827cef4c9e61e4fc57f
4
- data.tar.gz: fcac408001e6146b528bff93043bb285763c2125
2
+ SHA256:
3
+ metadata.gz: 934b74ffaf40fbd3777aa02996131b8c3776bbf19f828cb023d3eaee4cebe380
4
+ data.tar.gz: 2855ee7125f40af14b7e974086a6b029fa2628a00c3981f48a8a56c8d45f881b
5
5
  SHA512:
6
- metadata.gz: 05e12efccee348519f52f4c09475db68df8fb538ebe6823ee3c51ccd91fd783dd44bd2598c14a6eb1541685d70c2fcfc8a5c3346697e11bcb85d5c3563fd01b7
7
- data.tar.gz: 6de19511111ce66b440fd6bb79db77be74d5ec9d6aee98da555dd427001c4acfd7188a174cdc4171d257b2456be07690881a69709584be558c688714958da78c
6
+ metadata.gz: 94ad97e8f2d22572e5a3ec12af53a35aaec168aae552a6a1e0fb302c8ed2cae403f135ff0a45c8570e5a7baa6c2de01f69cc8cd03c3223c5b03ae2261d549d7d
7
+ data.tar.gz: b9afd808b9c76dae011163c091707d6b5f90bc285ce97a59647d459ff1c5ddcf52d4726315c114930fe0a91d9d1640c9ccbc1783672df5d880cc7f16a7e74a8d
data/CHANGELOG.md CHANGED
@@ -1,7 +1,17 @@
1
1
  # Changelog
2
2
  ## Version 1
3
+ ### 1.1.1
4
+ * Update URL to use HTTPS, fixes no response body
5
+
6
+ ### 1.1.0
7
+ * New `UrbanDictError` is raised when the API returns an error.
8
+
9
+ ### 1.0.2
10
+ * Bump HTTPClient version.
11
+ * Use pessimistic version requirements.
12
+
3
13
  ### 1.0.1
4
14
  * License as MIT
5
15
 
6
16
  ### 1.0.0
7
- * Initial release.
17
+ * Initial release.
data/lib/urbandict.rb CHANGED
@@ -5,21 +5,34 @@ require_relative 'slang'
5
5
  module UrbanDictionary
6
6
  module_function
7
7
 
8
- URL = 'http://api.urbandictionary.com/v0/define'
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
- end
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,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: urbandict
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.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: 2016-03-23 00:00:00.000000000 Z
11
+ date: 2024-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '='
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.7.1
19
+ version: '2.8'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '='
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.7.1
26
+ version: '2.8'
27
27
  description: An interface to the Urban Dictionary API
28
28
  email: elifosterwy@gmail.com
29
29
  executables: []
@@ -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
- rubyforge_project:
57
- rubygems_version: 2.5.1
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: []