jgeoip 0.1.7-java → 0.2.0-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md
CHANGED
@@ -10,6 +10,12 @@ You can easily use it with the free GeoIP Library from maxmind.com aswell as the
|
|
10
10
|
# => {:city=>"San Francisco", :postal_code=>"94110", :country_code=>"US", :country_name=>"United States", :region=>"CA", :latitude=>37.74839782714844, :longitude=>37.74839782714844, :dma_code=>807, :area_code=>415, :metro_code=>807}
|
11
11
|
|
12
12
|
Will return a Location object with all the result properties and a #to_hash method
|
13
|
+
|
14
|
+
### Organization/ISP Lookup
|
15
|
+
p JGeoIP.new('/opt/MaxMind/GeoIPISP.dat').org('github.com')
|
16
|
+
|
17
|
+
Will return a string holding the organization/isp name
|
18
|
+
|
13
19
|
|
14
20
|
### Distance between two locations (km)
|
15
21
|
p1 = @geo.city('github.com')
|
Binary file
|
data/lib/jgeoip/version.rb
CHANGED
@@ -41,4 +41,14 @@ public class JGeoIP extends RubyObject {
|
|
41
41
|
|
42
42
|
return loc;
|
43
43
|
}
|
44
|
+
|
45
|
+
@JRubyMethod
|
46
|
+
public IRubyObject org(ThreadContext context, IRubyObject searchString) throws IOException {
|
47
|
+
String org = cl.getOrg(searchString.toString());
|
48
|
+
if (org == null) {
|
49
|
+
return context.runtime.getNil();
|
50
|
+
}
|
51
|
+
|
52
|
+
return context.runtime.newString(org);
|
53
|
+
}
|
44
54
|
}
|
data/test/unit/jgeoip_test.rb
CHANGED
@@ -4,6 +4,17 @@ require 'test_helper'
|
|
4
4
|
require 'benchmark'
|
5
5
|
|
6
6
|
class JGeoIPTest < Test::Unit::TestCase
|
7
|
+
context 'The GeoIP Organization/ISP API' do
|
8
|
+
setup do
|
9
|
+
@geo = JGeoIP.new('/opt/MaxMind/GeoIPISP.dat')
|
10
|
+
end
|
11
|
+
|
12
|
+
should 'find the correct isp by ip' do
|
13
|
+
assert_equal "Gruner + Jahr AG & Co, Hamburg", @geo.org('194.12.192.169')
|
14
|
+
assert_equal "Deutsche Telekom AG", @geo.org('193.159.61.143')
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
7
18
|
context 'The Geoip City API' do
|
8
19
|
setup do
|
9
20
|
@geo = JGeoIP.new('/opt/MaxMind/GeoLiteCity.dat')
|
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: jgeoip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.2.0
|
6
6
|
platform: java
|
7
7
|
authors:
|
8
8
|
- Tobias Schlottke
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-10 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: shoulda-context
|
@@ -70,7 +70,7 @@ files:
|
|
70
70
|
- Rakefile
|
71
71
|
- jgeoip.gemspec
|
72
72
|
- lib/java/geoip-1.2.5.jar
|
73
|
-
- lib/java/jgeoip-0.
|
73
|
+
- lib/java/jgeoip-0.2.0.jar
|
74
74
|
- lib/jgeoip.rb
|
75
75
|
- lib/jgeoip/version.rb
|
76
76
|
- script/benchmark.rb
|