geoclue 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +9 -0
- data/Gemfile.lock +4 -4
- data/geoclue.gemspec +1 -1
- data/lib/geoclue/cache.rb +3 -1
- data/lib/geoclue/client.rb +8 -4
- data/lib/geoclue/reverse_geocoder.rb +18 -4
- data/lib/geoclue/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0124bfbdb74f8f7db512a10befb4551c1c7881f00838ef049661844135304124
|
4
|
+
data.tar.gz: d7a8a7d0de41620460f248c167e8b41ffc788e7f37597303b0fcafcb0d68eebd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ccea38f74d1f5b5ab602934f92af1729c89db184227c4db63e7597ee6dc337e13f9ee61b75a6c782b28981ebec01546357ec135c831d5c0f5baf8fe38629da0
|
7
|
+
data.tar.gz: aa91cdcbc3d5882f1934b969b4640d2bd0d1dba0f836b06274ed1b01a5447e1091cf9486960a1d68371fd446f577a94d8b9446559de4dc1f99ecee4f41ebba4e
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,15 @@
|
|
2
2
|
|
3
3
|
All notable changes to the project will be documented here.
|
4
4
|
|
5
|
+
## [0.1.2] - 2020-06-28
|
6
|
+
|
7
|
+
### Added
|
8
|
+
- Add settlement field in results to capture city, town, village
|
9
|
+
|
10
|
+
### Fixed
|
11
|
+
- Update ReverseGeocoder to use OpenStreetMap
|
12
|
+
Previous solution LocationIQ removed public access API
|
13
|
+
|
5
14
|
## [0.1.1] - 2019-06-09
|
6
15
|
|
7
16
|
### Fixed
|
data/Gemfile.lock
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
geoclue (0.1.
|
4
|
+
geoclue (0.1.2)
|
5
5
|
ruby-dbus (~> 0.15.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
minitest (5.
|
11
|
-
rake (
|
10
|
+
minitest (5.14.0)
|
11
|
+
rake (12.3.3)
|
12
12
|
ruby-dbus (0.15.0)
|
13
13
|
|
14
14
|
PLATFORMS
|
@@ -18,7 +18,7 @@ DEPENDENCIES
|
|
18
18
|
bundler (~> 1.17)
|
19
19
|
geoclue!
|
20
20
|
minitest (~> 5.0)
|
21
|
-
rake (~>
|
21
|
+
rake (~> 12.3)
|
22
22
|
|
23
23
|
BUNDLED WITH
|
24
24
|
1.17.2
|
data/geoclue.gemspec
CHANGED
@@ -38,6 +38,6 @@ Gem::Specification.new do |spec|
|
|
38
38
|
spec.add_dependency "ruby-dbus", "~> 0.15.0"
|
39
39
|
|
40
40
|
spec.add_development_dependency "bundler", "~> 1.17"
|
41
|
-
spec.add_development_dependency "rake", "~>
|
41
|
+
spec.add_development_dependency "rake", "~> 12.3"
|
42
42
|
spec.add_development_dependency "minitest", "~> 5.0"
|
43
43
|
end
|
data/lib/geoclue/cache.rb
CHANGED
@@ -4,6 +4,8 @@ module GeoClue
|
|
4
4
|
class Cache
|
5
5
|
attr_accessor :data
|
6
6
|
|
7
|
+
EXPIRATION = 900
|
8
|
+
|
7
9
|
def initialize
|
8
10
|
@data = {}
|
9
11
|
read if valid?
|
@@ -47,7 +49,7 @@ module GeoClue
|
|
47
49
|
end
|
48
50
|
|
49
51
|
def recent?
|
50
|
-
(Time.now - File.mtime(filepath)) <
|
52
|
+
(Time.now - File.mtime(filepath)) < EXPIRATION
|
51
53
|
end
|
52
54
|
|
53
55
|
def full?
|
data/lib/geoclue/client.rb
CHANGED
@@ -3,7 +3,7 @@ require 'dbus'
|
|
3
3
|
module GeoClue
|
4
4
|
class Client
|
5
5
|
COORD_KEYS = %w[latitude longitude accuracy].freeze
|
6
|
-
ADDR_KEYS = %w[house_number road city county state country postcode country_code].freeze
|
6
|
+
ADDR_KEYS = %w[house_number road settlement city town village county state country postcode country_code].freeze
|
7
7
|
|
8
8
|
def initialize
|
9
9
|
@data = {}
|
@@ -50,7 +50,7 @@ module GeoClue
|
|
50
50
|
def manager
|
51
51
|
@manager ||= begin
|
52
52
|
object = service["/org/freedesktop/GeoClue2/Manager"]
|
53
|
-
|
53
|
+
object["org.freedesktop.GeoClue2.Manager"]
|
54
54
|
object
|
55
55
|
end
|
56
56
|
end
|
@@ -66,7 +66,11 @@ module GeoClue
|
|
66
66
|
interface["DesktopId"] = "geoclue-ruby"
|
67
67
|
interface["RequestedAccuracyLevel"] = ['u', 8]
|
68
68
|
interface.on_signal("LocationUpdated") do
|
69
|
-
|
69
|
+
begin
|
70
|
+
handle_location_update(interface["Location"])
|
71
|
+
rescue DBus::InvalidPacketException
|
72
|
+
retry
|
73
|
+
end
|
70
74
|
end
|
71
75
|
Thread.new { interface["Location"] }
|
72
76
|
object
|
@@ -75,7 +79,7 @@ module GeoClue
|
|
75
79
|
|
76
80
|
def handle_location_update(location_id)
|
77
81
|
location = service[location_id]
|
78
|
-
|
82
|
+
location["org.freedesktop.GeoClue2.Location"]
|
79
83
|
@data = location.GetAll("org.freedesktop.GeoClue2.Location").transform_keys(&:downcase)
|
80
84
|
end
|
81
85
|
end
|
@@ -4,10 +4,24 @@ module GeoClue
|
|
4
4
|
module ReverseGeocoder
|
5
5
|
class << self
|
6
6
|
def geocode(coords)
|
7
|
-
url =
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
url = URI::HTTPS.build(
|
8
|
+
scheme: "https",
|
9
|
+
host: "nominatim.openstreetmap.org",
|
10
|
+
path: "/reverse",
|
11
|
+
query: URI.encode_www_form(
|
12
|
+
format: 'json',
|
13
|
+
lat: coords['latitude'],
|
14
|
+
lon: coords['longitude']
|
15
|
+
)
|
16
|
+
)
|
17
|
+
|
18
|
+
result = JSON.parse(Net::HTTP.get(url))
|
19
|
+
|
20
|
+
return {} if ! result.key?("address")
|
21
|
+
|
22
|
+
addr = result["address"]
|
23
|
+
addr["settlement"] = addr["city"] || addr["town"] || addr["village"]
|
24
|
+
addr
|
11
25
|
end
|
12
26
|
end
|
13
27
|
end
|
data/lib/geoclue/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geoclue
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jacob Evan Shreve
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-dbus
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '12.3'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '12.3'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: minitest
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,7 +100,7 @@ metadata:
|
|
100
100
|
homepage_uri: https://github.com/shreve/geoclue-ruby
|
101
101
|
source_code_uri: https://github.com/shreve/geoclue-ruby
|
102
102
|
changelog_uri: https://github.com/shreve/geoclue-ruby/blob/master/CHANGELOG.md
|
103
|
-
post_install_message:
|
103
|
+
post_install_message:
|
104
104
|
rdoc_options: []
|
105
105
|
require_paths:
|
106
106
|
- lib
|
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
116
|
version: '0'
|
117
117
|
requirements: []
|
118
118
|
rubygems_version: 3.0.3
|
119
|
-
signing_key:
|
119
|
+
signing_key:
|
120
120
|
specification_version: 4
|
121
121
|
summary: Access your computer's geographic coordinates
|
122
122
|
test_files: []
|