dinosaurus 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +10 -2
- data/lib/dinosaurus/thesaurus.rb +3 -0
- data/lib/dinosaurus/version.rb +1 -1
- data/spec/dinosaurus/thesaurus_spec.rb +6 -0
- data/spec/fixtures/vcr_cassettes/nonsense.yml +40 -0
- metadata +9 -7
data/README.md
CHANGED
@@ -18,9 +18,17 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
|
21
|
+
Add your api key using the `configure` method.
|
22
22
|
|
23
|
-
|
23
|
+
Dinosaurus.configure do |config|
|
24
|
+
config.api_key = 'djksfhjk'
|
25
|
+
end
|
26
|
+
|
27
|
+
Now, lookup words in the Thesaurus:
|
28
|
+
|
29
|
+
require "dinosaurus"
|
30
|
+
|
31
|
+
results = Dinosaurus.lookup('word')
|
24
32
|
|
25
33
|
## Contributing
|
26
34
|
|
data/lib/dinosaurus/thesaurus.rb
CHANGED
@@ -15,6 +15,9 @@ module Dinosaurus
|
|
15
15
|
|
16
16
|
if res.code == 200
|
17
17
|
{ text: word, results: JSON.parse(res.body) }
|
18
|
+
# Word does not exist.
|
19
|
+
elsif res.code == 404
|
20
|
+
{ text: word, results: [] }
|
18
21
|
else
|
19
22
|
warning = "DINOSAURUS_WARNING: #{res.code}. WORD: #{word}."
|
20
23
|
Logging.logger.warn(warning)
|
data/lib/dinosaurus/version.rb
CHANGED
@@ -25,6 +25,12 @@ describe Dinosaurus::Thesaurus do
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
it "should return [] for nonsense words" do
|
29
|
+
VCR.use_cassette('nonsense') do
|
30
|
+
subject.lookup('hsdfkjhsf')[:results].should == []
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
28
34
|
it "should raise up if missing api key" do
|
29
35
|
Dinosaurus.configuration.stub(:api_key)
|
30
36
|
expect do
|
@@ -0,0 +1,40 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://words.bighugelabs.com/api/2/<API_KEY>/hsdfkjhsf/json
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers: {}
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 404
|
13
|
+
message: Not Found
|
14
|
+
headers:
|
15
|
+
Server:
|
16
|
+
- nginx/1.1.19
|
17
|
+
Date:
|
18
|
+
- Sun, 22 Jul 2012 21:28:48 GMT
|
19
|
+
Content-Type:
|
20
|
+
- text/html
|
21
|
+
Content-Length:
|
22
|
+
- '0'
|
23
|
+
Connection:
|
24
|
+
- keep-alive
|
25
|
+
X-Powered-By:
|
26
|
+
- PHP/5.3.10-1ubuntu3.2
|
27
|
+
Set-Cookie:
|
28
|
+
- PHPSESSID=kdt9bdp2nfkp8g5hp6h2ersk80; path=/; domain=words.bighugelabs.com
|
29
|
+
Expires:
|
30
|
+
- Thu, 19 Nov 1981 08:52:00 GMT
|
31
|
+
Cache-Control:
|
32
|
+
- no-store, no-cache, must-revalidate, post-check=0, pre-check=0
|
33
|
+
Pragma:
|
34
|
+
- no-cache
|
35
|
+
body:
|
36
|
+
encoding: US-ASCII
|
37
|
+
string: ''
|
38
|
+
http_version:
|
39
|
+
recorded_at: Sun, 22 Jul 2012 21:28:47 GMT
|
40
|
+
recorded_with: VCR 2.2.0
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dinosaurus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-07-22 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70182548252180 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70182548252180
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: vcr
|
27
|
-
requirement: &
|
27
|
+
requirement: &70182548250000 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70182548250000
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: httparty
|
38
|
-
requirement: &
|
38
|
+
requirement: &70182548247380 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70182548247380
|
47
47
|
description: Ruby wrapper for the Big Huge Thesaurus APIs.
|
48
48
|
email:
|
49
49
|
- dtuite@gmail.com
|
@@ -65,6 +65,7 @@ files:
|
|
65
65
|
- lib/dinosaurus/thesaurus.rb
|
66
66
|
- lib/dinosaurus/version.rb
|
67
67
|
- spec/dinosaurus/thesaurus_spec.rb
|
68
|
+
- spec/fixtures/vcr_cassettes/nonsense.yml
|
68
69
|
- spec/fixtures/vcr_cassettes/word.yml
|
69
70
|
- spec/spec_helper.rb
|
70
71
|
homepage: http://words.bighugelabs.com
|
@@ -93,5 +94,6 @@ specification_version: 3
|
|
93
94
|
summary: Lookup synonyms, antonyms etc. using the Big Huge Thesaurus API.
|
94
95
|
test_files:
|
95
96
|
- spec/dinosaurus/thesaurus_spec.rb
|
97
|
+
- spec/fixtures/vcr_cassettes/nonsense.yml
|
96
98
|
- spec/fixtures/vcr_cassettes/word.yml
|
97
99
|
- spec/spec_helper.rb
|