geoip-c 0.9.0 → 0.9.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ae090a902a2c6012eef837411743d23201d98c3a
4
- data.tar.gz: e057da0aa1d34651f91a26fa0c3c586529cc493f
3
+ metadata.gz: b214921f3c6c8e001c5c4ba8f6644abd409eb82a
4
+ data.tar.gz: ba47aa25fe030a3a2ed16b6823920bd493a78145
5
5
  SHA512:
6
- metadata.gz: 19193af7ae5b8bfb762ab8d4b8a7eecde9c00d776f1c96a2ee3029a05845db26a2525eba3a365f478f2b591cd0ade6ae24c1e49d6942a502b7df2a8ee923c508
7
- data.tar.gz: e77e7cb91f5e4775a35f8db2962850b9d85141c38ef4ede81a73261d66a7e1468b72e222074056534f73a6b3740361176a27e9ca153e676250fe4a6724b15473
6
+ metadata.gz: 70537ae991d10c7ed6125e3311a2e94053ddb07db4cb009e134cb6a3da7a7387fe27184cc5e7bad41c313a9e28a0c719d2841e465eecb8e06ca3e9df49278546
7
+ data.tar.gz: 4b0e83e9f990e518a7bed7b57ee1263bb0ac73782fcf8ce4667a3297ab9acb8b9885644548a22d847b9a4a9bb9233a482bb8c86d379ead0baf77312c8cc4d72d
data/.gitignore CHANGED
@@ -1,5 +1,6 @@
1
- pkg/
2
- doc/
1
+ /.bundle
2
+ /pkg
3
+ /doc
3
4
  mkmf.log
4
5
  Makefile
5
6
  conftest.dSYM/
@@ -7,3 +8,5 @@ geoip.bundle
7
8
  geoip.so
8
9
  geoip.o
9
10
  Gemfile.lock
11
+ /tmp
12
+ /data
@@ -1,3 +1,7 @@
1
+ ## 0.9.1 (14 October 2013)
2
+
3
+ * Improves gem structure. (Luis Lavena)
4
+
1
5
  ## 0.9.0 (21 August 2013)
2
6
 
3
7
  * Returns UTF-8 encoded strings in Ruby 1.9. (Andy Lindeman)
data/Rakefile CHANGED
@@ -3,23 +3,39 @@ require 'bundler/gem_tasks'
3
3
  require 'rake/clean'
4
4
  require 'rake/testtask'
5
5
  require 'rdoc/task'
6
+ require "rake/extensiontask"
6
7
 
7
- task :default => [:compile, :test]
8
+ task :default => [:test]
8
9
 
9
- CLEAN.add "geoip.{o,bundle,so,obj,pdb,lib,def,exp}"
10
- CLOBBER.add ['Makefile', 'mkmf.log','doc']
10
+ CLOBBER.add 'doc', 'data'
11
11
 
12
- Rake::RDocTask.new do |rdoc|
13
- rdoc.rdoc_files.add ['README.md', 'geoip.c']
12
+ RDoc::Task.new do |rdoc|
14
13
  rdoc.main = "README.md" # page to start on
15
- rdoc.rdoc_dir = 'doc/' # rdoc output folder
14
+ rdoc.rdoc_files.add ["README.md", "ext/geoip/geoip.c"]
15
+ rdoc.rdoc_dir = 'doc' # rdoc output folder
16
16
  end
17
17
 
18
18
  Rake::TestTask.new do |t|
19
- t.test_files = ['test.rb']
20
19
  t.verbose = true
21
20
  end
22
21
 
23
- desc 'compile the extension'
24
- task(:compile => 'Makefile') { sh 'make' }
25
- file('Makefile' => "geoip.c") { ruby 'extconf.rb' }
22
+ spec = Gem::Specification.load "geoip-c.gemspec"
23
+
24
+ Rake::ExtensionTask.new("geoip", spec) do |ext|
25
+ end
26
+
27
+ directory "data"
28
+
29
+ file "data/GeoLiteCity.dat" => ["data"] do |f|
30
+ url = "http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz"
31
+
32
+ sh "curl #{url} -o data/GeoLiteCity.dat.gz"
33
+ sh "gunzip data/GeoLiteCity.dat.gz"
34
+ touch f.name
35
+ end
36
+
37
+ task :database => ["data/GeoLiteCity.dat"] do
38
+ ENV['CITY'] = File.expand_path("data/GeoLiteCity.dat")
39
+ end
40
+
41
+ task :test => [:compile, :database]
File without changes
@@ -137,6 +137,7 @@ static VALUE generic_single_value_lookup_response(char *key, char *value)
137
137
  VALUE rb_city_record_to_hash(GeoIPRecord *record)
