geoip-db 2013.05

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
1
+ data/GeoLiteCity.dat
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,16 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ geoip-db (2013.05)
5
+ geoip
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ geoip (1.1.2)
11
+
12
+ PLATFORMS
13
+ ruby
14
+
15
+ DEPENDENCIES
16
+ geoip-db!
@@ -0,0 +1,32 @@
1
+ # GeoIP::DB
2
+
3
+ Combining the geoip gem and the database from MaxMind, this gem offers IP Geolocation in an easy to deploy package.
4
+
5
+ ## Usage
6
+
7
+ ```ruby
8
+ require 'geoip-db'
9
+
10
+ geoip = GeoIP::DB.instance
11
+ geoip.city('github.com')
12
+ #=> ["github.com", "207.97.227.239", "US", "USA", "United States", "NA", "CA", "San Francisco", "94110", 37.7484, -122.4156, 807, 415, "America/Los_Angeles"]
13
+ ```
14
+
15
+ `GeoIP::DB.instance` returns an instance of `GeoIP` initialized with a copy of the city database. See
16
+ [geoip](https://github.com/cjheath/geoip) for further usage.
17
+
18
+
19
+ ## Packaging
20
+
21
+ 1. `rake update_database`
22
+ 2. Update gemspec
23
+ 3. `gem build geoip-db.gemspec`
24
+
25
+ ## Versioning
26
+
27
+ The version represents the year and month that the database was updated. Maxmind updates the database on the first
28
+ Tuesday of each month.
29
+
30
+ ---
31
+
32
+ This product includes GeoLite data created by MaxMind, available from [http://www.maxmind.com](http://www.maxmind.com).
@@ -0,0 +1,26 @@
1
+ require 'uri'
2
+ require 'net/http'
3
+ require 'zlib'
4
+
5
+ require_relative 'lib/geoip-db'
6
+
7
+ GZIP_WBITS = (Zlib::MAX_WBITS + 32)
8
+
9
+ task :update_database do
10
+ url = GeoIP::DB::URL
11
+
12
+ Net::HTTP.start(url.host, url.port) do |http|
13
+ request = Net::HTTP::Get.new(url.to_s)
14
+ zlib = Zlib::Inflate.new(GZIP_WBITS)
15
+
16
+ File.open(GeoIP::DB::PATH, 'w+') do |out|
17
+ http.request(request) do |response|
18
+ response.read_body do |body_chunk|
19
+ out << zlib.inflate(body_chunk)
20
+ end
21
+ end
22
+ end
23
+
24
+ zlib.finish
25
+ end
26
+ end
@@ -0,0 +1,21 @@
1
+ Gem::Specification.new do |s|
2
+ # required
3
+ s.name = "geoip-db"
4
+ s.version = '2013.05'
5
+ s.date = '2013-05-08'
6
+ s.summary = "Packaged IP Geolocation Database. This product includes GeoLite data created by MaxMind, available from http://www.maxmind.com."
7
+ s.files = [*`git ls-files`.split, *Dir['data/*']]
8
+
9
+ # optional
10
+ s.description = <<-EOS
11
+ Combining the geoip gem and the database from MaxMind, this gem offers IP Geolocation in an easy to deploy package.
12
+
13
+ This product includes GeoLite data created by MaxMind, available from http://www.maxmind.com."
14
+ EOS
15
+ s.license = 'MIT'
16
+ s.author = 'TJ Singleton'
17
+ s.email = 'tjsingleton@me.com'
18
+ s.homepage = 'https://github.com/tjsingleton/geoip-db'
19
+
20
+ s.add_dependency 'geoip'
21
+ end
@@ -0,0 +1,12 @@
1
+ require 'geoip'
2
+
3
+ class GeoIP
4
+ module DB
5
+ URL = URI.parse('http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz')
6
+ PATH = File.expand_path(File.join(File.dirname(__FILE__), '..', 'data', 'GeoLiteCity.dat'))
7
+
8
+ def self.instance
9
+ Thread.current[:geoip] ||= GeoIP.new(PATH)
10
+ end
11
+ end
12
+ end
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: geoip-db
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: '2013.05'
6
+ platform: ruby
7
+ authors:
8
+ - TJ Singleton
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-05-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: geoip
16
+ version_requirements: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ requirement: !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ! '>='
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ type: :runtime
29
+ prerelease: false
30
+ description: ! 'Combining the geoip gem and the database from MaxMind, this gem offers
31
+ IP Geolocation in an easy to deploy package.
32
+
33
+
34
+ This product includes GeoLite data created by MaxMind, available from http://www.maxmind.com."
35
+
36
+ '
37
+ email: tjsingleton@me.com
38
+ executables: []
39
+ extensions: []
40
+ extra_rdoc_files: []
41
+ files:
42
+ - .gitignore
43
+ - Gemfile
44
+ - Gemfile.lock
45
+ - README.md
46
+ - Rakefile
47
+ - geoip-db.gemspec
48
+ - lib/geoip-db.rb
49
+ - data/GeoLiteCity.dat
50
+ homepage: https://github.com/tjsingleton/geoip-db
51
+ licenses:
52
+ - MIT
53
+ post_install_message:
54
+ rdoc_options: []
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ requirements: []
70
+ rubyforge_project:
71
+ rubygems_version: 1.8.25
72
+ signing_key:
73
+ specification_version: 3
74
+ summary: Packaged IP Geolocation Database. This product includes GeoLite data created
75
+ by MaxMind, available from http://www.maxmind.com.
76
+ test_files: []
77
+ has_rdoc: