geocoder 1.4.8 → 1.4.9

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of geocoder might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 854db8cc60efe7a71d336d5001d509a69e1abd13
4
- data.tar.gz: e75d9237cd4fc8399b19308434bca339e2a538c1
3
+ metadata.gz: 81f22c128760be6a86ad082425c44dc7629b4dea
4
+ data.tar.gz: 49b92dcdc5b815522f9ff85cc1cfbe7b347659fe
5
5
  SHA512:
6
- metadata.gz: b10a62001c292e4829aa71e44846c8d2a3272095de360ba09b8cb1469692158bd4a8b0745053433b316e60edf6c7720487c45f9cea303067d44c8d2883b65f6d
7
- data.tar.gz: 0b6f87527cf3fa4034b080423a3c195a56c34de80cc3069b103710a14af562e46e446da2e65fbb2f7df62e424be9e6623924f4087b343767617ebb0bfa091be3
6
+ metadata.gz: e8f78f3018bc36b0012d17891a1f11ee903b805b217ddee7382cc8aee396f6852ef802b38e8dbf4e16b5de2db358fbfedfc5a6c8a272831def08015a121d368d
7
+ data.tar.gz: ce136edcfad4e4e199d04e27c621e55806d9966a98c918ce9a1b8e847c4eb137770bdfb03daa09c57db38acd0a0a2169831fc42fae64c397ab16dbf32af0cc4a
@@ -3,6 +3,11 @@ Changelog
3
3
 
4
4
  Major changes to Geocoder for each release. Please see the Git log for complete list of changes.
5
5
 
6
+ 1.4.9 (2018 May 27)
7
+ -------------------
8
+ * Fix regression in :geoip2 lookup.
9
+ * Add support for Postcodes.io lookup (thanks github.com/sledge909).
10
+
6
11
  1.4.8 (2018 May 21)
7
12
  -------------------
8
13
  * Change default IP address lookup from :freegeoip to :ipinfo_io.
data/README.md CHANGED
@@ -703,7 +703,18 @@ Data Science Toolkit provides an API whose response format is like Google's but
703
703
  * **Terms of Service**: http://wiki.geoportail.lu/doku.php?id=en:mcg_1
704
704
  * **Limitations**: ?
705
705
 
706
- #### PostcodeAnywhere Uk (`:postcode_anywhere_uk`)
706
+ #### Postcodes.io (`:postcodes_io`)
707
+
708
+ * **API key**: none
709
+ * **Quota**: ?
710
+ * **Region**: UK
711
+ * **SSL support**: yes
712
+ * **Languages**: English
713
+ * **Documentation**: http://postcodes.io/docs
714
+ * **Terms of Service**: ?
715
+ * **Limitations**: UK postcodes only
716
+
717
+ #### PostcodeAnywhere UK (`:postcode_anywhere_uk`)
707
718
 
708
719
  This uses the PostcodeAnywhere UK Geocode service, this will geocode any string from UK postcode, placename, point of interest or location.
709
720
 
@@ -712,7 +723,7 @@ This uses the PostcodeAnywhere UK Geocode service, this will geocode any string
712
723
  * **Region**: UK
713
724
  * **SSL support**: yes
714
725
  * **Languages**: English
715
- * **Documentation**: [http://www.postcodeanywhere.co.uk/Support/WebService/Geocoding/UK/Geocode/2/](http://www.postcodeanywhere.co.uk/Support/WebService/Geocoding/UK/Geocode/2/)
726
+ * **Documentation**: http://www.postcodeanywhere.co.uk/Support/WebService/Geocoding/UK/Geocode/2/
716
727
  * **Terms of Service**: ?
717
728
  * **Limitations**: ?
718
729
  * **Notes**: To use PostcodeAnywhere you must include an API key: `Geocoder.configure(:lookup => :postcode_anywhere_uk, :api_key => 'your_api_key')`.
@@ -48,6 +48,7 @@ module Geocoder
48
48
  :smarty_streets,
49
49
  :okf,
50
50
  :postcode_anywhere_uk,
51
+ :postcodes_io,
51
52
  :geoportail_lu,
52
53
  :ban_data_gouv_fr,
53
54
  :test,
@@ -0,0 +1,28 @@
1
+ require 'geocoder/lookups/base'
2
+ require 'geocoder/results/postcodes_io'
3
+
4
+ module Geocoder::Lookup
5
+ class PostcodesIo < Base
6
+ def name
7
+ 'Postcodes.io'
8
+ end
9
+
10
+ def query_url(query)
11
+ str = query.sanitized_text.gsub(/\s/, '')
12
+ format('%s://%s/%s', protocol, 'api.postcodes.io/postcodes', str)
13
+ end
14
+
15
+ def supported_protocols
16
+ [:https]
17
+ end
18
+
19
+ private
20
+
21
+ def results(query)
22
+ response = fetch_data(query)
23
+ return [] if response.nil? || response['status'] != 200 || response.empty?
24
+
25
+ [response['result']]
26
+ end
27
+ end
28
+ end
@@ -62,6 +62,10 @@ module Geocoder
62
62
  @language ||= default_language
63
63
  end
64
64
 
65
+ def data
66
+ @data.to_hash
67
+ end
68
+
65
69
  private
66
70
 
67
71
  def default_language
@@ -0,0 +1,40 @@
1
+ require 'geocoder/results/base'
2
+
3
+ module Geocoder::Result
4
+ class PostcodesIo < Base
5
+
6
+ def coordinates
7
+ [@data['latitude'].to_f, @data['longitude'].to_f]
8
+ end
9
+
10
+ def quality
11
+ @data['quality']
12
+ end
13
+
14
+ def postal_code
15
+ @data['postcode']
16
+ end
17
+ alias address postal_code
18
+
19
+ def city
20
+ @data['admin_ward']
21
+ end
22
+
23
+ def county
24
+ @data['admin_county']
25
+ end
26
+ alias state county
27
+
28
+ def state_code
29
+ @data['codes']['admin_county']
30
+ end
31
+
32
+ def country
33
+ 'United Kingdom'
34
+ end
35
+
36
+ def country_code
37
+ 'UK'
38
+ end
39
+ end
40
+ end
@@ -1,3 +1,3 @@
1
1
  module Geocoder
2
- VERSION = "1.4.8"
2
+ VERSION = "1.4.9"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geocoder
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.8
4
+ version: 1.4.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Reisner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-21 00:00:00.000000000 Z
11
+ date: 2018-05-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Provides object geocoding (by street or IP address), reverse geocoding
14
14
  (coordinates to street address), distance queries for ActiveRecord and Mongoid,
@@ -88,6 +88,7 @@ files:
88
88
  - lib/geocoder/lookups/pickpoint.rb
89
89
  - lib/geocoder/lookups/pointpin.rb
90
90
  - lib/geocoder/lookups/postcode_anywhere_uk.rb
91
+ - lib/geocoder/lookups/postcodes_io.rb
91
92
  - lib/geocoder/lookups/smarty_streets.rb
92
93
  - lib/geocoder/lookups/telize.rb
93
94
  - lib/geocoder/lookups/test.rb
@@ -140,6 +141,7 @@ files:
140
141
  - lib/geocoder/results/pickpoint.rb
141
142
  - lib/geocoder/results/pointpin.rb
142
143
  - lib/geocoder/results/postcode_anywhere_uk.rb
144
+ - lib/geocoder/results/postcodes_io.rb
143
145
  - lib/geocoder/results/smarty_streets.rb
144
146
  - lib/geocoder/results/telize.rb
145
147
  - lib/geocoder/results/test.rb