dinosaurus 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/dinosaurus.gemspec CHANGED
@@ -19,4 +19,5 @@ Gem::Specification.new do |gem|
19
19
  gem.add_development_dependency "vcr"
20
20
 
21
21
  gem.add_dependency "httparty"
22
+ gem.add_dependency "activesupport"
22
23
  end
@@ -1,6 +1,7 @@
1
1
  require "httparty"
2
2
  require "json"
3
3
  require "uri"
4
+ require "active_support/core_ext/object/blank"
4
5
 
5
6
  module Dinosaurus
6
7
  class MissingApiKeyError < StandardError; end
@@ -11,6 +12,8 @@ module Dinosaurus
11
12
  format :json
12
13
 
13
14
  def self.synonyms_of(word)
15
+ # No-op if the word is blank.
16
+ return [] if word.blank?
14
17
  lookup = lookup(word)
15
18
 
16
19
  synonyms = []
@@ -23,6 +26,7 @@ module Dinosaurus
23
26
  end
24
27
 
25
28
  def self.lookup(word)
29
+ return { text: word, results: [] } if word.blank?
26
30
  res = get(url_for(word))
27
31
 
28
32
  if res.code == 200
@@ -1,3 +1,3 @@
1
1
  module Dinosaurus
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -13,6 +13,10 @@ describe Dinosaurus::Thesaurus do
13
13
  results.should_not include(*%w[abnormal])
14
14
  end
15
15
  end
16
+
17
+ it "should return [] if the word is blank" do
18
+ subject.synonyms_of('').should == []
19
+ end
16
20
  end
17
21
 
18
22
  it "should return results" do
@@ -25,7 +29,6 @@ describe Dinosaurus::Thesaurus do
25
29
  it "should return related terms" do
26
30
  VCR.use_cassette('normal') do
27
31
  results = subject.lookup('normal')[:results]
28
- p results
29
32
  results['adjective']['rel'].should include('sane')
30
33
  end
31
34
  end
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.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-07-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70334277729580 !ruby/object:Gem::Requirement
16
+ requirement: &70257631167000 !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: *70334277729580
24
+ version_requirements: *70257631167000
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: vcr
27
- requirement: &70334277728780 !ruby/object:Gem::Requirement
27
+ requirement: &70257631165340 !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: *70334277728780
35
+ version_requirements: *70257631165340
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: httparty
38
- requirement: &70334277728020 !ruby/object:Gem::Requirement
38
+ requirement: &70257631178460 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,18 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70334277728020
46
+ version_requirements: *70257631178460
47
+ - !ruby/object:Gem::Dependency
48
+ name: activesupport
49
+ requirement: &70257631176920 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: *70257631176920
47
58
  description: Ruby wrapper for the Big Huge Thesaurus APIs.
48
59
  email:
49
60
  - dtuite@gmail.com