geoclue 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 66f96002a66f1fbc8136f7efc8b42665446b0acbbf234a6893dc203feb9bd331
4
- data.tar.gz: 8adb10655b6568b752d0723a77b347d4ffa7fe13eec496c4857e3969819c3feb
3
+ metadata.gz: 0124bfbdb74f8f7db512a10befb4551c1c7881f00838ef049661844135304124
4
+ data.tar.gz: d7a8a7d0de41620460f248c167e8b41ffc788e7f37597303b0fcafcb0d68eebd
5
5
  SHA512:
6
- metadata.gz: faa415d7aecaf74a0382d756adfc3cfd3d1fbcaf2529282ecb8d5d68fa68bc1fa6e3083163c93ef7ea4fdb699db21f69a24452b4cb90f030e903947a9189e332
7
- data.tar.gz: 58164e0b9064af2e9160835e0e487cbf0a51dee33fccba7c3250cba423476bcb9b7e2cfaf6e8b63122ac658672ee4df9d53988afb3cef538bb1c3a83be5a9c45
6
+ metadata.gz: 7ccea38f74d1f5b5ab602934f92af1729c89db184227c4db63e7597ee6dc337e13f9ee61b75a6c782b28981ebec01546357ec135c831d5c0f5baf8fe38629da0
7
+ data.tar.gz: aa91cdcbc3d5882f1934b969b4640d2bd0d1dba0f836b06274ed1b01a5447e1091cf9486960a1d68371fd446f577a94d8b9446559de4dc1f99ecee4f41ebba4e
data/.gitignore CHANGED
@@ -6,3 +6,4 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ *.gem
@@ -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
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- geoclue (0.1.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.3)
11
- rake (10.5.0)
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 (~> 10.0)
21
+ rake (~> 12.3)
22
22
 
23
23
  BUNDLED WITH
24
24
  1.17.2
@@ -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", "~> 10.0"
41
+ spec.add_development_dependency "rake", "~> 12.3"
42
42
  spec.add_development_dependency "minitest", "~> 5.0"
43
43
  end
@@ -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)) < 900
52
+ (Time.now - File.mtime(filepath)) < EXPIRATION
51
53
  end
52
54
 
53
55
  def full?
@@ -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
- interface = object["org.freedesktop.GeoClue2.Manager"]
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
- handle_location_update(interface["Location"])
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
- interface = location["org.freedesktop.GeoClue2.Location"]
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 = "https://locationiq.com/v1/reverse_sandbox.php?format=json&lat=#{coords["latitude"]}&lon=#{coords["longitude"]}"
8
- uri = URI(url)
9
- result = Net::HTTP.get(uri)
10
- JSON.parse(result)["address"]
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
@@ -1,3 +1,3 @@
1
1
  module GeoClue
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
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.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: 2019-12-11 00:00:00.000000000 Z
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: '10.0'
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: '10.0'
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: []