geoip_city 0.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/README +9 -15
  2. data/Rakefile +5 -1
  3. data/geoip_city.c +2 -0
  4. data/test.rb +6 -0
  5. metadata +2 -2
data/README CHANGED
@@ -7,7 +7,13 @@ Actually this is only a Ruby binding to a C library which provides this
7
7
  function. Also, you must download a large binary database with all this
8
8
  mapping information. It is kindly provided free of charge by MaxMind.com.
9
9
 
10
- = How To Use
10
+ = Usage
11
+ require 'geoip_city'
12
+ db = GeoIPCity::Database.new('/opt/GeoIP/share/GeoIP/GeoLiteCity.dat')
13
+ result = db.look_up('24.24.24.24')
14
+ puts result.inspect
15
+
16
+ = Install
11
17
  Some variation of the following should work.
12
18
 
13
19
  1. Install the GeoCity C library. You can get it from here
@@ -19,16 +25,8 @@ Some variation of the following should work.
19
25
  ./configure --prefix=/opt/GeoIP
20
26
  make && sudo make install
21
27
 
22
- 2. Now install the geoip Ruby gem (this package!)
23
-
24
- Hint: You need to make sure that gcc can find the GeoIP header and library
25
- files. One way to do this is to ensure that your CPATH and LIBRARY_PATH
26
- enviromental variables include the GeoIP directory. So, if you want, do
27
- this:
28
- export CPATH="/opt/GeoIP/include:$CPATH"
29
- export LIBRARY_PATH="/opt/GeoIP/lib:$LIBRARY_PATH"
30
- sudo gem install geoip_city
31
-
28
+ 2. Now install the geoip_city gem
29
+ sudo gem install geoip_city -- --with-geoip-dir=/opt/GeoIP
32
30
 
33
31
  3. Download the GeoLite City database file in binary format from:
34
32
  http://www.maxmind.com/app/geolitecity
@@ -39,10 +37,6 @@ Some variation of the following should work.
39
37
 
40
38
 
41
39
  4. Use it!
42
- require 'geoip'
43
- db = GeoIP::Database.new('/opt/GeoIP/share/GeoIP/GeoLiteCity.dat')
44
- result = db.look_up('24.24.24.24')
45
- puts result.inspect
46
40
 
47
41
  = License
48
42
  Copyright (C) 2007 Ryan Dahl (ry@tinyclouds.org)
data/Rakefile CHANGED
@@ -24,7 +24,7 @@ spec = Gem::Specification.new do |s|
24
24
  s.name = 'geoip_city'
25
25
  s.author = 'ry dahl'
26
26
  s.email = 'ry@tinyclouds.org'
27
- s.version = "0.1"
27
+ s.version = "0.1.2"
28
28
  s.summary = "A Binding to the GeoIP C library"
29
29
  s.homepage = "http://geoip_city.rubyforge.org"
30
30
  s.files = FileList['Rakefile', '*.rb', '*.c', 'README*']
@@ -41,3 +41,7 @@ end
41
41
  desc 'compile the extension'
42
42
  task(:compile => 'Makefile') { sh 'make' }
43
43
  file('Makefile' => "geoip_city.c") { ruby 'extconf.rb' }
44
+
45
+ task(:webpage) do
46
+ sh 'scp -r doc/* rydahl@rubyforge.org:/var/www/gforge-projects/geoip-city/'
47
+ end
data/geoip_city.c CHANGED
@@ -18,6 +18,8 @@ VALUE rb_geoip_new(VALUE self, VALUE filename) {
18
18
  if(gi = GeoIP_open(STR2CSTR(filename), GEOIP_MEMORY_CACHE)) {
19
19
  database = Data_Wrap_Struct(cDB, 0, GeoIP_delete, gi);
20
20
  rb_obj_call_init(database, 0, 0);
21
+ } else {
22
+ rb_sys_fail("Problem opening database");
21
23
  }
22
24
  return database;
23
25
  }
data/test.rb CHANGED
@@ -21,5 +21,11 @@ class GeoIPTest < Test::Unit::TestCase
21
21
  assert_equal 'Ithaca', h[:city]
22
22
  assert_equal 'United States', h[:country_name]
23
23
  end
24
+
25
+ def test_bad_db_file
26
+ assert_raises Errno::ENOENT do
27
+ GeoIPCity::Database.new('/blah')
28
+ end
29
+ end
24
30
 
25
31
  end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: geoip_city
5
5
  version: !ruby/object:Gem::Version
6
- version: "0.1"
7
- date: 2007-10-27 00:00:00 +02:00
6
+ version: 0.1.2
7
+ date: 2007-12-09 00:00:00 -08:00
8
8
  summary: A Binding to the GeoIP C library
9
9
  require_paths:
10
10
  - .