timezone 1.3.24 → 1.3.26
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +15 -0
- data/.github/workflows/{rake.yml → ci.yml} +2 -2
- data/.rubocop.yml +24 -5
- data/CHANGES.markdown +8 -0
- data/README.markdown +2 -2
- data/data/America/Miquelon +2 -2
- data/data/America/Montreal +2 -2
- data/data/America/Nassau +2 -2
- data/data/America/Nipigon +2 -2
- data/data/America/Thunder_Bay +2 -2
- data/data/America/Toronto +2 -2
- data/data/Asia/Almaty +2 -1
- data/data/Asia/Gaza +2 -2
- data/data/Asia/Hebron +2 -2
- data/data/Asia/Ho_Chi_Minh +2 -2
- data/data/Asia/Qostanay +2 -1
- data/data/Asia/Saigon +2 -2
- data/data/Canada/Eastern +2 -2
- data/lib/timezone/error.rb +6 -0
- data/lib/timezone/loader.rb +2 -2
- data/lib/timezone/lookup/geonames.rb +1 -0
- data/lib/timezone/lookup/google.rb +3 -2
- data/lib/timezone/lookup.rb +3 -2
- data/lib/timezone/parser.rb +5 -4
- data/lib/timezone/version.rb +1 -1
- data/lib/timezone/zone.rb +0 -1
- data/test/timezone/lookup/test_geonames.rb +16 -9
- data/test/timezone/lookup/test_google.rb +7 -2
- data/test/timezone/lookup/test_test.rb +1 -0
- data/test/timezone/test_lookup.rb +5 -5
- data/timezone.gemspec +6 -4
- metadata +38 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b58b8ab043d3250736d281e7509b23a4b37d55a8183c774154bfc927a4432435
|
4
|
+
data.tar.gz: 34ef3d1d64a98c9089ccc3327eac6b757bc672402d88d764d9bea929419b7376
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14a9ba4a4d102859a3005027a372ad5f2a5e2eaac4497a59b37c4d10fbfd33268a042da306fec8cd74755ded865502f353145806d1104e26c4d9be52dd79076d
|
7
|
+
data.tar.gz: dc486e7a84ac0a70e6dd565ad040feefd0d9b708765f93bcb4a0857442564d2bd215258c3999bdbe5b166ce4f06fdb314ed4fc44913081b90cb8a32b789bdfc4
|
data/.codeclimate.yml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
version: "2" # required to adjust maintainability checks
|
2
|
+
|
3
|
+
checks:
|
4
|
+
argument-count:
|
5
|
+
enabled: true
|
6
|
+
config:
|
7
|
+
threshold: 5
|
8
|
+
method-complexity:
|
9
|
+
enabled: true
|
10
|
+
config:
|
11
|
+
threshold: 15
|
12
|
+
return-statements:
|
13
|
+
enabled: true
|
14
|
+
config:
|
15
|
+
threshold: 10
|
@@ -1,4 +1,4 @@
|
|
1
|
-
name:
|
1
|
+
name: CI
|
2
2
|
|
3
3
|
on:
|
4
4
|
push:
|
@@ -11,7 +11,7 @@ jobs:
|
|
11
11
|
runs-on: ubuntu-latest
|
12
12
|
strategy:
|
13
13
|
matrix:
|
14
|
-
ruby-version: ['2.
|
14
|
+
ruby-version: ['2.5', '2.6', '2.7', '3.0', '3.1', '3.2', '3.3']
|
15
15
|
|
16
16
|
steps:
|
17
17
|
- uses: actions/checkout@v2
|
data/.rubocop.yml
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
+
require: rubocop-performance
|
2
|
+
|
1
3
|
AllCops:
|
2
|
-
TargetRubyVersion: 2.
|
4
|
+
TargetRubyVersion: 2.4
|
5
|
+
NewCops: enable
|
6
|
+
SuggestExtensions: false
|
3
7
|
|
4
|
-
|
5
|
-
|
8
|
+
Gemspec/RequiredRubyVersion:
|
9
|
+
Enabled: false
|
6
10
|
|
7
11
|
Layout/EmptyLineBetweenDefs:
|
8
12
|
Enabled: true
|
@@ -10,6 +14,9 @@ Layout/EmptyLineBetweenDefs:
|
|
10
14
|
Layout/MultilineMethodCallIndentation:
|
11
15
|
EnforcedStyle: indented
|
12
16
|
|
17
|
+
Layout/ParameterAlignment:
|
18
|
+
EnforcedStyle: with_fixed_indentation
|
19
|
+
|
13
20
|
Layout/SpaceAfterComma:
|
14
21
|
Enabled: true
|
15
22
|
|
@@ -23,6 +30,9 @@ Layout/SpaceBeforeSemicolon:
|
|
23
30
|
Enabled: true
|
24
31
|
|
25
32
|
|
33
|
+
Lint/MissingSuper:
|
34
|
+
Enabled: false
|
35
|
+
|
26
36
|
Lint/DuplicateMethods:
|
27
37
|
Enabled: true
|
28
38
|
|
@@ -39,7 +49,7 @@ Metrics/ClassLength:
|
|
39
49
|
# Offense count: 13
|
40
50
|
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
|
41
51
|
# URISchemes: http, https
|
42
|
-
|
52
|
+
Layout/LineLength:
|
43
53
|
Max: 80
|
44
54
|
|
45
55
|
Metrics/MethodLength:
|
@@ -85,12 +95,21 @@ Style/NumericLiterals:
|
|
85
95
|
Style/PreferredHashMethods:
|
86
96
|
Enabled: true
|
87
97
|
|
98
|
+
Style/RedundantArgument:
|
99
|
+
Enabled: false
|
100
|
+
|
101
|
+
Style/RedundantFetchBlock:
|
102
|
+
Enabled: false
|
103
|
+
|
88
104
|
Style/RedundantReturn:
|
89
105
|
Enabled: true
|
90
106
|
|
91
107
|
Style/RedundantSelf:
|
92
108
|
Enabled: true
|
93
109
|
|
110
|
+
Style/SafeNavigation:
|
111
|
+
Enabled: false
|
112
|
+
|
94
113
|
Style/SingleLineMethods:
|
95
114
|
Enabled: false
|
96
115
|
|
@@ -103,7 +122,7 @@ Style/StringLiterals:
|
|
103
122
|
Style/TrivialAccessors:
|
104
123
|
Enabled: true
|
105
124
|
|
106
|
-
Style/
|
125
|
+
Style/RedundantPercentQ:
|
107
126
|
Enabled: true
|
108
127
|
|
109
128
|
Style/DateTime:
|
data/CHANGES.markdown
CHANGED
data/README.markdown
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
# Timezone
|
2
|
+
![ci](https://github.com/panthomakos/timezone/actions/workflows/ci.yml/badge.svg)
|
3
|
+
[![maintainability](https://api.codeclimate.com/v1/badges/d19a4a37dcbd373ac566/maintainability)](https://codeclimate.com/github/panthomakos/timezone/maintainability)
|
2
4
|
|
3
5
|
Accurate current and history timezones for Ruby.
|
4
6
|
|
@@ -246,5 +248,3 @@ You can also provide a fallback lookup, which will be returned if you query an u
|
|
246
248
|
|
247
249
|
::Timezone::Lookup.lookup.default('America/Los_Angeles')
|
248
250
|
=> "America/Los_Angeles"
|
249
|
-
|
250
|
-
## Code Quality [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/panthomakos/timezone)
|
data/data/America/Miquelon
CHANGED
data/data/America/Montreal
CHANGED
@@ -49,13 +49,13 @@
|
|
49
49
|
3999600:EPT:1:-14400
|
50
50
|
18147600:EST:0:-18000
|
51
51
|
13302000:EDT:1:-14400
|
52
|
-
|
52
|
+
18147600:EST:0:-18000
|
53
53
|
13302000:EDT:1:-14400
|
54
54
|
18147600:EST:0:-18000
|
55
55
|
13302000:EDT:1:-14400
|
56
56
|
18147600:EST:0:-18000
|
57
57
|
18745200:EDT:1:-14400
|
58
|
-
|
58
|
+
13309200:EST:0:-18000
|
59
59
|
18140400:EDT:1:-14400
|
60
60
|
13309200:EST:0:-18000
|
61
61
|
13302000:EDT:1:-14400
|
data/data/America/Nassau
CHANGED
@@ -49,13 +49,13 @@
|
|
49
49
|
3999600:EPT:1:-14400
|
50
50
|
18147600:EST:0:-18000
|
51
51
|
13302000:EDT:1:-14400
|
52
|
-
|
52
|
+
18147600:EST:0:-18000
|
53
53
|
13302000:EDT:1:-14400
|
54
54
|
18147600:EST:0:-18000
|
55
55
|
13302000:EDT:1:-14400
|
56
56
|
18147600:EST:0:-18000
|
57
57
|
18745200:EDT:1:-14400
|
58
|
-
|
58
|
+
13309200:EST:0:-18000
|
59
59
|
18140400:EDT:1:-14400
|
60
60
|
13309200:EST:0:-18000
|
61
61
|
13302000:EDT:1:-14400
|
data/data/America/Nipigon
CHANGED
@@ -49,13 +49,13 @@
|
|
49
49
|
3999600:EPT:1:-14400
|
50
50
|
18147600:EST:0:-18000
|
51
51
|
13302000:EDT:1:-14400
|
52
|
-
|
52
|
+
18147600:EST:0:-18000
|
53
53
|
13302000:EDT:1:-14400
|
54
54
|
18147600:EST:0:-18000
|
55
55
|
13302000:EDT:1:-14400
|
56
56
|
18147600:EST:0:-18000
|
57
57
|
18745200:EDT:1:-14400
|
58
|
-
|
58
|
+
13309200:EST:0:-18000
|
59
59
|
18140400:EDT:1:-14400
|
60
60
|
13309200:EST:0:-18000
|
61
61
|
13302000:EDT:1:-14400
|
data/data/America/Thunder_Bay
CHANGED
@@ -49,13 +49,13 @@
|
|
49
49
|
3999600:EPT:1:-14400
|
50
50
|
18147600:EST:0:-18000
|
51
51
|
13302000:EDT:1:-14400
|
52
|
-
|
52
|
+
18147600:EST:0:-18000
|
53
53
|
13302000:EDT:1:-14400
|
54
54
|
18147600:EST:0:-18000
|
55
55
|
13302000:EDT:1:-14400
|
56
56
|
18147600:EST:0:-18000
|
57
57
|
18745200:EDT:1:-14400
|
58
|
-
|
58
|
+
13309200:EST:0:-18000
|
59
59
|
18140400:EDT:1:-14400
|
60
60
|
13309200:EST:0:-18000
|
61
61
|
13302000:EDT:1:-14400
|
data/data/America/Toronto
CHANGED
@@ -49,13 +49,13 @@
|
|
49
49
|
3999600:EPT:1:-14400
|
50
50
|
18147600:EST:0:-18000
|
51
51
|
13302000:EDT:1:-14400
|
52
|
-
|
52
|
+
18147600:EST:0:-18000
|
53
53
|
13302000:EDT:1:-14400
|
54
54
|
18147600:EST:0:-18000
|
55
55
|
13302000:EDT:1:-14400
|
56
56
|
18147600:EST:0:-18000
|
57
57
|
18745200:EDT:1:-14400
|
58
|
-
|
58
|
+
13309200:EST:0:-18000
|
59
59
|
18140400:EDT:1:-14400
|
60
60
|
13309200:EST:0:-18000
|
61
61
|
13302000:EDT:1:-14400
|
data/data/Asia/Almaty
CHANGED
data/data/Asia/Gaza
CHANGED
@@ -120,10 +120,10 @@
|
|
120
120
|
18666000:EEST:1:10800
|
121
121
|
15728400:EET:0:7200
|
122
122
|
15721200:EEST:1:10800
|
123
|
+
15123600:EET:0:7200
|
124
|
+
16326000:EEST:1:10800
|
123
125
|
14518800:EET:0:7200
|
124
126
|
16930800:EEST:1:10800
|
125
|
-
13914000:EET:0:7200
|
126
|
-
17535600:EEST:1:10800
|
127
127
|
13309200:EET:0:7200
|
128
128
|
18140400:EEST:1:10800
|
129
129
|
13309200:EET:0:7200
|
data/data/Asia/Hebron
CHANGED
@@ -122,10 +122,10 @@
|
|
122
122
|
18666000:EEST:1:10800
|
123
123
|
15728400:EET:0:7200
|
124
124
|
15721200:EEST:1:10800
|
125
|
+
15123600:EET:0:7200
|
126
|
+
16326000:EEST:1:10800
|
125
127
|
14518800:EET:0:7200
|
126
128
|
16930800:EEST:1:10800
|
127
|
-
13914000:EET:0:7200
|
128
|
-
17535600:EEST:1:10800
|
129
129
|
13309200:EET:0:7200
|
130
130
|
18140400:EEST:1:10800
|
131
131
|
13309200:EET:0:7200
|
data/data/Asia/Ho_Chi_Minh
CHANGED
data/data/Asia/Qostanay
CHANGED
data/data/Asia/Saigon
CHANGED
data/data/Canada/Eastern
CHANGED
@@ -49,13 +49,13 @@
|
|
49
49
|
3999600:EPT:1:-14400
|
50
50
|
18147600:EST:0:-18000
|
51
51
|
13302000:EDT:1:-14400
|
52
|
-
|
52
|
+
18147600:EST:0:-18000
|
53
53
|
13302000:EDT:1:-14400
|
54
54
|
18147600:EST:0:-18000
|
55
55
|
13302000:EDT:1:-14400
|
56
56
|
18147600:EST:0:-18000
|
57
57
|
18745200:EDT:1:-14400
|
58
|
-
|
58
|
+
13309200:EST:0:-18000
|
59
59
|
18140400:EDT:1:-14400
|
60
60
|
13309200:EST:0:-18000
|
61
61
|
13302000:EDT:1:-14400
|
data/lib/timezone/error.rb
CHANGED
@@ -12,16 +12,22 @@ module Timezone
|
|
12
12
|
module Error
|
13
13
|
# Top-level error. All other timezone errors subclass this one.
|
14
14
|
class Base < StandardError; end
|
15
|
+
|
15
16
|
# Indicates an invalid timezone name.
|
16
17
|
class InvalidZone < Base; end
|
18
|
+
|
17
19
|
# Indicates a lookup failure.
|
18
20
|
class Lookup < Base; end
|
21
|
+
|
19
22
|
# Indicates an error during lookup using the geonames API.
|
20
23
|
class GeoNames < Lookup; end
|
24
|
+
|
21
25
|
# Indicates an error during lookup using the google API.
|
22
26
|
class Google < Lookup; end
|
27
|
+
|
23
28
|
# Indicates a missing stub during a test lookup.
|
24
29
|
class Test < Lookup; end
|
30
|
+
|
25
31
|
# Indicates an invalid configuration.
|
26
32
|
class InvalidConfig < Base; end
|
27
33
|
end
|
data/lib/timezone/loader.rb
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
require 'timezone/error'
|
4
4
|
|
5
|
-
module Timezone
|
5
|
+
module Timezone
|
6
6
|
# Responsible for loading and parsing timezone data from files.
|
7
7
|
module Loader
|
8
|
-
ZONE_FILE_PATH = File.expand_path(File.dirname(__FILE__)
|
8
|
+
ZONE_FILE_PATH = File.expand_path("#{File.dirname(__FILE__)}/../../data")
|
9
9
|
SOURCE_BIT = 0
|
10
10
|
|
11
11
|
@rules = {} # cache of loaded rules
|
@@ -14,7 +14,7 @@ module Timezone
|
|
14
14
|
class Google < ::Timezone::Lookup::Basic
|
15
15
|
# Indicates that no time zone data could be found for the specified
|
16
16
|
# <lat, lng>. This can occur if the query is incomplete or ambiguous.
|
17
|
-
NO_TIMEZONE_INFORMATION = 'ZERO_RESULTS'
|
17
|
+
NO_TIMEZONE_INFORMATION = 'ZERO_RESULTS'
|
18
18
|
|
19
19
|
def initialize(config)
|
20
20
|
if config.api_key.nil?
|
@@ -34,7 +34,8 @@ module Timezone
|
|
34
34
|
raise(Timezone::Error::Google, '403 Forbidden')
|
35
35
|
end
|
36
36
|
|
37
|
-
return unless
|
37
|
+
return unless /^2\d\d$/.match?(response.code)
|
38
|
+
|
38
39
|
data = JSON.parse(response.body)
|
39
40
|
|
40
41
|
return if data['status'] == NO_TIMEZONE_INFORMATION
|
data/lib/timezone/lookup.rb
CHANGED
@@ -4,12 +4,13 @@ require 'timezone/lookup/geonames'
|
|
4
4
|
require 'timezone/lookup/google'
|
5
5
|
require 'timezone/lookup/test'
|
6
6
|
require 'timezone/net_http_client'
|
7
|
+
require 'ostruct'
|
7
8
|
|
8
9
|
module Timezone
|
9
10
|
# Configure timezone lookups.
|
10
11
|
module Lookup
|
11
12
|
class << self
|
12
|
-
MISSING_LOOKUP = 'No lookup configured'
|
13
|
+
MISSING_LOOKUP = 'No lookup configured'
|
13
14
|
private_constant :MISSING_LOOKUP
|
14
15
|
|
15
16
|
# Returns the lookup object
|
@@ -45,7 +46,7 @@ module Timezone
|
|
45
46
|
test: ::Timezone::Lookup::Test
|
46
47
|
}.freeze
|
47
48
|
|
48
|
-
INVALID_LOOKUP = 'Invalid lookup specified'
|
49
|
+
INVALID_LOOKUP = 'Invalid lookup specified'
|
49
50
|
|
50
51
|
attr_reader :config
|
51
52
|
|
data/lib/timezone/parser.rb
CHANGED
@@ -9,7 +9,7 @@ module Timezone
|
|
9
9
|
MIN_YEAR = -500
|
10
10
|
MAX_YEAR = 2039
|
11
11
|
|
12
|
-
LINE = /\s*(.+)\s*=\s*(.+)\s*isdst=(\d+)\s*gmtoff=([
|
12
|
+
LINE = /\s*(.+)\s*=\s*(.+)\s*isdst=(\d+)\s*gmtoff=([+\-]*\d+)/.freeze
|
13
13
|
|
14
14
|
# Bookkeeping files that we do not want to parse.
|
15
15
|
IGNORE = ['leapseconds', 'posixrules', 'tzdata.zi'].freeze
|
@@ -25,6 +25,7 @@ module Timezone
|
|
25
25
|
next if File.directory?(file)
|
26
26
|
next if file.end_with?('.tab')
|
27
27
|
next if IGNORE.include?(File.basename(file))
|
28
|
+
|
28
29
|
parse(file)
|
29
30
|
end
|
30
31
|
end
|
@@ -65,7 +66,7 @@ module Timezone
|
|
65
66
|
def parse_offset(offset)
|
66
67
|
arity = offset.start_with?('-') ? -1 : 1
|
67
68
|
|
68
|
-
match = offset.match(/^[
|
69
|
+
match = offset.match(/^[\-+](\d{2})$/)
|
69
70
|
arity * match[1].to_i * 60 * 60
|
70
71
|
end
|
71
72
|
end
|
@@ -76,10 +77,10 @@ module Timezone
|
|
76
77
|
class Line
|
77
78
|
attr_accessor :source, :name, :dst, :offset
|
78
79
|
|
79
|
-
SOURCE_FORMAT = '%a %b %e %H:%M:%S %Y %Z'
|
80
|
+
SOURCE_FORMAT = '%a %b %e %H:%M:%S %Y %Z'
|
80
81
|
|
81
82
|
def initialize(match)
|
82
|
-
self.source = Time.strptime(match[1]
|
83
|
+
self.source = Time.strptime("#{match[1]}C", SOURCE_FORMAT).to_i
|
83
84
|
self.name = match[2].split(' ').last
|
84
85
|
self.dst = match[3].to_i
|
85
86
|
self.offset = match[4].to_i
|
data/lib/timezone/version.rb
CHANGED
data/lib/timezone/zone.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'timezone/lookup/geonames'
|
4
4
|
require 'minitest/autorun'
|
5
|
+
require 'ostruct'
|
5
6
|
require_relative '../../http_test_client'
|
6
7
|
|
7
8
|
class TestGeonames < ::Minitest::Test
|
@@ -19,6 +20,10 @@ class TestGeonames < ::Minitest::Test
|
|
19
20
|
}
|
20
21
|
end
|
21
22
|
|
23
|
+
def lookup_file(file_name, &block)
|
24
|
+
lookup(File.open(File.join(mock_path, file_name)).read, &block)
|
25
|
+
end
|
26
|
+
|
22
27
|
def lookup(body = nil, &_block)
|
23
28
|
config = OpenStruct.new
|
24
29
|
config.username = 'timezone'
|
@@ -40,23 +45,25 @@ class TestGeonames < ::Minitest::Test
|
|
40
45
|
end
|
41
46
|
|
42
47
|
def test_lookup
|
43
|
-
mine =
|
48
|
+
mine = lookup_file('/lat_lon_coords.txt')
|
44
49
|
|
45
50
|
assert_equal 'Australia/Adelaide', mine.lookup(*coordinates)
|
46
51
|
end
|
47
52
|
|
48
53
|
def test_lookup_with_etc
|
49
54
|
etc_data.each do |key, data|
|
50
|
-
|
51
|
-
|
55
|
+
mine = lookup_file("/lat_lon_coords_#{key}.txt") do |c|
|
56
|
+
c.offset_etc_zones = true
|
57
|
+
end
|
52
58
|
|
53
59
|
assert_equal data[:name], mine.lookup(*data[:coordinates])
|
54
60
|
end
|
55
61
|
end
|
56
62
|
|
57
63
|
def test_wrong_offset
|
58
|
-
|
59
|
-
|
64
|
+
mine = lookup_file('/lat_lon_coords_wrong_offset.txt') do |c|
|
65
|
+
c.offset_etc_zones = true
|
66
|
+
end
|
60
67
|
|
61
68
|
assert_nil mine.lookup(*coordinates)
|
62
69
|
end
|
@@ -80,7 +87,7 @@ class TestGeonames < ::Minitest::Test
|
|
80
87
|
end
|
81
88
|
|
82
89
|
def test_api_limit
|
83
|
-
mine =
|
90
|
+
mine = lookup_file('/api_limit_reached.json')
|
84
91
|
|
85
92
|
assert_exception(
|
86
93
|
mine,
|
@@ -90,19 +97,19 @@ class TestGeonames < ::Minitest::Test
|
|
90
97
|
end
|
91
98
|
|
92
99
|
def test_invalid_latlong
|
93
|
-
mine =
|
100
|
+
mine = lookup_file('/invalid_latlong.json')
|
94
101
|
|
95
102
|
assert_exception(mine, 'invalid lat/lng')
|
96
103
|
end
|
97
104
|
|
98
105
|
def test_no_result_found
|
99
|
-
mine =
|
106
|
+
mine = lookup_file('/no_result_found.json')
|
100
107
|
|
101
108
|
assert_nil(mine.lookup(10, 10))
|
102
109
|
end
|
103
110
|
|
104
111
|
def test_invalid_parameter
|
105
|
-
mine =
|
112
|
+
mine = lookup_file('/invalid_parameter.json')
|
106
113
|
|
107
114
|
assert_exception(mine, 'error parsing parameter')
|
108
115
|
end
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'timezone/lookup/google'
|
4
4
|
require 'minitest/autorun'
|
5
5
|
require 'timecop'
|
6
|
+
require 'ostruct'
|
6
7
|
require_relative '../../http_test_client'
|
7
8
|
|
8
9
|
class TestGoogle < ::Minitest::Test
|
@@ -12,6 +13,10 @@ class TestGoogle < ::Minitest::Test
|
|
12
13
|
[-34.92771808058, 138.477041423321]
|
13
14
|
end
|
14
15
|
|
16
|
+
def lookup_file(file_name, &block)
|
17
|
+
lookup(File.open(File.join(mock_path, file_name)).read, &block)
|
18
|
+
end
|
19
|
+
|
15
20
|
def lookup(body = nil, &_block)
|
16
21
|
config = OpenStruct.new
|
17
22
|
config.api_key = 'MTIzYWJj'
|
@@ -33,7 +38,7 @@ class TestGoogle < ::Minitest::Test
|
|
33
38
|
end
|
34
39
|
|
35
40
|
def test_google_using_lat_long_coordinates
|
36
|
-
mine =
|
41
|
+
mine = lookup_file('/google_lat_lon_coords.txt')
|
37
42
|
|
38
43
|
assert_equal 'Australia/Adelaide', mine.lookup(*coordinates)
|
39
44
|
end
|
@@ -76,7 +81,7 @@ class TestGoogle < ::Minitest::Test
|
|
76
81
|
end
|
77
82
|
|
78
83
|
def test_no_result_found
|
79
|
-
mine =
|
84
|
+
mine = lookup_file('/google_no_result_found.json')
|
80
85
|
|
81
86
|
assert_nil(mine.lookup(26.188703, -78.987053))
|
82
87
|
end
|
@@ -8,7 +8,7 @@ class TestLookup < ::Minitest::Test
|
|
8
8
|
Timezone::Lookup.config(:test)
|
9
9
|
|
10
10
|
assert_equal Timezone::Lookup::Test,
|
11
|
-
|
11
|
+
Timezone::Lookup.lookup.class
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_geonames_config
|
@@ -17,10 +17,10 @@ class TestLookup < ::Minitest::Test
|
|
17
17
|
end
|
18
18
|
|
19
19
|
assert_equal Timezone::Lookup::Geonames,
|
20
|
-
|
20
|
+
Timezone::Lookup.lookup.class
|
21
21
|
|
22
22
|
assert_equal Timezone::NetHTTPClient,
|
23
|
-
|
23
|
+
Timezone::Lookup.lookup.config.request_handler
|
24
24
|
end
|
25
25
|
|
26
26
|
def test_google_config
|
@@ -29,10 +29,10 @@ class TestLookup < ::Minitest::Test
|
|
29
29
|
end
|
30
30
|
|
31
31
|
assert_equal Timezone::Lookup::Google,
|
32
|
-
|
32
|
+
Timezone::Lookup.lookup.class
|
33
33
|
|
34
34
|
assert_equal Timezone::NetHTTPClient,
|
35
|
-
|
35
|
+
Timezone::Lookup.lookup.config.request_handler
|
36
36
|
end
|
37
37
|
|
38
38
|
def test_custom_config
|
data/timezone.gemspec
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
# -*- encoding: utf-8 -*-
|
3
2
|
|
4
|
-
$:.push File.expand_path('
|
3
|
+
$:.push File.expand_path('lib', __dir__)
|
5
4
|
require 'timezone/version'
|
6
5
|
|
7
6
|
Gem::Specification.new do |s|
|
@@ -25,8 +24,11 @@ Gem::Specification.new do |s|
|
|
25
24
|
s.rdoc_options = ['--charset=UTF-8']
|
26
25
|
s.require_paths = ['lib']
|
27
26
|
|
27
|
+
s.add_runtime_dependency('ostruct', '~> 0.6')
|
28
|
+
|
28
29
|
s.add_development_dependency('minitest', '~> 5.8')
|
29
|
-
s.add_development_dependency('rake', '~>
|
30
|
-
s.add_development_dependency('rubocop', '=
|
30
|
+
s.add_development_dependency('rake', '~> 13')
|
31
|
+
s.add_development_dependency('rubocop', '= 1.5.1')
|
32
|
+
s.add_development_dependency('rubocop-performance', '= 1.5.1')
|
31
33
|
s.add_development_dependency('timecop', '~> 0.8')
|
32
34
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: timezone
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.26
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pan Thomakos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ostruct
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.6'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.6'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: minitest
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -30,28 +44,42 @@ dependencies:
|
|
30
44
|
requirements:
|
31
45
|
- - "~>"
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
47
|
+
version: '13'
|
34
48
|
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
52
|
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
54
|
+
version: '13'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rubocop
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
59
|
- - '='
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
61
|
+
version: 1.5.1
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.5.1
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop-performance
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.5.1
|
48
76
|
type: :development
|
49
77
|
prerelease: false
|
50
78
|
version_requirements: !ruby/object:Gem::Requirement
|
51
79
|
requirements:
|
52
80
|
- - '='
|
53
81
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
82
|
+
version: 1.5.1
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
84
|
name: timecop
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -76,8 +104,9 @@ extra_rdoc_files:
|
|
76
104
|
- README.markdown
|
77
105
|
- License.txt
|
78
106
|
files:
|
107
|
+
- ".codeclimate.yml"
|
79
108
|
- ".editorconfig"
|
80
|
-
- ".github/workflows/
|
109
|
+
- ".github/workflows/ci.yml"
|
81
110
|
- ".gitignore"
|
82
111
|
- ".rubocop.yml"
|
83
112
|
- CHANGES.markdown
|
@@ -747,10 +776,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
747
776
|
- !ruby/object:Gem::Version
|
748
777
|
version: '0'
|
749
778
|
requirements: []
|
750
|
-
rubygems_version: 3.
|
779
|
+
rubygems_version: 3.4.19
|
751
780
|
signing_key:
|
752
781
|
specification_version: 4
|
753
|
-
summary: timezone-1.3.
|
782
|
+
summary: timezone-1.3.26
|
754
783
|
test_files:
|
755
784
|
- test/data/Helsinki_rules_without_timestamps.json
|
756
785
|
- test/data/asia
|