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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9da1e3774d2eb580162d1c13189efb3a2047c1b6079dc81054cc89d70b66121d
4
- data.tar.gz: 98a0b6c484c8645a9b520a65e9610fc1d32413233daba91846e432721e1ce16f
3
+ metadata.gz: ded83de005cb6eed43b3a9d76d7db0e6db9c21c79350a1fd851eb3f9564ed53e
4
+ data.tar.gz: efba91128741f1cbd0ee1cd5549047569e4fbc14c5cac8cfd382aa195502af92
5
5
  SHA512:
6
- metadata.gz: ca47460fb521caac37437bda0b8a1beac34e7c183244d4455f791415924cd256c08e636dd8b40ebdbaf02004b5b5ca2768d3c2ad20665857bc578f8d6085fe43
7
- data.tar.gz: c6a2491299f178fe1914c4bdee84278f33cc0696df508484e539fd470b662ac8d13d11c699389a1fccf015946a2d2f2f7c32e435dbbe2673abce9c3febf10c68
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.silent_mode = false
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
- * `silent_mode`: if set to true, no errors are raised (default is false),
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
- Use `TimezoneTeleporter.teleport(latitude, longitude)` to generate randomized coordinates in the same time zone:
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/TimezoneTeleporter/blob/master/CODE_OF_CONDUCT.md).
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 :silent_mode
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
- @silent_mode = false
10
+ @silent_exceptions = false
11
11
  @use_proximity_algorithm = true
12
12
  @delta_degree = 1
13
13
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TimezoneTeleporter
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
@@ -17,14 +17,30 @@ module TimezoneTeleporter
17
17
  @configuration ||= Configuration.new
18
18
  end
19
19
 
20
- def teleport(lat, lng)
21
- TIMEZONE_LOCATIONS[timezone_at(lat, lng)]
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.silent_mode
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.2.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-07-30 00:00:00.000000000 Z
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 gives you some new coordinates in the same timezone.
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/timezone_teleporter
132
+ homepage: https://github.com/blinkist/timezone-teleporter
130
133
  licenses:
131
134
  - MIT
132
135
  metadata: {}