rack-geoip 0.1.2 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ vendor/bundle
5
+ .config
6
+ .yardoc
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ data
12
+ doc/
13
+ lib/bundler/man
14
+ pkg
15
+ rdoc
16
+ spec/reports
17
+ test/tmp
18
+ test/version_tmp
19
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in rack-geoip.gemspec
4
+ gemspec
data/Rakefile CHANGED
@@ -1,48 +1,7 @@
1
- require 'rubygems'
2
- require 'rake'
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
 
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "rack-geoip"
8
- gem.summary = %Q{A rack middleware component that handles simple geoip lookups.}
9
- gem.description = %Q{A rack middleware component that handles simple geoip lookups.}
10
- gem.email = "ckraybill@gmail.com"
11
- gem.homepage = "http://github.com/ckraybill/rack-geoip"
12
- gem.authors = ["Chris Kraybill"]
13
- gem.add_development_dependency "rspec", ">= 1.2.9"
14
- gem.add_dependency "geoip_city"
15
- gem.add_dependency "json"
16
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
17
- end
18
- Jeweler::GemcutterTasks.new
19
- rescue LoadError
20
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
21
- end
22
-
23
- require 'spec/rake/spectask'
24
- Spec::Rake::SpecTask.new(:spec) do |spec|
25
- spec.libs << 'lib' << 'spec'
26
- spec.spec_files = FileList['spec/**/*_spec.rb']
27
- end
28
-
29
- Spec::Rake::SpecTask.new(:rcov) do |spec|
30
- spec.libs << 'lib' << 'spec'
31
- spec.pattern = 'spec/**/*_spec.rb'
32
- spec.rcov = true
33
- end
34
-
35
- task :spec => :check_dependencies
4
+ RSpec::Core::RakeTask.new
36
5
 
37
6
  task :default => :spec
38
-
39
- require 'rake/rdoctask'
40
- Rake::RDocTask.new do |rdoc|
41
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
42
-
43
- rdoc.rdoc_dir = 'rdoc'
44
- rdoc.title = "rack-geoip #{version}"
45
- rdoc.rdoc_files.include('README*','COPYING')
46
- rdoc.rdoc_files.include('lib/**/*.rb')
47
- rdoc.rdoc_files.include('TODO')
48
- end
7
+ task :test => :spec
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 2.0.1
@@ -11,18 +11,18 @@ module Rack::Geoip
11
11
  @app, @options = app, DEFAULT.merge(options)
12
12
  @db = GeoIPCity::Database.new(@options[:db], @options[:db_lookup])
13
13
  end
14
-
14
+
15
15
  def call(env)
16
16
  dup._call(env)
17
17
  end
18
-
18
+
19
19
  def _call(env)
20
20
  if env['PATH_INFO'] == @options[:path]
21
21
  request = Rack::Request.new(env)
22
22
  if request.params['ip'] && result=@db.look_up(request.params['ip'])
23
- [200, {'Content-Type' => 'application/json'}, result.to_json]
23
+ [200, {'Content-Type' => 'application/json'}, [result.to_json]]
24
24
  else
25
- [404, {'Content-Type' => 'text/plain'}, "Example usage: #{env['rack.url_scheme']}://#{env['HTTP_HOST']}#{env['PATH_INFO']}?ip=8.8.8.8"]
25
+ [404, {'Content-Type' => 'text/plain'}, ["Example usage: #{env['rack.url_scheme']}://#{env['HTTP_HOST']}#{env['PATH_INFO']}?ip=8.8.8.8"]]
26
26
  end
27
27
  else
28
28
  @app.call(env)
@@ -0,0 +1,5 @@
1
+ module Rack
2
+ module Geoip
3
+ VERSION = '2.0.1'
4
+ end
5
+ end
data/rack-geoip.gemspec CHANGED
@@ -1,63 +1,28 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
1
  # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ require 'rack/geoip/version'
5
6
 
6
7
  Gem::Specification.new do |s|
