dinosaurus 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/dinosaurus/thesaurus.rb +11 -0
- data/lib/dinosaurus/version.rb +1 -1
- data/lib/dinosaurus.rb +4 -0
- data/spec/dinosaurus/thesaurus_spec.rb +20 -0
- data/spec/fixtures/vcr_cassettes/normal.yml +40 -0
- metadata +10 -8
data/lib/dinosaurus/thesaurus.rb
CHANGED
@@ -10,6 +10,17 @@ module Dinosaurus
|
|
10
10
|
base_uri "words.bighugelabs.com"
|
11
11
|
format :json
|
12
12
|
|
13
|
+
def self.synonyms_of(word)
|
14
|
+
lookup = lookup(word)
|
15
|
+
|
16
|
+
synonyms = []
|
17
|
+
lookup[:results].each do |part_of_speech, types|
|
18
|
+
synonyms += types['syn'] if types['syn']
|
19
|
+
synonyms += types['sim'] if types['sim']
|
20
|
+
synonyms += types['rel'] if types['rel']
|
21
|
+
end
|
22
|
+
synonyms
|
23
|
+
end
|
13
24
|
|
14
25
|
def self.lookup(word)
|
15
26
|
res = get(url_for(word))
|
data/lib/dinosaurus/version.rb
CHANGED
data/lib/dinosaurus.rb
CHANGED
@@ -3,6 +3,18 @@ require "spec_helper"
|
|
3
3
|
describe Dinosaurus::Thesaurus do
|
4
4
|
subject { Dinosaurus::Thesaurus }
|
5
5
|
|
6
|
+
describe "synonyms_of" do
|
7
|
+
it "should return synonyms" do
|
8
|
+
VCR.use_cassette('normal') do
|
9
|
+
results = subject.synonyms_of('normal')
|
10
|
+
# Should include similar and related.
|
11
|
+
results.should include(*%w[sane convention average])
|
12
|
+
# Should not include antynoms.
|
13
|
+
results.should_not include(*%w[abnormal])
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
6
18
|
it "should return results" do
|
7
19
|
VCR.use_cassette('word') do
|
8
20
|
results = subject.lookup('word')[:results]
|
@@ -10,6 +22,14 @@ describe Dinosaurus::Thesaurus do
|
|
10
22
|
end
|
11
23
|
end
|
12
24
|
|
25
|
+
it "should return related terms" do
|
26
|
+
VCR.use_cassette('normal') do
|
27
|
+
results = subject.lookup('normal')[:results]
|
28
|
+
p results
|
29
|
+
results['adjective']['rel'].should include('sane')
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
13
33
|
it "should return the lookup word" do
|
14
34
|
VCR.use_cassette('word') do
|
15
35
|
subject.lookup('word')[:text].should == 'word'
|
@@ -0,0 +1,40 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://words.bighugelabs.com/api/2/<API_KEY>/normal/json
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers: {}
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 200
|
13
|
+
message: OK
|
14
|
+
headers:
|
15
|
+
Server:
|
16
|
+
- nginx/1.1.19
|
17
|
+
Date:
|
18
|
+
- Wed, 25 Jul 2012 10:32:52 GMT
|
19
|
+
Content-Type:
|
20
|
+
- text/javascript
|
21
|
+
Content-Length:
|
22
|
+
- '229'
|
23
|
+
Connection:
|
24
|
+
- keep-alive
|
25
|
+
X-Powered-By:
|
26
|
+
- PHP/5.3.10-1ubuntu3.2
|
27
|
+
Set-Cookie:
|
28
|
+
- PHPSESSID=c7o04aqfq3ucnshi05iiviaok2; 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: ! '{"adjective":{"ant":["abnormal","paranormal"],"rel":["sane","standard"],"sim":["average","mean","median","modal","natural","perpendicular","regular","typical"]},"noun":{"syn":["convention","pattern","rule","formula","practice"]}}'
|
38
|
+
http_version:
|
39
|
+
recorded_at: Wed, 25 Jul 2012 10:32:52 GMT
|
40
|
+
recorded_with: VCR 2.2.4
|
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.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70334277729580 !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: *70334277729580
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: vcr
|
27
|
-
requirement: &
|
27
|
+
requirement: &70334277728780 !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: *70334277728780
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: httparty
|
38
|
-
requirement: &
|
38
|
+
requirement: &70334277728020 !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: *70334277728020
|
47
47
|
description: Ruby wrapper for the Big Huge Thesaurus APIs.
|
48
48
|
email:
|
49
49
|
- dtuite@gmail.com
|
@@ -67,6 +67,7 @@ files:
|
|
67
67
|
- spec/dinosaurus/thesaurus_spec.rb
|
68
68
|
- spec/fixtures/vcr_cassettes/meal_people.yml
|
69
69
|
- spec/fixtures/vcr_cassettes/nonsense.yml
|
70
|
+
- spec/fixtures/vcr_cassettes/normal.yml
|
70
71
|
- spec/fixtures/vcr_cassettes/word.yml
|
71
72
|
- spec/spec_helper.rb
|
72
73
|
homepage: http://words.bighugelabs.com
|
@@ -97,5 +98,6 @@ test_files:
|
|
97
98
|
- spec/dinosaurus/thesaurus_spec.rb
|
98
99
|
- spec/fixtures/vcr_cassettes/meal_people.yml
|
99
100
|
- spec/fixtures/vcr_cassettes/nonsense.yml
|
101
|
+
- spec/fixtures/vcr_cassettes/normal.yml
|
100
102
|
- spec/fixtures/vcr_cassettes/word.yml
|
101
103
|
- spec/spec_helper.rb
|