geolocal 0.9 → 0.9.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.
- checksums.yaml +4 -4
- data/README.md +26 -13
- data/Rakefile +1 -0
- data/lib/geolocal/tasks.rb +29 -0
- data/lib/geolocal/version.rb +1 -1
- metadata +3 -5
- data/lib/geolocal.rb +0 -5
- data/lib/geolocal/railtie.rb +0 -12
- data/lib/tasks/geolocal.rake +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f7cad64f85f04f0bd9971651e2470ad2f344640
|
4
|
+
data.tar.gz: 3e309a0a2464feb9c2431e34b2aacddfea18635c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9735c98cb5e6268510d41d792c9dcfb88428d4123f69855f74e03f2c48e133fdac101d6ee7a9dd6c3a90093f5bd0fa7b41a96b9a16508e1fa2f90282f1c57d8
|
7
|
+
data.tar.gz: 04cee72abe241e39642c681b87f003a6ab963d30d16182e1f206c438b1cdf5ec51711c1b0b4618deb462232a714c667856bff656fe174c404c7ffadc58c71148
|
data/README.md
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
# Geolocal
|
2
2
|
|
3
3
|
Geocode IP addresses with a single Ruby if statement.
|
4
|
-
No network access, no context switches, no delay
|
5
|
-
`Geolocal.in_spain?(request.remote_ip)`.
|
6
|
-
|
4
|
+
No network access, no context switches, no delay,
|
5
|
+
just one low-calorie lookup like `Geolocal.in_spain?(request.remote_ip)`.
|
6
|
+
|
7
|
+
500,000 individual lookups per second is fairly typical performance.
|
7
8
|
|
8
9
|
|
9
10
|
## Installation
|
@@ -14,17 +15,23 @@ Add this line to your Gemfile:
|
|
14
15
|
gem 'geolocal'
|
15
16
|
```
|
16
17
|
|
18
|
+
And this line to your Rakefile:
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
require 'geolocal/tasks'
|
22
|
+
```
|
17
23
|
|
18
24
|
## Usage
|
19
25
|
|
20
26
|
If you're using Rails, run `rails generate geolocal` to create the configuration file.
|
21
27
|
Otherwise, crib from [config/geolocal.rb](https://github.com/bronson/geolocal/tree/master/config/geolocal.rb).
|
22
28
|
|
23
|
-
The
|
29
|
+
The configuration file describes the ranges you're interested in.
|
24
30
|
Here's an example:
|
25
31
|
|
26
32
|
```ruby
|
27
33
|
require 'geolocal/configuration'
|
34
|
+
|
28
35
|
Geolocal.configure do |config|
|
29
36
|
config.countries = {
|
30
37
|
us: 'US',
|
@@ -40,6 +47,7 @@ creates the desired methods:
|
|
40
47
|
|
41
48
|
```ruby
|
42
49
|
require 'geolocal'
|
50
|
+
|
43
51
|
Geolocal.in_us?(request.remote_ip)
|
44
52
|
Geolocal.in_spain?('2a05:af06::') # optional IPv6 support
|
45
53
|
Geolocal.in_central_america?('200.16.66.0')
|
@@ -127,21 +135,26 @@ ruby contrib/benchmark-continents.rb
|
|
127
135
|
|
128
136
|
## Alternatives
|
129
137
|
|
130
|
-
The [Geocoder gem](https://github.com/alexreisner/geocoder) offers
|
138
|
+
The [Geocoder gem](https://github.com/alexreisner/geocoder) also offers
|
131
139
|
[local database services](https://github.com/alexreisner/geocoder#ip-address-local-database-services).
|
132
140
|
It offers more options and more providers than Geolocal, but it's a little more complex and not as fast.
|
133
|
-
Geolocal also doesn't add any dependencies to your deploy, potentially making it easier to get working
|
141
|
+
Geolocal also doesn't add any dependencies to your deploy, potentially making it easier to get it working
|
134
142
|
with oddball environments like Heroku.
|
135
143
|
|
136
144
|
|
137
|
-
##
|
145
|
+
## Roadmap
|
146
|
+
|
147
|
+
* Add support for cities
|
148
|
+
* other sources for this data? [MainFacts](http://mainfacts.com/ip-address-space-addresses), [NirSoft](http://www.nirsoft.net/countryip/)
|
149
|
+
Also maybe allow providers to accept their own options?
|
150
|
+
* release 1.0!
|
151
|
+
* Detect nesting? Putting in_eu?, in_europe?, and in_france? in your config generates a lot of redundant overlap.
|
152
|
+
* Add support for for-pay features like lat/lon and timezones?
|
153
|
+
|
154
|
+
|
155
|
+
## License
|
138
156
|
|
139
|
-
-
|
140
|
-
- [ ] other sources for this data? [MainFacts](http://mainfacts.com/ip-address-space-addresses), [NirSoft](http://www.nirsoft.net/countryip/)
|
141
|
-
Also maybe allow providers to accept their own options?
|
142
|
-
- [ ] release 1.0!
|
143
|
-
- [ ] Detect nesting? Putting in_eu?, in_europe?, and in_france? generates a lot of redundant overlap.
|
144
|
-
- [ ] Add support for for-pay features like lat/lon and timezones?
|
157
|
+
Pain-free MIT. Downloaded data is copyrighted by the provider you downloaded it from.
|
145
158
|
|
146
159
|
|
147
160
|
## Contributing
|
data/Rakefile
CHANGED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'geolocal/configuration'
|
2
|
+
|
3
|
+
namespace :geolocal do
|
4
|
+
def configured_provider
|
5
|
+
# we use this file by default
|
6
|
+
config='config/geolocal'
|
7
|
+
|
8
|
+
# but you can specify the config file on the command line:
|
9
|
+
# `rake geolocal config=contrib/continents`
|
10
|
+
config=ENV['config'] if ENV['config']
|
11
|
+
puts "loading geolocal configuration from #{config}"
|
12
|
+
require './' + config
|
13
|
+
|
14
|
+
Geolocal.configuration.load_provider.new
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Downloads the most recent geocoding information"
|
18
|
+
task :download do
|
19
|
+
configured_provider.download
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "Updates your geocoding statements to use new data."
|
23
|
+
task :update => :download do
|
24
|
+
configured_provider.update
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
desc "shorthand for running geolocal:update"
|
29
|
+
task geolocal: 'geolocal:update'
|
data/lib/geolocal/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geolocal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Bronson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -89,14 +89,12 @@ files:
|
|
89
89
|
- lib/generators/geolocal/USAGE
|
90
90
|
- lib/generators/geolocal/geolocal_generator.rb
|
91
91
|
- lib/generators/geolocal/templates/geolocal.rb
|
92
|
-
- lib/geolocal.rb
|
93
92
|
- lib/geolocal/configuration.rb
|
94
93
|
- lib/geolocal/provider/base.rb
|
95
94
|
- lib/geolocal/provider/db_ip.rb
|
96
95
|
- lib/geolocal/provider/test.rb
|
97
|
-
- lib/geolocal/
|
96
|
+
- lib/geolocal/tasks.rb
|
98
97
|
- lib/geolocal/version.rb
|
99
|
-
- lib/tasks/geolocal.rake
|
100
98
|
- spec/data/dbip-country.csv.gz
|
101
99
|
- spec/geolocal/configuration_spec.rb
|
102
100
|
- spec/geolocal/provider/base_spec.rb
|
data/lib/geolocal.rb
DELETED
data/lib/geolocal/railtie.rb
DELETED
data/lib/tasks/geolocal.rake
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
# Provides geolocal's rake tasks.
|
2
|
-
|
3
|
-
# we use this file by default
|
4
|
-
config='config/geolocal'
|
5
|
-
|
6
|
-
# but you can specify the config file on the command line:
|
7
|
-
# `rake geolocal config=contrib/continents`
|
8
|
-
config=ENV['config'] if ENV['config']
|
9
|
-
puts "loading geolocal configuration from #{config}"
|
10
|
-
require './' + config
|
11
|
-
|
12
|
-
|
13
|
-
namespace :geolocal do
|
14
|
-
desc "Downloads the most recent geocoding information"
|
15
|
-
task :download do
|
16
|
-
Geolocal.configuration.load_provider.new.download
|
17
|
-
end
|
18
|
-
|
19
|
-
desc "Updates your geocoding statements to use new data."
|
20
|
-
task :update => :download do
|
21
|
-
Geolocal.configuration.load_provider.new.update
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
desc "shorthand for running geolocal:update"
|
26
|
-
task geolocal: 'geolocal:update'
|