geomancer 0.6.1 → 0.7.0
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
- checksums.yaml.gz.asc +12 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +12 -0
- data/Rakefile +4 -0
- data/geomancer.gemspec +1 -0
- data/lib/geomancer/version.rb +1 -1
- data/lib/geomancer.rb +31 -1
- data/spec/lat_and_long_spec.rb +36 -0
- data/spec/zip_code_spec.rb +19 -0
- data.tar.gz.asc +12 -0
- metadata +32 -12
- metadata.gz.asc +12 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: eefb06205d0d05df1e1687cef51d978ee4f94e3c
|
|
4
|
+
data.tar.gz: d9ee2fba66a67084baed6120f011a1479a16c0d7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e6f34ffce78af9b62b245536dbd2c103987e014bc40067589908eb0411295ea6720db68fb4723b80de68c582e72a1e70b09a54bdb756459689fd5963b0700563
|
|
7
|
+
data.tar.gz: 4e869fb98950958cfa250f66283783e1a204aee4d6c71cbcfb4731d89669102baea2196b49478afab06bf3e6a5e3b49bd279ce840993f7da2593e36a5b9ac9f2
|
checksums.yaml.gz.asc
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
-----BEGIN PGP SIGNATURE-----
|
|
2
|
+
Version: GnuPG/MacGPG2 v2.0.22 (Darwin)
|
|
3
|
+
Comment: GPGTools - http://gpgtools.org
|
|
4
|
+
|
|
5
|
+
iQEcBAABCgAGBQJTclGPAAoJEP5F5V2hilTW9lEH/j8VyHMYPbNXg4Biss/nWxvN
|
|
6
|
+
bc2ezN1WTWHU4l95Ssoj0NPat2hqyF1aEQkV63u6C5Dk4y+U0wKHH+hA8rj/K4SS
|
|
7
|
+
9IusNj9AJg38hzYcoSJMpN1+Yl8unU6mb7ZerX7uA+fXtp2y2gqzMgQq/aZsRIjj
|
|
8
|
+
LPv0zscXs/1EdOz6XCCxlynYLJJPwspJjlq+W0aoGEQozvmFZFFgtHcxshftkvXe
|
|
9
|
+
DBybusWom/x7U5CJkS+oTyYbfd28pEg10OlaCPcMfqKdQNaxdz1+U4SrBgLXpEQ1
|
|
10
|
+
PF9R325wAuDfeVHZQe28k7LsuRHjd6QuxrmE/2p5RCdLNW/i4KYBmIWnhR3ZQ0Q=
|
|
11
|
+
=iGB2
|
|
12
|
+
-----END PGP SIGNATURE-----
|
data/.ruby-gemset
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
geomancer
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ruby-2.1.2
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
0.7.0 - 2014-05-13
|
|
2
|
+
==================
|
|
3
|
+
|
|
4
|
+
* If an address looks like a zip code, don't ever do 'real'
|
|
5
|
+
geolocation and fall back to the static lookup.
|
|
6
|
+
|
|
7
|
+
* If an address looks something like "latitude: 41.9040, longitude:
|
|
8
|
+
12.4530" just extract the numbers and trust that's what we want
|
|
9
|
+
instead of 'real' geolocation.
|
|
10
|
+
|
|
11
|
+
* Support :cache option to save results: `cache => Redis.new`
|
|
12
|
+
|
|
1
13
|
0.6.1 - 2014-04-09
|
|
2
14
|
==================
|
|
3
15
|
|
data/Rakefile
CHANGED
data/geomancer.gemspec
CHANGED
data/lib/geomancer/version.rb
CHANGED
data/lib/geomancer.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require "geomancer/version"
|
|
2
|
+
require "geomancer/zip_code"
|
|
2
3
|
|
|
3
4
|
module Geomancer
|
|
4
5
|
# Your code goes here...
|
|
@@ -11,11 +12,40 @@ module Geomancer
|
|
|
11
12
|
require_relative './geomancer/zip_code'
|
|
12
13
|
else
|
|
13
14
|
require 'geocoder'
|
|
14
|
-
|
|
15
|
+
|
|
16
|
+
cache = opts.delete(:cache)
|
|
17
|
+
geocoder_config = { :engine => opts }
|
|
18
|
+
geocoder_config[:cache] = cache if cache
|
|
19
|
+
|
|
20
|
+
Geocoder.configure(geocoder_config)
|
|
15
21
|
end
|
|
16
22
|
end
|
|
17
23
|
|
|
24
|
+
LAT_LONG_RE = /lat(itude)?:\s+(?<latitude>[\d\.\-]+)[\s,]+long(itude)?:\s+(?<longitude>[\d\.\-]+)/
|
|
25
|
+
|
|
26
|
+
def self.extract_lat_and_long address
|
|
27
|
+
matches = LAT_LONG_RE.match(address)
|
|
28
|
+
|
|
29
|
+
return nil if !matches
|
|
30
|
+
|
|
31
|
+
latitude = matches["latitude"]
|
|
32
|
+
longitude = matches["longitude"]
|
|
33
|
+
|
|
34
|
+
return nil if !(latitude && longitude)
|
|
35
|
+
|
|
36
|
+
return {:latitude => latitude.to_f, :longitude => longitude.to_f}
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def self.zip_code_only? address
|
|
40
|
+
address.match(/^\d\d\d\d\d(?:-\d\d\d\d)?$/)
|
|
41
|
+
end
|
|
42
|
+
|
|
18
43
|
def self.geolocate address
|
|
44
|
+
return Geomancer::ZipCode.geolocate(address) if zip_code_only?(address)
|
|
45
|
+
|
|
46
|
+
lat_and_long = extract_lat_and_long(address)
|
|
47
|
+
return lat_and_long if lat_and_long
|
|
48
|
+
|
|
19
49
|
if !@engine
|
|
20
50
|
warn("No configuration provided. Defaulting to zip code geolocator")
|
|
21
51
|
configure(:zip_code)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require 'geomancer'
|
|
2
|
+
|
|
3
|
+
describe Geomancer do
|
|
4
|
+
it "extracts basic latitude" do
|
|
5
|
+
Geomancer.extract_lat_and_long("latitude: 41.9040 longitude: 12.4530").should_not be_nil
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
it "extracts abbreviated latitude" do
|
|
9
|
+
Geomancer.extract_lat_and_long("lat: 41.9040 long: 12.4530").should_not be_nil
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "extracts comma separated stuff" do
|
|
13
|
+
Geomancer.extract_lat_and_long("lat: 41.9040, long: 12.4530").should_not be_nil
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "doesn't extract only latitude" do
|
|
17
|
+
Geomancer.extract_lat_and_long("lat: 41.9040").should be_nil
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "doesn't extract only longitude" do
|
|
21
|
+
Geomancer.extract_lat_and_long("longitude: 41.9040").should be_nil
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "extracts actual numbers" do
|
|
25
|
+
lat_and_long = Geomancer.extract_lat_and_long("lat: 41.9040, long: 12.4530")
|
|
26
|
+
lat_and_long[:latitude].should be_a Float
|
|
27
|
+
lat_and_long[:longitude].should be_a Float
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "extracts negative numbers" do
|
|
31
|
+
lat_and_long = Geomancer.extract_lat_and_long("lat: 37.2350, long: -115.8111")
|
|
32
|
+
lat_and_long[:longitude].should == -115.8111
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'geomancer'
|
|
2
|
+
|
|
3
|
+
describe Geomancer do
|
|
4
|
+
context 'zips' do
|
|
5
|
+
["15217", "15217-3343"].each do |zip|
|
|
6
|
+
it "detects #{zip}" do
|
|
7
|
+
Geomancer.zip_code_only?(zip).should be_true
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
context 'non-zips' do
|
|
13
|
+
["123456", "123456-22"].each do |nonzip|
|
|
14
|
+
it "doesn't detect #{nonzip}" do
|
|
15
|
+
Geomancer.zip_code_only?(nonzip).should be_false
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
data.tar.gz.asc
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
-----BEGIN PGP SIGNATURE-----
|
|
2
|
+
Version: GnuPG/MacGPG2 v2.0.22 (Darwin)
|
|
3
|
+
Comment: GPGTools - http://gpgtools.org
|
|
4
|
+
|
|
5
|
+
iQEcBAABCgAGBQJTclGPAAoJEP5F5V2hilTWfIgH/3g+u5l6XWzkALF4zOxzbu0Q
|
|
6
|
+
9Nxz/beoG6ToP5gN9IBHLKDKzBMQrnLyzSIkRLvnnT+M0xVFWUEBKVS5wpU1zJs0
|
|
7
|
+
wA2jSkC1k8SqbxW5kDovr47S8GhY3ytJLwZBMorGBURklF53H4UUiqkTNSJqktuy
|
|
8
|
+
WL/X39xEgTdl1EQmjqdWPJV4wEsLlRBgw7sDGKILVn7Xh94Nqb4au9tryqQQqs5j
|
|
9
|
+
aS8UyDAOXtzQRHOU3kXgOeuAdDXdv5S8891gg2HdLO3WolnAEoh/VoMzcAwOQnuX
|
|
10
|
+
8u/XzXC3HKAFR5as7fA3UIhDu6IYeQYJwtDQIorkyn9nEUaBRakvwathbA6DfWE=
|
|
11
|
+
=8YHO
|
|
12
|
+
-----END PGP SIGNATURE-----
|
metadata
CHANGED
|
@@ -1,55 +1,69 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: geomancer
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Grant T. Olson
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-
|
|
11
|
+
date: 2014-05-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: geocoder
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- -
|
|
17
|
+
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
19
|
version: '0'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
|
-
- -
|
|
24
|
+
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: '0'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: bundler
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
|
-
- - ~>
|
|
31
|
+
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
33
|
version: '1.5'
|
|
34
34
|
type: :development
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
|
-
- - ~>
|
|
38
|
+
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
40
|
version: '1.5'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: rake
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
|
-
- -
|
|
45
|
+
- - ">="
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
47
|
version: '0'
|
|
48
48
|
type: :development
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
|
-
- -
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rspec
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
53
67
|
- !ruby/object:Gem::Version
|
|
54
68
|
version: '0'
|
|
55
69
|
description:
|
|
@@ -59,7 +73,9 @@ executables: []
|
|
|
59
73
|
extensions: []
|
|
60
74
|
extra_rdoc_files: []
|
|
61
75
|
files:
|
|
62
|
-
- .gitignore
|
|
76
|
+
- ".gitignore"
|
|
77
|
+
- ".ruby-gemset"
|
|
78
|
+
- ".ruby-version"
|
|
63
79
|
- CHANGELOG.md
|
|
64
80
|
- Gemfile
|
|
65
81
|
- LICENSE.txt
|
|
@@ -70,6 +86,8 @@ files:
|
|
|
70
86
|
- lib/geomancer/version.rb
|
|
71
87
|
- lib/geomancer/zip_code.rb
|
|
72
88
|
- lib/geomancer/zips.rb
|
|
89
|
+
- spec/lat_and_long_spec.rb
|
|
90
|
+
- spec/zip_code_spec.rb
|
|
73
91
|
homepage: ''
|
|
74
92
|
licenses:
|
|
75
93
|
- MIT
|
|
@@ -80,12 +98,12 @@ require_paths:
|
|
|
80
98
|
- lib
|
|
81
99
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
82
100
|
requirements:
|
|
83
|
-
- -
|
|
101
|
+
- - ">="
|
|
84
102
|
- !ruby/object:Gem::Version
|
|
85
103
|
version: '0'
|
|
86
104
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
105
|
requirements:
|
|
88
|
-
- -
|
|
106
|
+
- - ">="
|
|
89
107
|
- !ruby/object:Gem::Version
|
|
90
108
|
version: '0'
|
|
91
109
|
requirements: []
|
|
@@ -94,4 +112,6 @@ rubygems_version: 2.2.2
|
|
|
94
112
|
signing_key:
|
|
95
113
|
specification_version: 4
|
|
96
114
|
summary: Simple wrapper around various geolocation services
|
|
97
|
-
test_files:
|
|
115
|
+
test_files:
|
|
116
|
+
- spec/lat_and_long_spec.rb
|
|
117
|
+
- spec/zip_code_spec.rb
|
metadata.gz.asc
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
-----BEGIN PGP SIGNATURE-----
|
|
2
|
+
Version: GnuPG/MacGPG2 v2.0.22 (Darwin)
|
|
3
|
+
Comment: GPGTools - http://gpgtools.org
|
|
4
|
+
|
|
5
|
+
iQEcBAABCgAGBQJTclGPAAoJEP5F5V2hilTWIWYH/3PCruEHKd9uZnSPFO+C1Q+3
|
|
6
|
+
ejuzn/lgyg8L9de4XPOVcRH7Xn6f81NBTQHhLOobhNoI/5A+KxgThuy1RsSGDoLu
|
|
7
|
+
EqK1qzNCyYpuIwhlhebE6ya4W11UPrVYfPIYNf+QZcIiWHihRfoH1tu7ePw56VEi
|
|
8
|
+
mmolO3SUxT3CRI1qR966ycZTtauGT6OdLt9nPpgpgjXjBAN0l4qFrtK1RKdI+mIZ
|
|
9
|
+
DzauuMLQmosFbSnjRhAAb+dxXiGCuco02mTG/1zWAoM7Gk4JB35QySmvvbmBUb/d
|
|
10
|
+
6jwskjtGTfyLWlQ8+W9Mfn9fVWr2jy9zZahjDTI58p7vUxYy4uEYfB0nv91gE18=
|
|
11
|
+
=mR7X
|
|
12
|
+
-----END PGP SIGNATURE-----
|