zone_detect 0.1.0 → 0.2.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/CHANGELOG.markdown +7 -0
- data/README.markdown +9 -1
- data/ext/zone_detect/contrib/ZoneDetect/library/zonedetect.h +1 -0
- data/ext/zone_detect/zone_detect.c +2 -0
- data/lib/zone_detect/version.rb +1 -1
- data/lib/zone_detect.rb +23 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c5fa51707db0e4ded3e1fa680b3354e22deccd868a3b953190918979cce32b3
|
4
|
+
data.tar.gz: 12ae78865eb600807b27855e6cc4fddefe2e3fbe5d19c61b4a95ca49cdf84f39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e602ee96fe1f093410bf66bd9313416545c366e4f0659ce4b612346ed4178203ae47e87169c033bee78a9328aaeae7cbbac30b645eb0a036a539d044fa431851
|
7
|
+
data.tar.gz: 0b749e0ced9a56dac993771d43e681e5cf2872e12cc049560699b91850b689e48d5b868a3abcda13590d2ea67e4149f60572b5733aaa32df7df355e028a487e1
|
data/CHANGELOG.markdown
CHANGED
data/README.markdown
CHANGED
@@ -24,9 +24,17 @@ $ gem install zone_detect
|
|
24
24
|
|
25
25
|
```ruby
|
26
26
|
require "zone_detect"
|
27
|
-
|
27
|
+
|
28
|
+
zd = ZoneDetect.new('/path/to/data.bin')
|
28
29
|
zd.find(59.329, 18.063)
|
29
30
|
# => "Europe/Stockholm"
|
31
|
+
|
32
|
+
# Alternative usage:
|
33
|
+
ZoneDetect.configure do |config|
|
34
|
+
config.timezone_data_path = '/path/to/data.bin'
|
35
|
+
end
|
36
|
+
ZoneDetect.find(59.334, 18.063)
|
37
|
+
# => "Europe/Stockholm"
|
30
38
|
```
|
31
39
|
|
32
40
|
## Development
|
@@ -36,6 +36,8 @@ static VALUE initialize(VALUE self, VALUE path) {
|
|
36
36
|
struct zd_data *d;
|
37
37
|
TypedData_Get_Struct(self, struct zd_data, &zd_type, d);
|
38
38
|
d->cd = ZDOpenDatabase(StringValuePtr(path));
|
39
|
+
if (!d->cd)
|
40
|
+
rb_raise(rb_eRuntimeError, "Could not open data file");
|
39
41
|
return self;
|
40
42
|
}
|
41
43
|
|
data/lib/zone_detect/version.rb
CHANGED
data/lib/zone_detect.rb
CHANGED
@@ -2,3 +2,26 @@
|
|
2
2
|
|
3
3
|
require_relative 'zone_detect/zone_detect'
|
4
4
|
require_relative 'zone_detect/version'
|
5
|
+
|
6
|
+
# :nodoc:
|
7
|
+
class ZoneDetect
|
8
|
+
# :nodoc:
|
9
|
+
class Config
|
10
|
+
attr_accessor :timezone_data_path
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.configure
|
14
|
+
config = Config.new
|
15
|
+
yield config
|
16
|
+
raise 'Missing required configuration: timezone_data_path' unless config.timezone_data_path
|
17
|
+
|
18
|
+
@instance = ZoneDetect.new(config.timezone_data_path)
|
19
|
+
nil
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.find(lat, lng)
|
23
|
+
raise 'Missing configuration' unless @instance
|
24
|
+
|
25
|
+
@instance.find(lat, lng)
|
26
|
+
end
|
27
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zone_detect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Cederblad
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-01-
|
11
|
+
date: 2023-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -54,7 +54,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
requirements: []
|
57
|
-
rubygems_version: 3.3.
|
57
|
+
rubygems_version: 3.3.12
|
58
58
|
signing_key:
|
59
59
|
specification_version: 4
|
60
60
|
summary: Find time zone from given coordinates
|