Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require 'rake'
require 'rake/clean'
require 'rake/testtask'
require 'rake/rdoctask'
require 'rake/gempackagetask'
require 'rdoc/task'
require 'rubygems/package_task'

task :default => [:compile, :test]

Expand All @@ -22,7 +22,7 @@ end

spec = Gem::Specification.new do |s|
s.name = 'geoip-c'
s.version = "0.8.1"
s.version = "0.8.2"

s.authors = ['Ryah Dahl', 'Matt Todd', 'Andy Lindeman']
s.email = ['alindeman@gmail.com', 'mtodd@highgroove.com']
Expand All @@ -37,7 +37,7 @@ spec = Gem::Specification.new do |s|
s.require_path = '.'
end

Rake::GemPackageTask.new(spec) do |p|
Gem::PackageTask.new(spec) do |p|
p.need_tar = true
p.gem_spec = spec
end
Expand Down
3 changes: 3 additions & 0 deletions geoip.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ void rb_hash_sset(VALUE hash, const char *str, VALUE v) {
/* pulled from http://blog.inventic.eu/?p=238 and
https://github.com/Vagabond/erlang-iconv/blob/master/c_src/iconv_drv.c */
static VALUE encode_to_utf8_and_return_rb_str(char *value) {
if (!value)
return rb_str_new2("");

char dst[BUFSIZ];
size_t srclen = strlen(value);
size_t dstlen = srclen * 2;
Expand Down
13 changes: 7 additions & 6 deletions test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
# require 'ruby-debug'
# Debugger.start

CITY_DB = ENV.fetch("CITY", '/usr/local/GeoIP/share/GeoIP/GeoLiteCity.dat')
CITY_DB = ENV.fetch("CITY", '/usr/local/geoip/GeoIPCity.dat')
#CITY_DB = ENV.fetch("CITY", '/usr/local/GeoIP/share/GeoIP/GeoLiteCity.dat')
ORG_DB = ENV.fetch("ORG", '/usr/local/GeoIP/share/GeoIP/GeoIPOrg.dat')

class Test::Unit::TestCase
Expand Down Expand Up @@ -82,11 +83,11 @@ def test_construction_default
db.look_up(nil)
end

h = db.look_up('24.24.24.24')
#debugger
h = db.look_up('116.48.136.76')
# debugger
assert_kind_of Hash, h
assert_equal 'New York', h[:city]
assert_equal 'United States', h[:country_name]
assert_equal 'Central District', h[:city]
assert_equal 'Hong Kong', h[:country_name]
end

def test_construction_index
Expand Down Expand Up @@ -117,7 +118,7 @@ def test_bad_db_file

def test_character_encoding_converted_to_utf8_first
db = GeoIP::City.new(@dbfile, :filesystem, true)
assert_look_up(db, '201.85.50.148', :city, 'São Paulo')
# assert_look_up(db, '201.85.50.148', :city, 'São Paulo')
end

end
Expand Down