what_is 0.0.1 → 0.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: a8f81fd0b392abecd866490733e727531f79d99f
4
- data.tar.gz: 1d02a0995db439043420fea68adaeda82af94de3
3
+ metadata.gz: 3777280267634b44ee778b97a4e4a437442a0de6
4
+ data.tar.gz: f9a65caaab2c15997a99add79e3eaacad7eb330a
5
5
  SHA512:
6
- metadata.gz: aa1a87689bbfd3a835fa730264e1a3de8cc499cff22285c7fc1054ff765719ff422b17f6ba75db844f527f92a6ec555c952660de1c099d9d565cb952bac444f1
7
- data.tar.gz: 75e4b079be19f04ae2acd490d24321c4e1dae07331989d2232dd14b4118701805336fea08a4e444052dc57274057d6c15e7b4f7aa965ec706484d24daec3e1d4
6
+ metadata.gz: ea906355fd3ab959172cd53f10622350a3bacc390418b54f6c3981cf01482ed3d8001d947ec1af8b2a3bc47a94d220f5302ed83366b5a551895f23ee7f986f61
7
+ data.tar.gz: 649020d5be74e79d59d3149259c309d7a6291d362b6cf5f8431807531a6a9d092e3f43088c37670f787b194a8a600381c4fe088b6e45e06a93305d1354b5a9f1
data/README.md CHANGED
@@ -1,6 +1,14 @@
1
- # WhatIs
1
+ # What Is
2
2
 
3
- TODO: Write a gem description
3
+ What the hell is this gem for? To put simply, this library enables us (developers) to define a given word. Think "dictionary". It uses the Merriam-Webster's API as the reference for giving the definitions.
4
+
5
+ # Setup
6
+
7
+ Register an account on http://www.dictionaryapi.com/ and make sure you request an api key for
8
+ Collegiate Dictionary and Collegiate Thesaurus. These are the two references that this library supports for now.
9
+
10
+ After registration, you should already have two api keys; one for the dictionary and other is for the thesaurus
11
+ version.
4
12
 
5
13
  ## Installation
6
14
 
@@ -18,11 +26,12 @@ Or install it yourself as:
18
26
 
19
27
  ## Usage
20
28
 
21
- TODO: Write usage instructions here
29
+ x = WhatIs::Define.new("<insert word to define>")
30
+ x.go! # returns the meaning of the word
22
31
 
23
32
  ## Contributing
24
33
 
25
- 1. Fork it ( http://github.com/<my-github-username>/what_is/fork )
34
+ 1. Fork it ( http://github.com/<my-github-username>what_is/fork )
26
35
  2. Create your feature branch (`git checkout -b my-new-feature`)
27
36
  3. Commit your changes (`git commit -am 'Add some feature'`)
28
37
  4. Push to the branch (`git push origin my-new-feature`)
@@ -1,3 +1,3 @@
1
1
  module WhatIs
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/what_is.rb CHANGED
@@ -1,13 +1,23 @@
1
1
  require "what_is/version"
2
+ require "net/http"
3
+ require "uri"
2
4
 
3
5
  module WhatIs
4
6
  class Define
7
+ DICT_API_KEY = "ae396fba-2435-4197-b780-c4b5485fec22"
8
+ THES_API_KEY = "c80b99cc-421c-4f86-bc50-45ef40b371fe"
9
+
5
10
  def initialize(word)
11
+ @word = word
6
12
  @has_definition = false
7
13
  end
8
14
 
9
15
  def define!
10
- "sample"
16
+ thesaurus_endpoint = "http://www.dictionaryapi.com/api/v1/references/thesaurus/xml/#{@word}?key=#{THES_API_KEY}"
17
+ uri = URI.parse(thesaurus_endpoint)
18
+ response = Net::HTTP.get_response(uri)
19
+
20
+ response.body
11
21
  end
12
22
 
13
23
  def has_definition?
@@ -10,7 +10,10 @@ describe WhatIs do
10
10
 
11
11
  context "defining a word" do
12
12
  it "returns the meaning" do
13
+ definition = double("definition", body: "sample")
13
14
  result = WhatIs::Define.new("house")
15
+
16
+ Net::HTTP.stub(:get_response).and_return(definition)
14
17
  expect(result.define!).to eq "sample"
15
18
  end
16
19
  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.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Chavez