hl-geocoder 0.1.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 +7 -0
- data/lib/geocoder.rb +28 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0ef5859d418c92b6eb30aefa3cc5e6fa5f820a5a
|
4
|
+
data.tar.gz: 059c041c0660c167e89d0bb89d785277afd9149e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 80946b14d44d5ebeb6b362266a1fcd463162f098062f23e50d667d37f3a9fc8f85724397f645e49bb542bbebf8400fc9e93ba2ca111f681e841b917d878a8486
|
7
|
+
data.tar.gz: 42030140943f644b9e8f731bd779de722ec0e0a8fe1882f838ecd9417530d60ef8d56526b086b1c4e656cc4f438b21ca4963896ca3c249cff09fab6d82d79383
|
data/lib/geocoder.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'uri'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
class Geocoder
|
6
|
+
|
7
|
+
@@BASE_URL = 'https://maps.googleapis.com/maps/api/geocode/json'
|
8
|
+
@api_key = ''
|
9
|
+
|
10
|
+
def initialize(key)
|
11
|
+
@api_key = key
|
12
|
+
end
|
13
|
+
|
14
|
+
def fetch(key, val)
|
15
|
+
# Replace spaces with %20. Otherwise, URI will be invalid.
|
16
|
+
val.gsub! ' ', '%20'
|
17
|
+
JSON.parse(Net::HTTP.get(URI.parse("#{@@BASE_URL}?key=#{@api_key}&#{key}=#{val}")))["results"][0]
|
18
|
+
end
|
19
|
+
|
20
|
+
def geocode(address)
|
21
|
+
fetch('address', address)
|
22
|
+
end
|
23
|
+
|
24
|
+
def reverse_geocode(lat, lng)
|
25
|
+
fetch('latlng', "#{lat},#{lng}")
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hl-geocoder
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Erik Boesen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-11-03 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Light library to make requests to Google Maps's Geocoding API.
|
14
|
+
email: me@erikboesen.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/geocoder.rb
|
20
|
+
homepage: https://github.com/ErikBoesen/hl-geocoder
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.0.14
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: Hecka light geocoder library
|
44
|
+
test_files: []
|