genderize_io_rb 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.6
1
+ 0.0.7
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "genderize_io_rb"
8
- s.version = "0.0.6"
8
+ s.version = "0.0.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kasper Johansen"]
@@ -27,6 +27,7 @@ Gem::Specification.new do |s|
27
27
  "VERSION",
28
28
  "genderize_io_rb.gemspec",
29
29
  "include/database_schema.rb",
30
+ "include/errors.rb",
30
31
  "include/result.rb",
31
32
  "lib/genderize_io_rb.rb",
32
33
  "spec/genderize_io_rb_spec.rb",
data/include/errors.rb ADDED
@@ -0,0 +1,3 @@
1
+ class GenderizeIoRb::Errors
2
+ class NameNotFound < RuntimeError; end
3
+ end
@@ -39,9 +39,12 @@ class GenderizeIoRb
39
39
  end
40
40
 
41
41
  http_res = @http.get("?name=#{CGI.escape(name)}")
42
+ json_res = JSON.parse(http_res.body)
43
+
44
+ raise GenderizeIoRb::Errors::NameNotFound, "Name was not found on Genderize.io: '#{name}'." unless json_res["gender"]
42
45
 
43
46
  res = ::GenderizeIoRb::Result.new(
44
- :data => JSON.parse(http_res.body),
47
+ :data => json_res,
45
48
  :genderize_io_rb => self
46
49
  )
47
50
 
@@ -45,4 +45,12 @@ describe "GenderizeIoRb" do
45
45
  gir.cache_db.insert(:genderize_io_rb_cache, :name => "kasper")
46
46
  }.to raise_error
47
47
  end
48
+
49
+ it "should raise errors when a name is not found" do
50
+ gir = GenderizeIoRb.new
51
+
52
+ expect {
53
+ gir.info_for_name("ksldfjslkjfweuir")
54
+ }.to raise_error(GenderizeIoRb::Errors::NameNotFound)
55
+ end
48
56
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: genderize_io_rb
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.6
5
+ version: 0.0.7
6
6
  platform: ruby
7
7
  authors:
8
8
  - Kasper Johansen
@@ -174,6 +174,7 @@ files:
174
174
  - VERSION
175
175
  - genderize_io_rb.gemspec
176
176
  - include/database_schema.rb
177
+ - include/errors.rb
177
178
  - include/result.rb
178
179
  - lib/genderize_io_rb.rb
179
180
  - spec/genderize_io_rb_spec.rb
@@ -192,7 +193,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
192
193
  - !ruby/object:Gem::Version
193
194
  segments:
194
195
  - 0
195
- hash: 148246184212076615
196
+ hash: -505520613497781920
196
197
  version: '0'
197
198
  required_rubygems_version: !ruby/object:Gem::Requirement
198
199
  none: false