what_is 1.0.1 → 1.0.2

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: 4c401f91649f02ab63ee8cd4819794050ffabc14
4
- data.tar.gz: 6353c0ce49f59955e4555117844460210816146a
3
+ metadata.gz: 02323142fd6f70554516e9a31aef2f8b712ff242
4
+ data.tar.gz: 54cfa98a19c07eafba6bcdc30d463aecad2cc0b6
5
5
  SHA512:
6
- metadata.gz: 92318a6ce0576bb43e5e363aede6ed54467af58785bd82543bf9a1d47bef3d1bee8c57b5f0ee18853a94f3eb77bdcf9c2b3e3b191db8240291ff94459a6b7e97
7
- data.tar.gz: cef044a128a8804a53b02c199a1eccb9bda541a78540a0f973a879c87693e5097796db737919e3674666230bbbf1d9a8093a84e6dadcc63654e52a2be0064d99
6
+ metadata.gz: 0d962ab8c1b034f6f682e61920b397d9f28444768f3a2a96811b92af6bd3e69bd418c926748f026d04803c40be14951081f7266aa3b5e61f70b13787558e88ec
7
+ data.tar.gz: 69a59df41d797c249f3d699ecded139d1bd6aa079a8076c6468d13547852cdd8aebb8876cc77d03cd0f311d943a4ee7ae5dcea7f555f663367fd9d086c746cbe
@@ -1,10 +1,5 @@
1
1
  module WhatIs
2
2
  class Configuration
3
3
  attr_accessor :thesaurus_api_key, :dictionary_api_key
4
-
5
- def initialize
6
- @thesaurus_api_key = "invalid"
7
- @dictionary_api_key = "invalid"
8
- end
9
4
  end
10
5
  end
@@ -1,3 +1,3 @@
1
1
  module WhatIs
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
data/lib/what_is.rb CHANGED
@@ -25,12 +25,16 @@ module WhatIs
25
25
  end
26
26
 
27
27
  def define!
28
+ raise NoApiKeyException unless WhatIs.configuration.thesaurus_api_key
29
+
28
30
  thesaurus_endpoint = "http://www.dictionaryapi.com/api/v1/references/thesaurus/xml/#{@word}?key=#{WhatIs.configuration.thesaurus_api_key}"
29
31
  uri = URI.parse(thesaurus_endpoint)
30
32
  response = Net::HTTP.get_response(uri)
31
33
  doc = Nokogiri::XML(response.body)
32
34
 
33
35
  doc.xpath("//mc").first.text
36
+ rescue NoApiKeyException => e
37
+ no_api_key_exception_message
34
38
  rescue Exception => e
35
39
  default_exception_message
36
40
  end
@@ -44,5 +48,9 @@ module WhatIs
44
48
  def default_exception_message
45
49
  "Oops! Something happened while defining this word."
46
50
  end
51
+
52
+ def no_api_key_exception_message
53
+ "No api key provided."
54
+ end
47
55
  end
48
56
  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: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Chavez