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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 96827a06dbd3e84d6cc2922de77a77dd666efa31
4
- data.tar.gz: 5ea5f4612b47af9e28d6c1c49bbe93328af4893e
3
+ metadata.gz: 9bc504abaed6b12c498d26d178fba9e8e24578b3
4
+ data.tar.gz: 14849216d28710c925694f1d849e04a8773dff72
5
5
  SHA512:
6
- metadata.gz: d30f06c334b5aceccb765ebe52d6b5d87fe35bd3f573126a4e58a2125d58950afb8d542de56411b7281e3153ee41f135f89ded9c28d3ed7c5f276f6327b3b764
7
- data.tar.gz: 3a99c9dd366d1bc2ae8aedc83b33cba2f418fef40fe93c7e9ae8f16f542dfbf3e8437e1233f56eacedc97370b3dfced2a2b58fedeca1482711eb9d1d567249dd
6
+ metadata.gz: 417006d216846f045dd552ceba491da30087d749d7b4f347d656ef99f81fabe1492797da48ea0e6d7fe8930dbc77b3943bed6e44694e41a4b33db0e3c74f9450
7
+ data.tar.gz: f9934c46cb7bb17c4c834c60940694c3fdde06d5a4970f9d17c6f9c3fcc8779a4e1648b0a7dc90df839ca448f4fa44d629463cb15f5039c04b8a24e12f91d8d6
@@ -1,3 +1,3 @@
1
1
  module WhatIs
2
- VERSION = "0.0.3"
2
+ VERSION = "0.1.0"
3
3
  end
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
- response.body
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. Something happened while defining this word"
34
+ "Oops! Something happened while defining this word."
33
35
  end
34
36
  end
35
37
  end
data/what_is.gemspec CHANGED
@@ -21,4 +21,6 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "bundler", "~> 1.5"
22
22
  spec.add_development_dependency "rake"
23
23
  spec.add_development_dependency "rspec"
24
+
25
+ spec.add_dependency "nokogiri"
24
26
  end
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.3
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