geo_magic 0.2.3 → 0.2.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/geo_magic.gemspec +2 -2
- data/lib/geo_magic/geocode/geocoder.rb +14 -12
- data/spec/geo_magic/geocoder_spec.rb +1 -1
- metadata +4 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.3
|
1
|
+
0.2.3.1
|
data/geo_magic.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{geo_magic}
|
8
|
-
s.version = "0.2.3"
|
8
|
+
s.version = "0.2.3.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Kristian Mandrup"]
|
12
|
-
s.date = %q{2011-01-
|
12
|
+
s.date = %q{2011-01-24}
|
13
13
|
s.description = %q{Get IP and location data using freegeoip.net - can also calculate of distance between map points using haversine supporting multiple distance units}
|
14
14
|
s.email = %q{kmandrup@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -57,28 +57,28 @@ module GeoMagic
|
|
57
57
|
# Address
|
58
58
|
|
59
59
|
def street
|
60
|
-
thoroughfare["ThoroughfareName"]
|
60
|
+
thoroughfare["ThoroughfareName"] ? thoroughfare["ThoroughfareName"] : ""
|
61
61
|
end
|
62
62
|
|
63
63
|
def postal_code
|
64
|
-
locality["PostalCode"]["PostalCodeNumber"]
|
64
|
+
locality["PostalCode"] ? locality["PostalCode"]["PostalCodeNumber"] : ""
|
65
65
|
end
|
66
66
|
alias_method :zip, :postal_code
|
67
67
|
|
68
68
|
def city
|
69
|
-
subadm_api["SubAdministrativeAreaName"]
|
69
|
+
subadm_api["SubAdministrativeAreaName"] ? subadm_api["SubAdministrativeAreaName"] : ""
|
70
70
|
end
|
71
71
|
|
72
72
|
def state
|
73
|
-
adm_api["AdministrativeAreaName"]
|
73
|
+
adm_api["AdministrativeAreaName"] ? adm_api["AdministrativeAreaName"] : ""
|
74
74
|
end
|
75
75
|
|
76
76
|
def country_code
|
77
|
-
country_api["CountryNameCode"]
|
77
|
+
country_api["CountryNameCode"] ? country_api["CountryNameCode"] : ""
|
78
78
|
end
|
79
79
|
|
80
80
|
def country_name
|
81
|
-
country_api["CountryName"]
|
81
|
+
country_api["CountryName"] ? country_api["CountryName"] : ""
|
82
82
|
end
|
83
83
|
alias_method :country, :country_name
|
84
84
|
|
@@ -105,18 +105,20 @@ module GeoMagic
|
|
105
105
|
def thoroughfare
|
106
106
|
@thoroughfare ||= begin
|
107
107
|
thorough = [:subadm_api, :locality_api, :dependent_locality_api].select do |api|
|
108
|
-
send(api)
|
108
|
+
x = send(api)
|
109
|
+
x ? x["Thoroughfare"] : nil
|
109
110
|
end
|
110
|
-
send(thorough.first)["Thoroughfare"]
|
111
|
+
thorough.empty? ? {} : send(thorough.first)["Thoroughfare"]
|
111
112
|
end
|
112
113
|
end
|
113
114
|
|
114
115
|
def locality
|
115
116
|
@locality ||= begin
|
116
|
-
|
117
|
-
send(api)
|
118
|
-
|
119
|
-
|
117
|
+
loc = [:locality_api, :dependent_locality_api].select do |api|
|
118
|
+
x = send(api)
|
119
|
+
x ? x["PostalCode"] || x["LocalityName"] : nil
|
120
|
+
end
|
121
|
+
loc.empty? ? {} : send(loc.first)
|
120
122
|
end
|
121
123
|
end
|
122
124
|
|
@@ -19,7 +19,7 @@ describe "GeoMagic Geocoder" do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should create location and address hashes" do
|
22
|
-
location = @geocoder.instance.geocode "
|
22
|
+
location = @geocoder.instance.geocode "Pilotystrasse 11, munich, Germany"
|
23
23
|
p location.location_hash
|
24
24
|
p location.address_hash
|
25
25
|
end
|
metadata
CHANGED
@@ -6,7 +6,8 @@ version: !ruby/object:Gem::Version
|
|
6
6
|
- 0
|
7
7
|
- 2
|
8
8
|
- 3
|
9
|
-
|
9
|
+
- 1
|
10
|
+
version: 0.2.3.1
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Kristian Mandrup
|
@@ -14,7 +15,7 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2011-01-
|
18
|
+
date: 2011-01-24 00:00:00 +01:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
@@ -192,7 +193,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
192
193
|
requirements:
|
193
194
|
- - ">="
|
194
195
|
- !ruby/object:Gem::Version
|
195
|
-
hash:
|
196
|
+
hash: 3152749513202391524
|
196
197
|
segments:
|
197
198
|
- 0
|
198
199
|
version: "0"
|