jgeoip 0.0.3-java → 0.0.4-java
Sign up to get free protection for your applications and to get access to all the features.
Binary file
|
data/lib/jgeoip/version.rb
CHANGED
@@ -13,6 +13,7 @@ import java.util.HashSet;
|
|
13
13
|
import java.util.Set;
|
14
14
|
import java.lang.Object;
|
15
15
|
import org.jruby.Ruby;
|
16
|
+
import org.jruby.RubyNil;
|
16
17
|
import org.jruby.RubyArray;
|
17
18
|
import org.jruby.RubyClass;
|
18
19
|
import org.jruby.RubyFixnum;
|
@@ -62,8 +63,12 @@ public class JGeoIPLibrary implements Library {
|
|
62
63
|
}
|
63
64
|
|
64
65
|
@JRubyMethod
|
65
|
-
public
|
66
|
+
public IRubyObject city(ThreadContext context, IRubyObject searchString) throws IOException {
|
66
67
|
Location location = cl.getLocation(searchString.toString());
|
68
|
+
if (location == null) {
|
69
|
+
RubyNil nil = new RubyNil(ruby);
|
70
|
+
return nil;
|
71
|
+
}
|
67
72
|
|
68
73
|
RubyHash loc = new RubyHash(ruby);
|
69
74
|
loc.put(RubySymbol.newSymbol(ruby, "city"), RubyString.newString(ruby, location.city));
|
data/test/unit/jgeoip_test.rb
CHANGED
@@ -18,5 +18,10 @@ class JGeoIPTest < Test::Unit::TestCase
|
|
18
18
|
result = @geo.city('207.97.227.239')
|
19
19
|
assert_equal 'San Francisco', result[:city]
|
20
20
|
end
|
21
|
+
|
22
|
+
should 'throw a clean exception if the ip was not found' do
|
23
|
+
result = @geo.city('127.0.0.1')
|
24
|
+
assert_equal nil, result
|
25
|
+
end
|
21
26
|
end
|
22
27
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: jgeoip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.4
|
6
6
|
platform: java
|
7
7
|
authors:
|
8
8
|
- Tobias Schlottke
|
@@ -82,7 +82,7 @@ files:
|
|
82
82
|
- !binary |-
|
83
83
|
bGliL2phdmEvZ2VvaXAtMS4yLjUuamFy
|
84
84
|
- !binary |-
|
85
|
-
|
85
|
+
bGliL2phdmEvamdlb2lwLTAuMC40Lmphcg==
|
86
86
|
- !binary |-
|
87
87
|
bGliL2pnZW9pcC5yYg==
|
88
88
|
- !binary |-
|
data/lib/java/jgeoip-0.0.3.jar
DELETED
Binary file
|