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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4793314fdb8c13a7af74a3647a6839eafe2d4ee87222878dcda7090035284b2e
|
4
|
+
data.tar.gz: 1f614d3ea16f76c320740dfb7945b4abab6c74829230f643337ef321c0842f35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 =
|
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
|
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
|
|
data/lib/timezone_teleporter.rb
CHANGED
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.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
|
+
date: 2018-08-27 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: timezone_finder
|