rack-geoip 0.1.1 → 0.1.2
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 +3 -2
- data/VERSION +1 -1
- data/lib/rack/geoip.rb +3 -2
- data/lib/rack/geoip/lookup.rb +3 -3
- data/rack-geoip.gemspec +18 -20
- data/spec/rack-geoip_spec.rb +1 -1
- metadata +6 -7
- data/.gitignore +0 -22
data/README
CHANGED
@@ -41,8 +41,9 @@ And then in an initializer block
|
|
41
41
|
|
42
42
|
config.middleware.use "Rack::Geoip",
|
43
43
|
:db => 'data/GeoLiteCity.dat',
|
44
|
-
:path => '/geoip/info'
|
45
|
-
|
44
|
+
:path => '/geoip/info',
|
45
|
+
:db_lookup => :memory
|
46
|
+
|
46
47
|
=== Sample output
|
47
48
|
|
48
49
|
$ curl http://localhost:9292/lookup?ip=8.8.8.8
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/lib/rack/geoip.rb
CHANGED
@@ -25,7 +25,8 @@ module Rack #:nodoc:
|
|
25
25
|
#
|
26
26
|
# config.middleware.use "Rack::Geoip",
|
27
27
|
# :db => 'data/GeoLiteCity.dat',
|
28
|
-
# :path => '/geoip/info'
|
28
|
+
# :path => '/geoip/info',
|
29
|
+
# :db_lookup => :memory
|
29
30
|
#
|
30
31
|
module Geoip
|
31
32
|
autoload :Lookup, 'rack/geoip/lookup'
|
@@ -34,4 +35,4 @@ module Rack #:nodoc:
|
|
34
35
|
Lookup.new(backend,options)
|
35
36
|
end
|
36
37
|
end
|
37
|
-
end
|
38
|
+
end
|
data/lib/rack/geoip/lookup.rb
CHANGED
@@ -5,11 +5,11 @@ module Rack::Geoip
|
|
5
5
|
# Implements Rack's middleware interface and provides the geoip
|
6
6
|
# lookup service
|
7
7
|
class Lookup
|
8
|
-
DEFAULT = {:path => '/geoip/lookup', :db => 'GeoLiteCity.dat'}
|
8
|
+
DEFAULT = {:path => '/geoip/lookup', :db => 'GeoLiteCity.dat', :db_lookup => :memory}
|
9
9
|
|
10
10
|
def initialize(app, options={})
|
11
11
|
@app, @options = app, DEFAULT.merge(options)
|
12
|
-
@db = GeoIPCity::Database.new(@options[:db])
|
12
|
+
@db = GeoIPCity::Database.new(@options[:db], @options[:db_lookup])
|
13
13
|
end
|
14
14
|
|
15
15
|
def call(env)
|
@@ -29,4 +29,4 @@ module Rack::Geoip
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
32
|
-
end
|
32
|
+
end
|
data/rack-geoip.gemspec
CHANGED
@@ -1,46 +1,44 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rack-geoip}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Chris Kraybill"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2011-01-03}
|
13
13
|
s.description = %q{A rack middleware component that handles simple geoip lookups.}
|
14
14
|
s.email = %q{ckraybill@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"README",
|
17
|
-
|
17
|
+
"TODO"
|
18
18
|
]
|
19
19
|
s.files = [
|
20
20
|
".document",
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
"spec/spec_helper.rb"
|
21
|
+
"COPYING",
|
22
|
+
"README",
|
23
|
+
"Rakefile",
|
24
|
+
"TODO",
|
25
|
+
"VERSION",
|
26
|
+
"examples/basic.ru",
|
27
|
+
"lib/rack-geoip.rb",
|
28
|
+
"lib/rack/geoip.rb",
|
29
|
+
"lib/rack/geoip/lookup.rb",
|
30
|
+
"rack-geoip.gemspec",
|
31
|
+
"spec/rack-geoip_spec.rb",
|
32
|
+
"spec/spec.opts",
|
33
|
+
"spec/spec_helper.rb"
|
35
34
|
]
|
36
35
|
s.homepage = %q{http://github.com/ckraybill/rack-geoip}
|
37
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
38
36
|
s.require_paths = ["lib"]
|
39
37
|
s.rubygems_version = %q{1.3.7}
|
40
38
|
s.summary = %q{A rack middleware component that handles simple geoip lookups.}
|
41
39
|
s.test_files = [
|
42
40
|
"spec/rack-geoip_spec.rb",
|
43
|
-
|
41
|
+
"spec/spec_helper.rb"
|
44
42
|
]
|
45
43
|
|
46
44
|
if s.respond_to? :specification_version then
|
data/spec/rack-geoip_spec.rb
CHANGED
@@ -20,7 +20,7 @@ describe "RackGeoip" do
|
|
20
20
|
it 'should return 404 when a geocode lookup request has malformed parameters' do
|
21
21
|
get '/geocode/lookup'
|
22
22
|
last_response.status.should == 404
|
23
|
-
last_response.body.should == 'Example usage: http
|
23
|
+
last_response.body.should == 'Example usage: http://example.org/geocode/lookup?ip=8.8.8.8'
|
24
24
|
end
|
25
25
|
|
26
26
|
# This makes sure that the response is JSON parse-able
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-geoip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Chris Kraybill
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-01-03 00:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -73,7 +73,6 @@ extra_rdoc_files:
|
|
73
73
|
- TODO
|
74
74
|
files:
|
75
75
|
- .document
|
76
|
-
- .gitignore
|
77
76
|
- COPYING
|
78
77
|
- README
|
79
78
|
- Rakefile
|
@@ -92,8 +91,8 @@ homepage: http://github.com/ckraybill/rack-geoip
|
|
92
91
|
licenses: []
|
93
92
|
|
94
93
|
post_install_message:
|
95
|
-
rdoc_options:
|
96
|
-
|
94
|
+
rdoc_options: []
|
95
|
+
|
97
96
|
require_paths:
|
98
97
|
- lib
|
99
98
|
required_ruby_version: !ruby/object:Gem::Requirement
|