7
- s.name = %q{rack-geoip}
8
- s.version = "0.1.2"
8
+ s.name = "rack-geoip"
9
+ s.version = Rack::Geoip::VERSION
10
+ s.authors = ["Chris Kraybill"]
11
+ s.email = ["ckraybill@gmail.com"]
12
+ s.description = %q{A rack middleware component that handles simple geoip lookups.}
13
+ s.summary = %q{A rack middleware component that handles simple geoip lookups.}
14
+ s.homepage = %q{http://github.com/ckraybill/rack-geoip}
9
15
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Chris Kraybill"]
12
- s.date = %q{2011-01-03}
13
- s.description = %q{A rack middleware component that handles simple geoip lookups.}
14
- s.email = %q{ckraybill@gmail.com}
15
- s.extra_rdoc_files = [
16
- "README",
17
- "TODO"
18
- ]
19
- s.files = [
20
- ".document",
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"
34
- ]
35
- s.homepage = %q{http://github.com/ckraybill/rack-geoip}
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = []
36
19
  s.require_paths = ["lib"]
37
- s.rubygems_version = %q{1.3.7}
38
- s.summary = %q{A rack middleware component that handles simple geoip lookups.}
39
- s.test_files = [
40
- "spec/rack-geoip_spec.rb",
41
- "spec/spec_helper.rb"
42
- ]
43
20
 
44
- if s.respond_to? :specification_version then
45
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
46
- s.specification_version = 3
21
+ s.add_dependency 'rack'
22
+ s.add_dependency 'geoip_city19', '>= 2.0.1'
23
+ s.add_dependency 'json'
47
24
 
48
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
49
- s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
50
- s.add_runtime_dependency(%q<geoip_city>, [">= 0"])
51
- s.add_runtime_dependency(%q<json>, [">= 0"])
52
- else
53
- s.add_dependency(%q<rspec>, [">= 1.2.9"])
54
- s.add_dependency(%q<geoip_city>, [">= 0"])
55
- s.add_dependency(%q<json>, [">= 0"])
56
- end
57
- else
58
- s.add_dependency(%q<rspec>, [">= 1.2.9"])
59
- s.add_dependency(%q<geoip_city>, [">= 0"])
60
- s.add_dependency(%q<json>, [">= 0"])
61
- end
25
+ s.add_development_dependency 'rake'
26
+ s.add_development_dependency 'rspec'
27
+ s.add_development_dependency 'rack-test'
62
28
  end
63
-
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
1
+ require_relative "spec_helper"
2
2
 
3
3
  describe "RackGeoip" do
4
4
  def app
@@ -14,7 +14,7 @@ describe "RackGeoip" do
14
14
  last_response.should be_ok
15
15
  last_response.body.should == 'Hello World'
16
16
  end
17
-
17
+
18
18
  # This makes sure that the middleware will return a 404 with some suggested usage
19
19
  # when the request is malformed
20
20
  it 'should return 404 when a geocode lookup request has malformed parameters' do
@@ -22,7 +22,7 @@ describe "RackGeoip" do
22
22
  last_response.status.should == 404
23
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
27
27
  it 'should return some json when a geocode lookup works' do
28
28
  get '/geocode/lookup?ip=8.8.8.8'
@@ -30,7 +30,7 @@ describe "RackGeoip" do
30
30
  json = JSON.parse(last_response.body)
31
31
  json.class.should == Hash
32
32
  end
33
-
33
+
34
34
  # This tests the actual geocode lookup
35
35
  it 'should return the city Mountain View when the provided IP lookup is for a googleplex' do
36
36
  get '/geocode/lookup?ip=8.8.8.8'
data/spec/spec_helper.rb CHANGED
@@ -1,18 +1,13 @@
1
- $LOAD_PATH.unshift(File.dirname(__FILE__))
2
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
- require 'rubygems'
4
- require 'json'
5
- require 'rack-geoip'
6
- require 'spec'
7
- require 'spec/autorun'
1
+ require 'rspec'
8
2
  require 'rack/test'
3
+ require 'rack/geoip'
9
4
 
10
- Spec::Runner.configure do |config|
5
+ RSpec.configure do |config|
11
6
  config.include Rack::Test::Methods
12
7
  end
13
8
 
14
9
  class BasicRackApp
15
10
  def call(env)
16
- [200, {'Content-Type' => 'text/plain'}, 'Hello World']
11
+ [200, {'Content-Type' => 'text/plain'}, ['Hello World']]
17
12
  end
18
- end
13
+ end
metadata CHANGED
@@ -1,79 +1,123 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rack-geoip
3
- version: !ruby/object:Gem::Version
4
- hash: 31
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 1
9
- - 2
10
- version: 0.1.2
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.1
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Chris Kraybill
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-01-03 00:00:00 -08:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- name: rspec
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
12
+ date: 2013-02-16 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rack
16
+ requirement: !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 13
30
- segments:
31
- - 1
32
- - 2
33
- - 9
34
- version: 1.2.9
35
- type: :development
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: geoip_city
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
39
23
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: geoip_city19
32
+ requirement: !ruby/object:Gem::Requirement
41
33
  none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- hash: 3
46
- segments:
47
- - 0
48
- version: "0"
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: 2.0.1
49
38
  type: :runtime
50
- version_requirements: *id002
51
- - !ruby/object:Gem::Dependency
52
- name: json
53
39
  prerelease: false
54
- requirement: &id003 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
55
41
  none: false
56
- requirements:
57
- - - ">="
58
- - !ruby/object:Gem::Version
59
- hash: 3
60
- segments:
61
- - 0
62
- version: "0"
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 2.0.1
46
+ - !ruby/object:Gem::Dependency
47
+ name: json
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
63
54
  type: :runtime
64
- version_requirements: *id003
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rake
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rspec
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: rack-test
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
65
110
  description: A rack middleware component that handles simple geoip lookups.
66
- email: ckraybill@gmail.com
111
+ email:
112
+ - ckraybill@gmail.com
67
113
  executables: []
68
-
69
114
  extensions: []
70
-
71
- extra_rdoc_files:
72
- - README
73
- - TODO
74
- files:
115
+ extra_rdoc_files: []
116
+ files:
75
117
  - .document
118
+ - .gitignore
76
119
  - COPYING
120
+ - Gemfile
77
121
  - README
78
122
  - Rakefile
79
123
  - TODO
@@ -82,44 +126,42 @@ files:
82
126
  - lib/rack-geoip.rb
83
127
  - lib/rack/geoip.rb
84
128
  - lib/rack/geoip/lookup.rb
129
+ - lib/rack/geoip/version.rb
85
130
  - rack-geoip.gemspec
86
131
  - spec/rack-geoip_spec.rb
87
132
  - spec/spec.opts
88
133
  - spec/spec_helper.rb
89
- has_rdoc: true
90
134
  homepage: http://github.com/ckraybill/rack-geoip
91
135
  licenses: []
92
-
93
136
  post_install_message:
94
137
  rdoc_options: []
95
-
96
- require_paths:
138
+ require_paths:
97
139
  - lib
98
- required_ruby_version: !ruby/object:Gem::Requirement
140
+ required_ruby_version: !ruby/object:Gem::Requirement
99
141
  none: false
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- hash: 3
104
- segments:
142
+ requirements:
143
+ - - ! '>='
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ segments:
105
147
  - 0
106
- version: "0"
107
- required_rubygems_version: !ruby/object:Gem::Requirement
148
+ hash: 851683759161573456
149
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
150
  none: false
109
- requirements:
110
- - - ">="
111
- - !ruby/object:Gem::Version
112
- hash: 3
113
- segments:
151
+ requirements:
152
+ - - ! '>='
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
155
+ segments:
114
156
  - 0
115
- version: "0"
157
+ hash: 851683759161573456
116
158
  requirements: []
117
-
118
159
  rubyforge_project:
119
- rubygems_version: 1.3.7
160
+ rubygems_version: 1.8.23
120
161
  signing_key:
121
162
  specification_version: 3
122
163
  summary: A rack middleware component that handles simple geoip lookups.
123
- test_files:
164
+ test_files:
124
165
  - spec/rack-geoip_spec.rb
166
+ - spec/spec.opts
125
167
  - spec/spec_helper.rb