what_is 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/what_is/version.rb +1 -1
- data/lib/what_is.rb +6 -4
- data/what_is.gemspec +2 -0
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9bc504abaed6b12c498d26d178fba9e8e24578b3
|
4
|
+
data.tar.gz: 14849216d28710c925694f1d849e04a8773dff72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 417006d216846f045dd552ceba491da30087d749d7b4f347d656ef99f81fabe1492797da48ea0e6d7fe8930dbc77b3943bed6e44694e41a4b33db0e3c74f9450
|
7
|
+
data.tar.gz: f9934c46cb7bb17c4c834c60940694c3fdde06d5a4970f9d17c6f9c3fcc8779a4e1648b0a7dc90df839ca448f4fa44d629463cb15f5039c04b8a24e12f91d8d6
|
data/lib/what_is/version.rb
CHANGED
data/lib/what_is.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "what_is/version"
|
2
2
|
require "net/http"
|
3
3
|
require "uri"
|
4
|
+
require "nokogiri"
|
4
5
|
|
5
6
|
module WhatIs
|
6
7
|
class Define
|
@@ -8,7 +9,7 @@ module WhatIs
|
|
8
9
|
THES_API_KEY = "c80b99cc-421c-4f86-bc50-45ef40b371fe"
|
9
10
|
|
10
11
|
def initialize(word)
|
11
|
-
@word = word
|
12
|
+
@word = word.to_s
|
12
13
|
@has_definition = false
|
13
14
|
end
|
14
15
|
|
@@ -16,9 +17,10 @@ module WhatIs
|
|
16
17
|
thesaurus_endpoint = "http://www.dictionaryapi.com/api/v1/references/thesaurus/xml/#{@word}?key=#{THES_API_KEY}"
|
17
18
|
uri = URI.parse(thesaurus_endpoint)
|
18
19
|
response = Net::HTTP.get_response(uri)
|
20
|
+
doc = Nokogiri::XML(response.body)
|
19
21
|
|
20
|
-
|
21
|
-
rescue
|
22
|
+
doc.xpath("//mc").text
|
23
|
+
rescue Exception => e
|
22
24
|
default_exception_message
|
23
25
|
end
|
24
26
|
|
@@ -29,7 +31,7 @@ module WhatIs
|
|
29
31
|
private
|
30
32
|
|
31
33
|
def default_exception_message
|
32
|
-
"Oops
|
34
|
+
"Oops! Something happened while defining this word."
|
33
35
|
end
|
34
36
|
end
|
35
37
|
end
|
data/what_is.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: what_is
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Chavez
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: nokogiri
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
description: Defines a string
|
56
70
|
email:
|
57
71
|
- markchav3z@gmail.com
|