geoip_server 1.1.2 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +8 -1
- data/Gemfile.lock +18 -1
- data/VERSION +1 -1
- data/geoip_server.gemspec +3 -3
- data/lib/geoip_server.rb +15 -2
- data/test.rb +16 -2
- metadata +52 -53
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -3,9 +3,22 @@ GEM
|
|
3
3
|
specs:
|
4
4
|
activesupport (3.0.3)
|
5
5
|
geoip (0.8.8)
|
6
|
+
git (1.2.5)
|
6
7
|
i18n (0.5.0)
|
8
|
+
jeweler (1.8.4)
|
9
|
+
bundler (~> 1.0)
|
10
|
+
git (>= 1.2.5)
|
11
|
+
rake
|
12
|
+
rdoc
|
13
|
+
json (1.7.5)
|
7
14
|
newrelic_rpm (2.13.4)
|
8
15
|
rack (1.2.1)
|
16
|
+
rack-test (0.6.1)
|
17
|
+
rack (>= 1.0)
|
18
|
+
rake (0.9.2.2)
|
19
|
+
rdoc (3.12)
|
20
|
+
json (~> 1.4)
|
21
|
+
shoulda (2.0.6)
|
9
22
|
sinatra (1.1.2)
|
10
23
|
rack (~> 1.1)
|
11
24
|
tilt (~> 1.2)
|
@@ -18,5 +31,9 @@ DEPENDENCIES
|
|
18
31
|
activesupport
|
19
32
|
geoip
|
20
33
|
i18n
|
34
|
+
jeweler
|
21
35
|
newrelic_rpm
|
22
|
-
|
36
|
+
rack-test
|
37
|
+
rake
|
38
|
+
shoulda
|
39
|
+
sinatra (= 1.1.2)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.2.0
|
data/geoip_server.gemspec
CHANGED
@@ -5,13 +5,13 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{geoip_server}
|
8
|
-
s.version =
|
8
|
+
s.version = File.read('VERSION').chomp
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Jack Danger Canty"]
|
11
|
+
s.authors = ["Jack Danger Canty", "Fabien Allanic"]
|
12
12
|
s.date = %q{2011-04-10}
|
13
13
|
s.description = %q{Query the MaxMind GeoIP data records via a web service}
|
14
|
-
s.email = %q{gitcommit@6brand.com}
|
14
|
+
s.email = %q{gitcommit@6brand.com fabien@foodtree.com}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"README.markdown"
|
17
17
|
]
|
data/lib/geoip_server.rb
CHANGED
@@ -45,8 +45,21 @@ get '/:ip' do
|
|
45
45
|
|
46
46
|
return "{}" unless data
|
47
47
|
|
48
|
-
ActiveSupport::JSON.encode(encode(data))
|
48
|
+
respond_with(ActiveSupport::JSON.encode(encode(data)))
|
49
|
+
end
|
49
50
|
|
51
|
+
def respond_with json
|
52
|
+
# jsonp support
|
53
|
+
callback, variable = params[:callback], params[:variable]
|
54
|
+
if callback && variable
|
55
|
+
"var #{variable} = #{json};\n#{callback}(#{variable});"
|
56
|
+
elsif variable
|
57
|
+
"var #{variable} = #{json};"
|
58
|
+
elsif callback
|
59
|
+
"#{callback}(#{json});"
|
60
|
+
else
|
61
|
+
json
|
62
|
+
end
|
50
63
|
end
|
51
64
|
|
52
65
|
def encode data
|
@@ -81,4 +94,4 @@ def encode data
|
|
81
94
|
# Timezone, if available
|
82
95
|
:timezone => data.shift
|
83
96
|
}
|
84
|
-
end
|
97
|
+
end
|
data/test.rb
CHANGED
@@ -32,10 +32,24 @@ class GeoipServerTest < Test::Unit::TestCase
|
|
32
32
|
should "return ok" do
|
33
33
|
assert last_response.ok?
|
34
34
|
end
|
35
|
+
should "return json conent-type" do
|
36
|
+
assert_equal 'application/json;charset=ascii-8bit', last_response.headers['Content-Type']
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context "on GET to /:ip?callback=myCallbackFunction" do
|
41
|
+
setup {
|
42
|
+
get '/67.161.92.71?callback=myCallbackFunction'
|
43
|
+
}
|
44
|
+
should "return ok" do
|
45
|
+
assert last_response.ok?
|
46
|
+
end
|
35
47
|
should "return json content-type" do
|
36
|
-
assert_equal 'application/json', last_response.headers['Content-Type']
|
37
48
|
assert_equal 'application/json;charset=ascii-8bit', last_response.headers['Content-Type']
|
38
49
|
end
|
50
|
+
should "have a function as result" do
|
51
|
+
assert last_response.body =~ /myCallbackFunction\(\{.*\}\)/
|
52
|
+
end
|
39
53
|
end
|
40
54
|
|
41
55
|
context "converting array" do
|
@@ -71,4 +85,4 @@ class GeoipServerTest < Test::Unit::TestCase
|
|
71
85
|
assert_equal -122.3848, @hash[:lng]
|
72
86
|
end
|
73
87
|
end
|
74
|
-
end
|
88
|
+
end
|
metadata
CHANGED
@@ -1,26 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geoip_server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
- 1
|
9
8
|
- 2
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 1.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jack Danger Canty
|
14
|
+
- Fabien Allanic
|
14
15
|
autorequire:
|
15
16
|
bindir: bin
|
16
17
|
cert_chain: []
|
17
18
|
|
18
|
-
date: 2011-04-10 00:00:00
|
19
|
-
default_executable:
|
19
|
+
date: 2011-04-10 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
-
|
23
|
-
|
22
|
+
name: sinatra
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
25
|
none: false
|
25
26
|
requirements:
|
26
27
|
- - ">="
|
@@ -29,12 +30,12 @@ dependencies:
|
|
29
30
|
segments:
|
30
31
|
- 0
|
31
32
|
version: "0"
|
32
|
-
requirement: *id001
|
33
|
-
prerelease: false
|
34
|
-
name: sinatra
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
33
|
type: :runtime
|
37
|
-
version_requirements:
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: activesupport
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
39
|
none: false
|
39
40
|
requirements:
|
40
41
|
- - ">="
|
@@ -43,12 +44,12 @@ dependencies:
|
|
43
44
|
segments:
|
44
45
|
- 0
|
45
46
|
version: "0"
|
46
|
-
requirement: *id002
|
47
|
-
prerelease: false
|
48
|
-
name: activesupport
|
49
|
-
- !ruby/object:Gem::Dependency
|
50
47
|
type: :runtime
|
51
|
-
version_requirements:
|
48
|
+
version_requirements: *id002
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: geoip
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
53
|
none: false
|
53
54
|
requirements:
|
54
55
|
- - ">="
|
@@ -57,12 +58,12 @@ dependencies:
|
|
57
58
|
segments:
|
58
59
|
- 0
|
59
60
|
version: "0"
|
60
|
-
requirement: *id003
|
61
|
-
prerelease: false
|
62
|
-
name: geoip
|
63
|
-
- !ruby/object:Gem::Dependency
|
64
61
|
type: :runtime
|
65
|
-
version_requirements:
|
62
|
+
version_requirements: *id003
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: i18n
|
65
|
+
prerelease: false
|
66
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
66
67
|
none: false
|
67
68
|
requirements:
|
68
69
|
- - ">="
|
@@ -71,12 +72,12 @@ dependencies:
|
|
71
72
|
segments:
|
72
73
|
- 0
|
73
74
|
version: "0"
|
74
|
-
requirement: *id004
|
75
|
-
prerelease: false
|
76
|
-
name: i18n
|
77
|
-
- !ruby/object:Gem::Dependency
|
78
75
|
type: :runtime
|
79
|
-
version_requirements:
|
76
|
+
version_requirements: *id004
|
77
|
+
- !ruby/object:Gem::Dependency
|
78
|
+
name: newrelic_rpm
|
79
|
+
prerelease: false
|
80
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
80
81
|
none: false
|
81
82
|
requirements:
|
82
83
|
- - ">="
|
@@ -85,12 +86,12 @@ dependencies:
|
|
85
86
|
segments:
|
86
87
|
- 0
|
87
88
|
version: "0"
|
88
|
-
requirement: *id005
|
89
|
-
prerelease: false
|
90
|
-
name: newrelic_rpm
|
91
|
-
- !ruby/object:Gem::Dependency
|
92
89
|
type: :runtime
|
93
|
-
version_requirements:
|
90
|
+
version_requirements: *id005
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: sinatra
|
93
|
+
prerelease: false
|
94
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
94
95
|
none: false
|
95
96
|
requirements:
|
96
97
|
- - ">="
|
@@ -101,12 +102,12 @@ dependencies:
|
|
101
102
|
- 0
|
102
103
|
- 0
|
103
104
|
version: 1.0.0
|
104
|
-
requirement: *id006
|
105
|
-
prerelease: false
|
106
|
-
name: sinatra
|
107
|
-
- !ruby/object:Gem::Dependency
|
108
105
|
type: :runtime
|
109
|
-
version_requirements:
|
106
|
+
version_requirements: *id006
|
107
|
+
- !ruby/object:Gem::Dependency
|
108
|
+
name: active_support
|
109
|
+
prerelease: false
|
110
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
110
111
|
none: false
|
111
112
|
requirements:
|
112
113
|
- - ">="
|
@@ -115,12 +116,12 @@ dependencies:
|
|
115
116
|
segments:
|
116
117
|
- 0
|
117
118
|
version: "0"
|
118
|
-
requirement: *id007
|
119
|
-
prerelease: false
|
120
|
-
name: active_support
|
121
|
-
- !ruby/object:Gem::Dependency
|
122
119
|
type: :runtime
|
123
|
-
version_requirements:
|
120
|
+
version_requirements: *id007
|
121
|
+
- !ruby/object:Gem::Dependency
|
122
|
+
name: geoip
|
123
|
+
prerelease: false
|
124
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
124
125
|
none: false
|
125
126
|
requirements:
|
126
127
|
- - ">="
|
@@ -129,12 +130,12 @@ dependencies:
|
|
129
130
|
segments:
|
130
131
|
- 0
|
131
132
|
version: "0"
|
132
|
-
|
133
|
-
|
134
|
-
name: geoip
|
133
|
+
type: :runtime
|
134
|
+
version_requirements: *id008
|
135
135
|
- !ruby/object:Gem::Dependency
|
136
|
-
|
137
|
-
|
136
|
+
name: shoulda
|
137
|
+
prerelease: false
|
138
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
138
139
|
none: false
|
139
140
|
requirements:
|
140
141
|
- - ">="
|
@@ -143,11 +144,10 @@ dependencies:
|
|
143
144
|
segments:
|
144
145
|
- 0
|
145
146
|
version: "0"
|
146
|
-
|
147
|
-
|
148
|
-
name: shoulda
|
147
|
+
type: :development
|
148
|
+
version_requirements: *id009
|
149
149
|
description: Query the MaxMind GeoIP data records via a web service
|
150
|
-
email: gitcommit@6brand.com
|
150
|
+
email: gitcommit@6brand.com fabien@foodtree.com
|
151
151
|
executables: []
|
152
152
|
|
153
153
|
extensions: []
|
@@ -164,7 +164,6 @@ files:
|
|
164
164
|
- geoip_server.gemspec
|
165
165
|
- lib/geoip_server.rb
|
166
166
|
- test.rb
|
167
|
-
has_rdoc: true
|
168
167
|
homepage: http://github.com/JackDanger/geoip_server
|
169
168
|
licenses: []
|
170
169
|
|
@@ -194,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
194
193
|
requirements: []
|
195
194
|
|
196
195
|
rubyforge_project:
|
197
|
-
rubygems_version: 1.
|
196
|
+
rubygems_version: 1.8.23
|
198
197
|
signing_key:
|
199
198
|
specification_version: 3
|
200
199
|
summary: Query the MaxMind GeoIP data records via a web service
|