timezone_teleporter 0.3.0 → 0.4.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: ded83de005cb6eed43b3a9d76d7db0e6db9c21c79350a1fd851eb3f9564ed53e
4
- data.tar.gz: efba91128741f1cbd0ee1cd5549047569e4fbc14c5cac8cfd382aa195502af92
3
+ metadata.gz: 4793314fdb8c13a7af74a3647a6839eafe2d4ee87222878dcda7090035284b2e
4
+ data.tar.gz: 1f614d3ea16f76c320740dfb7945b4abab6c74829230f643337ef321c0842f35
5
5
  SHA512:
6
- metadata.gz: 95371547b81491290c35e0bb000e250b40825423f1591b9b5b41e10015380d46b1eda2c084a781421f55b97dc605786eb77eebc1e56fa2a9ac4e6293e8d45c58
7
- data.tar.gz: 795f94b0ed67791cd46a1873457584ac79115f8c64bb8161357e079751fa0f73680721b9e18d632fd9e540804ff9e7d625e679baeacc92b6986d6597a60ff0d6
6
+ metadata.gz: 6f1bb4c295cb22006ced5e929a28d841fcc17fa3d2af73b9acdd70ee85f36e900e4d3b1a2cb2c564d610147ca382ed5327123f339ee17a76b604acdd6e923e8c
7
+ data.tar.gz: 865bcf801a341c6355962d3b113c622a6d6c910abf9da75d121765bfa73227880698592841f714e23a2d25e444da48abbdf74c123adc417cf6ac8bc958747da5
data/README.md CHANGED
@@ -28,7 +28,7 @@ TimezoneTeleporter can be configured in an initializer:
28
28
 
29
29
  ```ruby
30
30
  TimezoneTeleporter.configure do |c|
31
- c.silent_exceptions = false
31
+ c.silent_exceptions = true
32
32
  c.use_proximity_algorithm = true
33
33
  c.delta_degree = 1
34
34
  end
@@ -36,30 +36,35 @@ end
36
36
 
37
37
  Use following configuration flags to customise the library's behaviour:
38
38
 
39
- * `silent_exceptions`: if set to true, no errors are raised (default is false),
39
+ * `silent_exceptions`: if set to true, no errors are raised and `teleport` returns nil in case no location could be found (default is true),
40
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),
41
41
  * `delta_degree`: defines the radius for the proximity algorithm (default is 1).
42
42
 
43
43
  ### Usage
44
44
 
45
- ##### Teleport with coordinates
46
- Use `TimezoneTeleporter.teleport(lat, lng)` to generate randomized coordinates inside the same time zone by passing coordinates:
45
+ ##### Teleport with coordinates or timezone
46
+ Use `TimezoneTeleporter.teleport(lat, lng)` or `TimezoneTeleporter.teleport(timezone)` 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
52
 
57
53
  ```ruby
58
54
  TimezoneTeleporter.teleport("Europe/Berlin")
59
55
  # => [51.165691, 10.451526]
60
56
  ```
61
- *Note: If time zone is not found, `TimezoneTeleporter.teleport` will return nil if silent_exceptions is set to true.*
62
57
 
58
+ **Note: If time zone is not found, `TimezoneTeleporter.teleport` will return nil if silent_exceptions is set to true.**
59
+
60
+ To get the best result, use both versions together with silent exceptions:
61
+
62
+ ```ruby
63
+ TimezoneTeleporter.configure { |c| c.silent_exceptions = true }
64
+
65
+ TimezoneTeleporter.teleport("Europe/Berlin") || TimezoneTeleporter.teleport(52.520007, 13.404954)
66
+ # => [51.165691, 10.451526]
67
+ ```
63
68
 
64
69
  ## Development
65
70
 
@@ -29,8 +29,6 @@ module TimezoneTeleporter
29
29
  teleport_timezone(timezone_at(lat, lng))
30
30
  rescue StandardError => e
31
31
  raise e unless configuration.silent_exceptions
32
-
33
- [lat, lng]
34
32
  end
35
33
 
36
34
  def teleport_timezone(timezone)
@@ -7,7 +7,7 @@ module TimezoneTeleporter
7
7
  attr_accessor :delta_degree
8
8
 
9
9
  def initialize
10
- @silent_exceptions = false
10
+ @silent_exceptions = true
11
11
  @use_proximity_algorithm = true
12
12
  @delta_degree = 1
13
13
  end
@@ -2,6 +2,14 @@
2
2
 
3
3
  module TimezoneTeleporter
4
4
  TIMEZONE_LOCATIONS = {
5
+ "Asia/Yangon" => [
6
+ "16.7833",
7
+ "96.1667"
8
+ ],
9
+ "Asia/Famagusta" => [
10
+ "35.0375",
11
+ "33.9833"
12
+ ],
5
13
  "Indian/Mauritius" => [
6
14
  -20.348404,
7
15
  57.55215200000001
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TimezoneTeleporter
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.0"
5
5
  end
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.3.0
4
+ version: 0.4.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-08-13 00:00:00.000000000 Z
13
+ date: 2018-08-27 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: timezone_finder