what_is 2.0.0 → 2.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 493c790fe1228f569420eef78cc6228c368fd6ba
4
- data.tar.gz: c884983bea39c2304f4110377376077062eacbd7
3
+ metadata.gz: 34bc624eb749ecafe148dcdca1a217dc96d3e02d
4
+ data.tar.gz: 2e359470f56ec958947dfc805c108d74f2451fa2
5
5
  SHA512:
6
- metadata.gz: 2a26c4b47795866d12904b353650ae7e1eee23019564afc14e32082460fdf0ceafc67c0025ff8fd342a964c3d6101b28d4c31ab05c208d53ae3977b1724dff73
7
- data.tar.gz: 4bfa06ede5bf98d9c416c11ad2c65a2838aa6fc34051104e5f6cbc263cad9cd8e520137f3dff7ecebda5f63b5a23e5f340440c2b5287628723b41ccbe96955ed
6
+ metadata.gz: f675709b46bafe489dc364ed558813d16d5d6e2faf25777cdc9df449003e78f7a1cb657d6afca836022a8592869d69d08349c3b6275d0d4841af7e0e043ef364
7
+ data.tar.gz: 9eb513bb18a8dd4ba686312aed13f6bbfbd80016fe9c1924f93af4e931bb00f2c9e5c8fc1dca90ed9604a9b60b640fe4ea10aac91253a50c822c85ae8a1c3e8b
@@ -1,3 +1,7 @@
1
+ require "net/http"
2
+ require "uri"
3
+ require "nokogiri"
4
+
1
5
  module WhatIs
2
6
  class Thesaurus
3
7
  BASE_URL = "http://www.dictionaryapi.com"
@@ -7,6 +11,8 @@ module WhatIs
7
11
  end
8
12
 
9
13
  def define!
14
+ raise WhatIs::NoApiKeyException unless api_key
15
+
10
16
  uri = URI.parse(api_endpoint)
11
17
  response = Net::HTTP.get_response(uri)
12
18
  doc = Nokogiri::XML(response.body)
@@ -26,5 +32,9 @@ module WhatIs
26
32
  def api_key
27
33
  WhatIs.configuration.thesaurus_api_key
28
34
  end
35
+
36
+ def no_api_key_exception_message
37
+ "ERROR: No api key provided for thesaurus."
38
+ end
29
39
  end
30
40
  end
@@ -1,3 +1,3 @@
1
1
  module WhatIs
2
- VERSION = "2.0.0"
2
+ VERSION = "2.0.1"
3
3
  end
data/lib/what_is.rb CHANGED
@@ -1,9 +1,6 @@
1
1
  require "what_is/version"
2
2
  require "what_is/configuration"
3
3
  require "what_is/exceptions"
4
- require "net/http"
5
- require "uri"
6
- require "nokogiri"
7
4
  require "what_is/thesaurus"
8
5
 
9
6
  module WhatIs
@@ -27,7 +24,6 @@ module WhatIs
27
24
  end
28
25
 
29
26
  def define!
30
- raise WhatIs::NoApiKeyException unless WhatIs.configuration.thesaurus_api_key
31
27
 
32
28
  case @reference
33
29
  when :thesaurus
@@ -47,9 +43,5 @@ module WhatIs
47
43
  def default_exception_message
48
44
  "ERROR: Unable to define `#{@word}`"
49
45
  end
50
-
51
- def no_api_key_exception_message
52
- "ERROR: No api key provided."
53
- end
54
46
  end
55
47
  end
@@ -1,17 +1,10 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe WhatIs do
4
- context "initially" do
5
- it "has no definition" do
6
- result = WhatIs::Define.new("sample")
7
- expect(result).not_to have_definition
8
- end
9
- end
10
-
11
4
  context "defining a word" do
12
5
  it "returns the meaning" do
13
6
  definition = double("definition", body: "sample")
14
- result = WhatIs::Define.new("house")
7
+ result = WhatIs::Define.new("house", :thesaurus)
15
8
 
16
9
  Net::HTTP.stub(:get_response).and_return(definition)
17
10
  expect(result.define!).to eq "sample"
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: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Chavez