timezone_teleporter 0.2.0 → 0.3.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 +4 -4
- data/README.md +15 -6
- data/lib/timezone_teleporter/configuration.rb +2 -2
- data/lib/timezone_teleporter/version.rb +1 -1
- data/lib/timezone_teleporter.rb +19 -3
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ded83de005cb6eed43b3a9d76d7db0e6db9c21c79350a1fd851eb3f9564ed53e
|
4
|
+
data.tar.gz: efba91128741f1cbd0ee1cd5549047569e4fbc14c5cac8cfd382aa195502af92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95371547b81491290c35e0bb000e250b40825423f1591b9b5b41e10015380d46b1eda2c084a781421f55b97dc605786eb77eebc1e56fa2a9ac4e6293e8d45c58
|
7
|
+
data.tar.gz: 795f94b0ed67791cd46a1873457584ac79115f8c64bb8161357e079751fa0f73680721b9e18d632fd9e540804ff9e7d625e679baeacc92b6986d6597a60ff0d6
|
data/README.md
CHANGED
@@ -7,7 +7,6 @@ TimezoneTeleporter anonymizes users' GPS coordinates by generating random coordi
|
|
7
7
|
## Dependencies
|
8
8
|
|
9
9
|
* Uses the gem [timezone_finder](https://github.com/gunyarakun/timezone_finder) for time zone lookup.
|
10
|
-
* Uses the gem [timezone](https://github.com/panthomakos/timezone).
|
11
10
|
|
12
11
|
## Installation
|
13
12
|
|
@@ -29,7 +28,7 @@ TimezoneTeleporter can be configured in an initializer:
|
|
29
28
|
|
30
29
|
```ruby
|
31
30
|
TimezoneTeleporter.configure do |c|
|
32
|
-
c.
|
31
|
+
c.silent_exceptions = false
|
33
32
|
c.use_proximity_algorithm = true
|
34
33
|
c.delta_degree = 1
|
35
34
|
end
|
@@ -37,20 +36,30 @@ end
|
|
37
36
|
|
38
37
|
Use following configuration flags to customise the library's behaviour:
|
39
38
|
|
40
|
-
* `
|
39
|
+
* `silent_exceptions`: if set to true, no errors are raised (default is false),
|
41
40
|
* `use_proximity_algorithm`: if the timezone is not found, TimezoneTeleporter tries to find the closest timezone within +-1 delta_degree longitude and +-1 delta_degree latitude (default is true),
|
42
41
|
* `delta_degree`: defines the radius for the proximity algorithm (default is 1).
|
43
42
|
|
44
43
|
### Usage
|
45
44
|
|
46
|
-
|
45
|
+
##### Teleport with coordinates
|
46
|
+
Use `TimezoneTeleporter.teleport(lat, lng)` to generate randomized coordinates inside the same time zone by passing coordinates:
|
47
47
|
|
48
48
|
```ruby
|
49
49
|
TimezoneTeleporter.teleport(52.520007, 13.404954)
|
50
50
|
# => [51.165691, 10.451526]
|
51
51
|
```
|
52
|
+
*Note: If time zone is not found, `TimezoneTeleporter.teleport` will return the origin coordinates if silent_exceptions is set to true.*
|
53
|
+
|
54
|
+
##### Teleport with time zone
|
55
|
+
Use `TimezoneTeleporter.teleport(timezone)` to generate randomized coordinates inside the same time zone by passing a time zone:
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
TimezoneTeleporter.teleport("Europe/Berlin")
|
59
|
+
# => [51.165691, 10.451526]
|
60
|
+
```
|
61
|
+
*Note: If time zone is not found, `TimezoneTeleporter.teleport` will return nil if silent_exceptions is set to true.*
|
52
62
|
|
53
|
-
*Note: If time zone is not found, `TimezoneTeleporter.teleport` will return the origin coordinates unless silent_mode is set to false.*
|
54
63
|
|
55
64
|
## Development
|
56
65
|
|
@@ -64,4 +73,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
64
73
|
|
65
74
|
## Code of Conduct
|
66
75
|
|
67
|
-
Everyone interacting in the TimezoneTeleporter project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/blinkist/
|
76
|
+
Everyone interacting in the TimezoneTeleporter project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/blinkist/timezone-teleporter/blob/master/CODE_OF_CONDUCT.md).
|
@@ -2,12 +2,12 @@
|
|
2
2
|
|
3
3
|
module TimezoneTeleporter
|
4
4
|
class Configuration
|
5
|
-
attr_accessor :
|
5
|
+
attr_accessor :silent_exceptions
|
6
6
|
attr_accessor :use_proximity_algorithm
|
7
7
|
attr_accessor :delta_degree
|
8
8
|
|
9
9
|
def initialize
|
10
|
-
@
|
10
|
+
@silent_exceptions = false
|
11
11
|
@use_proximity_algorithm = true
|
12
12
|
@delta_degree = 1
|
13
13
|
end
|
data/lib/timezone_teleporter.rb
CHANGED
@@ -17,14 +17,30 @@ module TimezoneTeleporter
|
|
17
17
|
@configuration ||= Configuration.new
|
18
18
|
end
|
19
19
|
|
20
|
-
def teleport(
|
21
|
-
|
20
|
+
def teleport(lat_or_tz, lng=nil)
|
21
|
+
if lng.nil?
|
22
|
+
teleport_timezone(lat_or_tz)
|
23
|
+
else
|
24
|
+
teleport_location(lat_or_tz, lng)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def teleport_location(lat, lng)
|
29
|
+
teleport_timezone(timezone_at(lat, lng))
|
22
30
|
rescue StandardError => e
|
23
|
-
raise e unless configuration.
|
31
|
+
raise e unless configuration.silent_exceptions
|
24
32
|
|
25
33
|
[lat, lng]
|
26
34
|
end
|
27
35
|
|
36
|
+
def teleport_timezone(timezone)
|
37
|
+
location = TIMEZONE_LOCATIONS[timezone]
|
38
|
+
|
39
|
+
raise TimeZoneNotFoundError unless location || configuration.silent_exceptions
|
40
|
+
|
41
|
+
location
|
42
|
+
end
|
43
|
+
|
28
44
|
def timezone_at(lat, lng)
|
29
45
|
timezone_name = timezone_finder.timezone_at(lat: lat, lng: lng)
|
30
46
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: timezone_teleporter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ole Richter
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2018-
|
13
|
+
date: 2018-08-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: timezone_finder
|
@@ -110,7 +110,10 @@ dependencies:
|
|
110
110
|
- - ">="
|
111
111
|
- !ruby/object:Gem::Version
|
112
112
|
version: '0'
|
113
|
-
description: TimezoneTeleporter
|
113
|
+
description: TimezoneTeleporter anonymizes users' GPS coordinates by generating random
|
114
|
+
coordinates in the same time zone. These new coordinates may be used then safely
|
115
|
+
by 3rd party systems to process the users' location, without disclosing their actual
|
116
|
+
physical position, providing more privacy, and anonymity to users.
|
114
117
|
email:
|
115
118
|
- ole@blinkist.com
|
116
119
|
- tomek@blinkist.com
|
@@ -126,7 +129,7 @@ files:
|
|
126
129
|
- lib/timezone_teleporter/errors.rb
|
127
130
|
- lib/timezone_teleporter/timezone_locations.rb
|
128
131
|
- lib/timezone_teleporter/version.rb
|
129
|
-
homepage: https://github.com/blinkist/
|
132
|
+
homepage: https://github.com/blinkist/timezone-teleporter
|
130
133
|
licenses:
|
131
134
|
- MIT
|
132
135
|
metadata: {}
|