138
138
  {
139
139
  VALUE hash = rb_hash_new();
140
+ char *region_name;
140
141
 
141
142
  if(record->country_code)
142
143
  rb_hash_sset(hash, "country_code", encode_to_utf8_and_return_rb_str(record->country_code));
@@ -147,10 +148,9 @@ VALUE rb_city_record_to_hash(GeoIPRecord *record)
147
148
  if(record->region) {
148
149
  rb_hash_sset(hash, "region", encode_to_utf8_and_return_rb_str(record->region));
149
150
 
150
- char *region_name = GeoIP_region_name_by_code(record->country_code, record->region);
151
- if (region_name) {
151
+ region_name = GeoIP_region_name_by_code(record->country_code, record->region);
152
+ if (region_name)
152
153
  rb_hash_sset(hash, "region_name", encode_to_utf8_and_return_rb_str(region_name));
153
- }
154
154
  }
155
155
  if(record->city)
156
156
  rb_hash_sset(hash, "city", encode_to_utf8_and_return_rb_str(record->city));
@@ -1,6 +1,8 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  Gem::Specification.new do |s|
2
4
  s.name = 'geoip-c'
3
- s.version = "0.9.0"
5
+ s.version = "0.9.1"
4
6
  s.licenses = ['WTFPL']
5
7
 
6
8
  s.authors = ['Ryan Dahl', 'Matt Todd', 'Charles Brian Quinn', 'Michael Sheakoski', 'Silvio Quadri', 'Andy Lindeman']
@@ -11,11 +13,11 @@ Gem::Specification.new do |s|
11
13
  s.homepage = "http://github.com/mtodd/geoip"
12
14
 
13
15
  s.files = `git ls-files`.split("\n")
14
- s.test_files = ['test.rb']
15
- s.extensions = ['extconf.rb']
16
- s.require_path = '.'
16
+ s.test_files = ['test/test_geoip.rb']
17
+ s.extensions = ["ext/geoip/extconf.rb"]
17
18
 
18
- s.add_development_dependency 'minitest', '~>5.0'
19
- s.add_development_dependency 'rake', '~>10.0'
20
- s.add_development_dependency 'rdoc', '~>4.0'
19
+ s.add_development_dependency 'minitest', '~> 5.0'
20
+ s.add_development_dependency 'rake', '~> 10.0'
21
+ s.add_development_dependency 'rdoc', '~> 4.0'
22
+ s.add_development_dependency "rake-compiler", "~> 0.9.1"
21
23
  end
@@ -1,8 +1,9 @@
1
1
  # encoding: utf-8
2
+
2
3
  require 'rubygems'
3
4
  gem 'minitest'
4
5
  require 'minitest/autorun'
5
- require File.dirname(__FILE__) + '/geoip'
6
+ require 'geoip'
6
7
 
7
8
  CITY_DB = ENV.fetch("CITY", '/usr/local/GeoIP/share/GeoIP/GeoLiteCity.dat')
8
9
  ORG_DB = ENV.fetch("ORG", '/usr/local/GeoIP/share/GeoIP/GeoIPOrg.dat')
@@ -115,7 +116,7 @@ class GeoIPCityTest < Minitest::Test
115
116
 
116
117
  def test_character_encoding_converted_to_utf8_first
117
118
  db = GeoIP::City.new(@dbfile, :filesystem, true)
118
- assert_look_up(db, '201.85.50.148', :city, "Jundiaí")
119
+ assert_look_up(db, '201.85.50.148', :city, "São Paulo")
119
120
  end
120
121
 
121
122
  def test_empty_region_name_does_not_crash
@@ -124,6 +125,10 @@ class GeoIPCityTest < Minitest::Test
124
125
  assert_look_up(db, '119.236.232.169', :region_name, nil)
125
126
  end
126
127
 
128
+ def test_hong_kong_segfault
129
+ db = GeoIP::City.new(@dbfile, :filesystem, true)
130
+ assert_look_up(db, "61.93.14.4", :country_name, "Hong Kong")
131
+ end
127
132
  end
128
133
 
129
134
  class GeoIPOrgTest < Minitest::Test
@@ -170,5 +175,4 @@ class GeoIPOrgTest < Minitest::Test
170
175
  GeoIP::Organization.new('/supposed-to-fail')
171
176
  end
172
177
  end
173
-
174
178
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geoip-c
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Dahl
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2013-08-21 00:00:00.000000000 Z
16
+ date: 2013-10-14 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: minitest
@@ -57,13 +57,27 @@ dependencies:
57
57
  - - ~>
58
58
  - !ruby/object:Gem::Version
59
59
  version: '4.0'
60
+ - !ruby/object:Gem::Dependency
61
+ name: rake-compiler
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ~>
65
+ - !ruby/object:Gem::Version
66
+ version: 0.9.1
67
+ type: :development
68
+ prerelease: false
69
+ version_requirements: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ~>
72
+ - !ruby/object:Gem::Version
73
+ version: 0.9.1
60
74
  description: Generic GeoIP lookup tool. Based on the geoip_city RubyGem by Ryan Dahl
61
75
  email:
62
76
  - andy@andylindeman.com
63
77
  - mtodd@highgroove.com
64
78
  executables: []
65
79
  extensions:
66
- - extconf.rb
80
+ - ext/geoip/extconf.rb
67
81
  extra_rdoc_files: []
68
82
  files:
69
83
  - .gitignore
@@ -71,10 +85,10 @@ files:
71
85
  - Gemfile
72
86
  - README.md
73
87
  - Rakefile
74
- - extconf.rb
88
+ - ext/geoip/extconf.rb
89
+ - ext/geoip/geoip.c
75
90
  - geoip-c.gemspec
76
- - geoip.c
77
- - test.rb
91
+ - test/test_geoip.rb
78
92
  homepage: http://github.com/mtodd/geoip
79
93
  licenses:
80
94
  - WTFPL
@@ -82,7 +96,7 @@ metadata: {}
82
96
  post_install_message:
83
97
  rdoc_options: []
84
98
  require_paths:
85
- - .
99
+ - lib
86
100
  required_ruby_version: !ruby/object:Gem::Requirement
87
101
  requirements:
88
102
  - - '>='
@@ -100,4 +114,4 @@ signing_key:
100
114
  specification_version: 4
101
115
  summary: A Binding to the GeoIP C library
102
116
  test_files:
103
- - test.rb
117
+ - test/test_geoip.rb