jgeoip 0.1.6-java → 0.1.7-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/.gitignore CHANGED
@@ -4,4 +4,5 @@ Gemfile.lock
4
4
  pkg/*
5
5
  target/*
6
6
  .DS_Store
7
- **/.DS_Store
7
+ **/.DS_Store
8
+ test/reports/*
data/.rvmrc CHANGED
@@ -1,2 +1 @@
1
- rvm use jruby-1.6.7
2
-
1
+ rvm use jruby-1.6.7
data/README.md CHANGED
@@ -6,6 +6,8 @@ You can easily use it with the free GeoIP Library from maxmind.com aswell as the
6
6
  ## example
7
7
  ### City Lookup
8
8
  p JGeoIP.new('/opt/MaxMind/GeoLiteCity.dat').city('github.com')
9
+
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}
9
11
 
10
12
  Will return a Location object with all the result properties and a #to_hash method
11
13
 
Binary file
@@ -1,3 +1,3 @@
1
1
  class JGeoIP
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
@@ -122,7 +122,7 @@ public class LocationProxy extends RubyObject {
122
122
 
123
123
  @JRubyMethod(name = "longitude")
124
124
  public IRubyObject getLongitude(ThreadContext context) {
125
- return context.runtime.newFloat(location.latitude);
125
+ return context.runtime.newFloat(location.longitude);
126
126
  }
127
127
 
128
128
  @JRubyMethod(name = "dma_code")
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  require 'test_helper'
2
4
  require 'benchmark'
3
5
 
@@ -22,6 +24,8 @@ class JGeoIPTest < Test::Unit::TestCase
22
24
  should 'find the city by ip too' do
23
25
  result = @geo.city('207.97.227.239')
24
26
  assert_equal 'United States', result[:country_name]
27
+ assert_in_delta 37.74839782714844, result.latitude, 10
28
+ assert_in_delta -122.41560363769531, result.longitude, 10
25
29
  end
26
30
 
27
31
  should 'find out the distance between to points' do
@@ -29,15 +33,10 @@ class JGeoIPTest < Test::Unit::TestCase
29
33
  p2 = @geo.city('alice.de')
30
34
  p3 = @geo.city('facebook.com')
31
35
  # from sf to hamburg
32
- assert_equal 8893.200366609715, p1.distance(p2)
36
+ assert_in_delta 8893.200366609715, p1.distance(p2), 10
33
37
 
34
38
  # from sf to sf
35
- assert_equal 46.25354059751858, p1.distance(p3)
36
-
37
- # no valid loation
38
- assert_raises Java::JavaLang::ClassCastException do
39
- p1.distance('foo')
40
- end
39
+ assert_in_delta 46.25354059751858, p1.distance(p3), 10
41
40
  end
42
41
 
43
42
  should 'return nil if an attribute does not exist' do
@@ -59,12 +58,19 @@ class JGeoIPTest < Test::Unit::TestCase
59
58
 
60
59
  should 'be inspectable' do
61
60
  result = @geo.city('85.183.18.35').inspect
62
- assert_match '{:city=>"Othmarschen"', result
61
+ assert_match /:city=>"(Othmarschen|Sparrieshoop)"/, result
63
62
  end
64
63
 
65
64
  should 'throw a clean exception if the ip was not found' do
66
65
  result = @geo.city('127.0.0.1')
67
66
  assert_equal nil, result
68
67
  end
68
+
69
+ should 'convert values to utf8' do
70
+ result = @geo.city('hs-osnabrueck.de').city
71
+ assert_equal 'Osnabrück', result
72
+ assert_equal 'UTF-8', result.encoding.to_s
73
+ end
74
+
69
75
  end
70
76
  end
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: jgeoip
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.6
5
+ version: 0.1.7
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-02-26 00:00:00.000000000Z
12
+ date: 2012-06-30 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.1.6.jar
73
+ - lib/java/jgeoip-0.1.7.jar
74
74
  - lib/jgeoip.rb
75
75
  - lib/jgeoip/version.rb
76
76
  - script/benchmark.rb
Binary file