timezone 0.99.2 → 1.0.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/CHANGES.markdown +6 -0
- data/README.markdown +1 -11
- data/Rakefile +3 -1
- data/data/America/Caracas +2 -1
- data/data/Asia/Almaty +51 -48
- data/data/Asia/Anadyr +3 -3
- data/data/Asia/Aqtau +50 -50
- data/data/Asia/Aqtobe +51 -49
- data/data/Asia/Baku +2 -2
- data/data/Asia/Barnaul +3 -3
- data/data/Asia/Chita +3 -3
- data/data/Asia/Irkutsk +3 -3
- data/data/Asia/Kamchatka +3 -3
- data/data/Asia/Khandyga +3 -3
- data/data/Asia/Krasnoyarsk +3 -3
- data/data/Asia/Magadan +5 -4
- data/data/Asia/Novokuznetsk +3 -3
- data/data/Asia/Novosibirsk +3 -3
- data/data/Asia/Omsk +3 -3
- data/data/Asia/Oral +51 -50
- data/data/Asia/Qyzylorda +51 -50
- data/data/Asia/Sakhalin +3 -3
- data/data/Asia/Srednekolymsk +3 -3
- data/data/Asia/Tomsk +68 -0
- data/data/Asia/Ust-Nera +3 -3
- data/data/Asia/Vladivostok +3 -3
- data/data/Asia/Yakutsk +3 -3
- data/data/Asia/Yekaterinburg +3 -3
- data/data/Asia/Yerevan +3 -3
- data/data/Europe/Astrakhan +2 -2
- data/data/Europe/Kaliningrad +3 -3
- data/data/Europe/Kirov +64 -0
- data/data/Europe/Minsk +2 -2
- data/data/Europe/Moscow +3 -3
- data/data/Europe/Samara +3 -3
- data/data/Europe/Ulyanovsk +3 -3
- data/data/Europe/Volgograd +2 -2
- data/data/W-SU +3 -3
- data/lib/timezone/error.rb +0 -4
- data/lib/timezone/lookup/basic.rb +1 -7
- data/lib/timezone/lookup/geonames.rb +7 -6
- data/lib/timezone/lookup/google.rb +2 -1
- data/lib/timezone/net_http_client.rb +1 -10
- data/lib/timezone/version.rb +1 -1
- data/lib/timezone/zone.rb +1 -122
- data/test/http_test_client.rb +1 -2
- data/test/mocks/{api_limit_reached.txt → api_limit_reached.json} +0 -0
- data/test/mocks/invalid_latlong.json +1 -0
- data/test/mocks/invalid_parameter.json +1 -0
- data/test/{basic_lookup_test.rb → timezone/lookup/test_basic.rb} +3 -1
- data/test/timezone/lookup/test_geonames.rb +33 -4
- data/test/timezone/test_zone.rb +211 -3
- data/timezone.gemspec +14 -13
- metadata +22 -26
- data/lib/timezone/active_support.rb +0 -156
- data/lib/timezone/configure.rb +0 -258
- data/test/geonames_lookup_test.rb +0 -56
- data/test/google_lookup_test.rb +0 -81
- data/test/test_lookup_test.rb +0 -41
- data/test/timezone_test.rb +0 -297
@@ -1,156 +0,0 @@
|
|
1
|
-
require 'timezone/deprecate'
|
2
|
-
|
3
|
-
module Timezone
|
4
|
-
# @deprecated Will be removed in the next release of `timezone` gem.
|
5
|
-
class ActiveSupport
|
6
|
-
TIMEZONE_MAPPING = {
|
7
|
-
'Pacific/Midway' => 'Midway Island',
|
8
|
-
'Pacific/Pago_Pago' => 'American Samoa',
|
9
|
-
'Pacific/Honolulu' => 'Hawaii',
|
10
|
-
'America/Juneau' => 'Alaska',
|
11
|
-
'America/Los_Angeles' => 'Pacific Time (US & Canada)',
|
12
|
-
'America/Tijuana' => 'Tijuana',
|
13
|
-
'America/Denver' => 'Mountain Time (US & Canada)',
|
14
|
-
'America/Phoenix' => 'Arizona',
|
15
|
-
'America/Chihuahua' => 'Chihuahua',
|
16
|
-
'America/Mazatlan' => 'Mazatlan',
|
17
|
-
'America/Chicago' => 'Central Time (US & Canada)',
|
18
|
-
'America/Regina' => 'Saskatchewan',
|
19
|
-
'America/Mexico_City' => 'Mexico City',
|
20
|
-
'America/Monterrey' => 'Monterrey',
|
21
|
-
'America/Guatemala' => 'Central America',
|
22
|
-
'America/New_York' => 'Eastern Time (US & Canada)',
|
23
|
-
'America/Indiana/Indianapolis' => 'Indiana (East)',
|
24
|
-
'America/Bogota' => 'Bogota',
|
25
|
-
'America/Lima' => 'Quito',
|
26
|
-
'America/Halifax' => 'Atlantic Time (Canada)',
|
27
|
-
'America/Caracas' => 'Caracas',
|
28
|
-
'America/La_Paz' => 'La Paz',
|
29
|
-
'America/Santiago' => 'Santiago',
|
30
|
-
'America/St_Johns' => 'Newfoundland',
|
31
|
-
'America/Sao_Paulo' => 'Brasilia',
|
32
|
-
'America/Argentina/Buenos_Aires' => 'Buenos Aires',
|
33
|
-
'America/Montevideo' => 'Montevideo',
|
34
|
-
'America/Guyana' => 'Georgetown',
|
35
|
-
'America/Godthab' => 'Greenland',
|
36
|
-
'Atlantic/South_Georgia' => 'Mid-Atlantic',
|
37
|
-
'Atlantic/Azores' => 'Azores',
|
38
|
-
'Atlantic/Cape_Verde' => 'Cape Verde Is.',
|
39
|
-
'Europe/Dublin' => 'Dublin',
|
40
|
-
'Europe/London' => 'London',
|
41
|
-
'Europe/Lisbon' => 'Lisbon',
|
42
|
-
'Africa/Casablanca' => 'Casablanca',
|
43
|
-
'Africa/Monrovia' => 'Monrovia',
|
44
|
-
'Etc/UTC' => 'UTC',
|
45
|
-
'Europe/Belgrade' => 'Belgrade',
|
46
|
-
'Europe/Bratislava' => 'Bratislava',
|
47
|
-
'Europe/Budapest' => 'Budapest',
|
48
|
-
'Europe/Ljubljana' => 'Ljubljana',
|
49
|
-
'Europe/Prague' => 'Prague',
|
50
|
-
'Europe/Sarajevo' => 'Sarajevo',
|
51
|
-
'Europe/Skopje' => 'Skopje',
|
52
|
-
'Europe/Warsaw' => 'Warsaw',
|
53
|
-
'Europe/Zagreb' => 'Zagreb',
|
54
|
-
'Europe/Brussels' => 'Brussels',
|
55
|
-
'Europe/Copenhagen' => 'Copenhagen',
|
56
|
-
'Europe/Madrid' => 'Madrid',
|
57
|
-
'Europe/Paris' => 'Paris',
|
58
|
-
'Europe/Amsterdam' => 'Amsterdam',
|
59
|
-
'Europe/Berlin' => 'Bern',
|
60
|
-
'Europe/Rome' => 'Rome',
|
61
|
-
'Europe/Stockholm' => 'Stockholm',
|
62
|
-
'Europe/Vienna' => 'Vienna',
|
63
|
-
'Africa/Algiers' => 'West Central Africa',
|
64
|
-
'Europe/Bucharest' => 'Bucharest',
|
65
|
-
'Africa/Cairo' => 'Cairo',
|
66
|
-
'Europe/Helsinki' => 'Helsinki',
|
67
|
-
'Europe/Kiev' => 'Kyiv',
|
68
|
-
'Europe/Riga' => 'Riga',
|
69
|
-
'Europe/Sofia' => 'Sofia',
|
70
|
-
'Europe/Tallinn' => 'Tallinn',
|
71
|
-
'Europe/Vilnius' => 'Vilnius',
|
72
|
-
'Europe/Athens' => 'Athens',
|
73
|
-
'Europe/Istanbul' => 'Istanbul',
|
74
|
-
'Europe/Minsk' => 'Minsk',
|
75
|
-
'Asia/Jerusalem' => 'Jerusalem',
|
76
|
-
'Africa/Harare' => 'Harare',
|
77
|
-
'Africa/Johannesburg' => 'Pretoria',
|
78
|
-
'Europe/Kaliningrad' => 'Kaliningrad',
|
79
|
-
'Europe/Moscow' => 'St. Petersburg',
|
80
|
-
'Europe/Volgograd' => 'Volgograd',
|
81
|
-
'Europe/Samara' => 'Samara',
|
82
|
-
'Asia/Kuwait' => 'Kuwait',
|
83
|
-
'Asia/Riyadh' => 'Riyadh',
|
84
|
-
'Africa/Nairobi' => 'Nairobi',
|
85
|
-
'Asia/Baghdad' => 'Baghdad',
|
86
|
-
'Asia/Tehran' => 'Tehran',
|
87
|
-
'Asia/Muscat' => 'Muscat',
|
88
|
-
'Asia/Baku' => 'Baku',
|
89
|
-
'Asia/Tbilisi' => 'Tbilisi',
|
90
|
-
'Asia/Yerevan' => 'Yerevan',
|
91
|
-
'Asia/Kabul' => 'Kabul',
|
92
|
-
'Asia/Yekaterinburg' => 'Ekaterinburg',
|
93
|
-
'Asia/Karachi' => 'Karachi',
|
94
|
-
'Asia/Tashkent' => 'Tashkent',
|
95
|
-
'Asia/Kolkata' => 'New Delhi',
|
96
|
-
'Asia/Kathmandu' => 'Kathmandu',
|
97
|
-
'Asia/Dhaka' => 'Dhaka',
|
98
|
-
'Asia/Colombo' => 'Sri Jayawardenepura',
|
99
|
-
'Asia/Almaty' => 'Almaty',
|
100
|
-
'Asia/Novosibirsk' => 'Novosibirsk',
|
101
|
-
'Asia/Rangoon' => 'Rangoon',
|
102
|
-
'Asia/Bangkok' => 'Hanoi',
|
103
|
-
'Asia/Jakarta' => 'Jakarta',
|
104
|
-
'Asia/Krasnoyarsk' => 'Krasnoyarsk',
|
105
|
-
'Asia/Shanghai' => 'Beijing',
|
106
|
-
'Asia/Chongqing' => 'Chongqing',
|
107
|
-
'Asia/Hong_Kong' => 'Hong Kong',
|
108
|
-
'Asia/Urumqi' => 'Urumqi',
|
109
|
-
'Asia/Kuala_Lumpur' => 'Kuala Lumpur',
|
110
|
-
'Asia/Singapore' => 'Singapore',
|
111
|
-
'Asia/Taipei' => 'Taipei',
|
112
|
-
'Australia/Perth' => 'Perth',
|
113
|
-
'Asia/Irkutsk' => 'Irkutsk',
|
114
|
-
'Asia/Ulaanbaatar' => 'Ulaanbaatar',
|
115
|
-
'Asia/Seoul' => 'Seoul',
|
116
|
-
'Asia/Tokyo' => 'Tokyo',
|
117
|
-
'Asia/Yakutsk' => 'Yakutsk',
|
118
|
-
'Australia/Darwin' => 'Darwin',
|
119
|
-
'Australia/Adelaide' => 'Adelaide',
|
120
|
-
'Australia/Melbourne' => 'Melbourne',
|
121
|
-
'Australia/Sydney' => 'Sydney',
|
122
|
-
'Australia/Brisbane' => 'Brisbane',
|
123
|
-
'Australia/Hobart' => 'Hobart',
|
124
|
-
'Asia/Vladivostok' => 'Vladivostok',
|
125
|
-
'Pacific/Guam' => 'Guam',
|
126
|
-
'Pacific/Port_Moresby' => 'Port Moresby',
|
127
|
-
'Asia/Magadan' => 'Magadan',
|
128
|
-
'Asia/Srednekolymsk' => 'Srednekolymsk',
|
129
|
-
'Pacific/Guadalcanal' => 'Solomon Is.',
|
130
|
-
'Pacific/Noumea' => 'New Caledonia',
|
131
|
-
'Pacific/Fiji' => 'Fiji',
|
132
|
-
'Asia/Kamchatka' => 'Kamchatka',
|
133
|
-
'Pacific/Majuro' => 'Marshall Is.',
|
134
|
-
'Pacific/Auckland' => 'Wellington',
|
135
|
-
'Pacific/Tongatapu' => "Nuku'alofa",
|
136
|
-
'Pacific/Fakaofo' => 'Tokelau Is.',
|
137
|
-
'Pacific/Chatham' => 'Chatham Is.',
|
138
|
-
'Pacific/Apia' => 'Samoa'
|
139
|
-
}.freeze
|
140
|
-
|
141
|
-
# @deprecated Will be removed in the next release of `timezone gem.
|
142
|
-
def self.format(zone, internal = false)
|
143
|
-
unless internal
|
144
|
-
Deprecate.call(
|
145
|
-
self,
|
146
|
-
:format,
|
147
|
-
'[DEPRECATE] `Timezone::ActiveSupport::format` will be ' \
|
148
|
-
'removed in the next release of the `timezone` gem. There ' \
|
149
|
-
'will be no replacement.'.freeze
|
150
|
-
)
|
151
|
-
end
|
152
|
-
|
153
|
-
TIMEZONE_MAPPING[zone] || zone
|
154
|
-
end
|
155
|
-
end
|
156
|
-
end
|
data/lib/timezone/configure.rb
DELETED
@@ -1,258 +0,0 @@
|
|
1
|
-
require 'timezone/net_http_client'
|
2
|
-
require 'timezone/lookup'
|
3
|
-
require 'timezone/deprecate'
|
4
|
-
|
5
|
-
module Timezone
|
6
|
-
# @deprecated `Timezone::Configure` will be removed in the release
|
7
|
-
# of the `timezone gem. Use `Timezone::Lookup::config` instead.
|
8
|
-
#
|
9
|
-
# The old way to configure this gem.
|
10
|
-
# rubocop:disable Style/ClassVars
|
11
|
-
class Configure
|
12
|
-
DEPRECATE = '[DEPRECATED] `Timezone::Configure` will be removed ' \
|
13
|
-
'in the release of the `timezone gem. Use `Timezone::Lookup` ' \
|
14
|
-
'instead.'.freeze
|
15
|
-
|
16
|
-
# @deprecated `Timezone::Configure` will be removed in the release
|
17
|
-
# of the `timezone gem. Use `Timezone::Lookup instead.
|
18
|
-
def self.google_api_key
|
19
|
-
@@google_api_key ||= nil
|
20
|
-
end
|
21
|
-
|
22
|
-
# @deprecated `Timezone::Configure` will be removed in the release
|
23
|
-
# of the `timezone gem. Use `Timezone::Lookup instead.
|
24
|
-
def self.google_api_key=(api_key)
|
25
|
-
@@google_api_key = api_key
|
26
|
-
end
|
27
|
-
|
28
|
-
# @deprecated `Timezone::Configure` will be removed in the release
|
29
|
-
# of the `timezone gem. Use `Timezone::Lookup instead.
|
30
|
-
def self.google_client_id
|
31
|
-
@@google_client_id ||= nil
|
32
|
-
end
|
33
|
-
|
34
|
-
# @deprecated `Timezone::Configure` will be removed in the release
|
35
|
-
# of the `timezone gem. Use `Timezone::Lookup instead.
|
36
|
-
def self.google_client_id=(client)
|
37
|
-
@@google_client_id = client
|
38
|
-
end
|
39
|
-
|
40
|
-
# @deprecated `Timezone::Configure` will be removed in the release
|
41
|
-
# of the `timezone gem. Use `Timezone::Lookup instead.
|
42
|
-
def self.use_google?
|
43
|
-
!google_api_key.nil?
|
44
|
-
end
|
45
|
-
|
46
|
-
# @deprecated `Timezone::Configure` will be removed in the release
|
47
|
-
# of the `timezone gem. Use `Timezone::Lookup instead.
|
48
|
-
def self.use_google_enterprise?
|
49
|
-
use_google? && !google_client_id.nil?
|
50
|
-
end
|
51
|
-
|
52
|
-
# @deprecated `Timezone::Configure` will be removed in the release
|
53
|
-
# of the `timezone gem. Use `Timezone::Lookup instead.
|
54
|
-
def self.lookup=(lookup)
|
55
|
-
@lookup = lookup && lookup.new(self)
|
56
|
-
end
|
57
|
-
|
58
|
-
# @deprecated `Timezone::Configure` will be removed in the release
|
59
|
-
# of the `timezone gem. Use `Timezone::Lookup instead.
|
60
|
-
def self.lookup
|
61
|
-
return @lookup if @lookup
|
62
|
-
|
63
|
-
use_google? ? google_lookup : geonames_lookup
|
64
|
-
end
|
65
|
-
|
66
|
-
# Responsible for mapping old configuration options to new
|
67
|
-
# configuration style for forwards-compatability with the
|
68
|
-
# updated Google lookup.
|
69
|
-
class GoogleConfigMapper
|
70
|
-
def initialize(config)
|
71
|
-
@config = config
|
72
|
-
end
|
73
|
-
|
74
|
-
def protocol; @config.protocol; end
|
75
|
-
|
76
|
-
def url; @config.url; end
|
77
|
-
|
78
|
-
def http_client; @config.http_client; end
|
79
|
-
|
80
|
-
def api_key; @config.google_api_key; end
|
81
|
-
|
82
|
-
def client_id; @config.google_client_id; end
|
83
|
-
|
84
|
-
def request_handler; nil; end
|
85
|
-
end
|
86
|
-
|
87
|
-
private_constant :GoogleConfigMapper
|
88
|
-
|
89
|
-
# @deprecated `Timezone::Configure` will be removed in the release
|
90
|
-
# of the `timezone gem. Use `Timezone::Lookup instead.
|
91
|
-
def self.google_lookup
|
92
|
-
@google_lookup ||=
|
93
|
-
Timezone::Lookup::Google.new(GoogleConfigMapper.new(self))
|
94
|
-
end
|
95
|
-
|
96
|
-
# Responsible for mapping old configuration options to new
|
97
|
-
# configuration style for forwards-compatability with the
|
98
|
-
# updated Geonames lookup.
|
99
|
-
class GeonamesConfigMapper
|
100
|
-
def initialize(config)
|
101
|
-
@config = config
|
102
|
-
end
|
103
|
-
|
104
|
-
def protocol; @config.protocol; end
|
105
|
-
|
106
|
-
def url; @config.url; end
|
107
|
-
|
108
|
-
def username; @config.username; end
|
109
|
-
|
110
|
-
def http_client; @config.http_client; end
|
111
|
-
|
112
|
-
def request_handler; nil; end
|
113
|
-
end
|
114
|
-
|
115
|
-
private_constant :GeonamesConfigMapper
|
116
|
-
|
117
|
-
# @deprecated `Timezone::Configure` will be removed in the release
|
118
|
-
# of the `timezone gem. Use `Timezone::Lookup instead.
|
119
|
-
def self.geonames_lookup
|
120
|
-
@geonames_lookup ||=
|
121
|
-
Timezone::Lookup::Geonames.new(GeonamesConfigMapper.new(self))
|
122
|
-
end
|
123
|
-
|
124
|
-
# @deprecated `Timezone::Configure` will be removed in the release
|
125
|
-
# of the `timezone gem. Use `Timezone::Lookup instead.
|
126
|
-
def self.geonames_url
|
127
|
-
@@geonames_url ||= 'api.geonames.org'
|
128
|
-
end
|
129
|
-
|
130
|
-
# @deprecated `Timezone::Configure` will be removed in the release
|
131
|
-
# of the `timezone gem. Use `Timezone::Lookup instead.
|
132
|
-
def self.geonames_url=(url)
|
133
|
-
@@geonames_url = url
|
134
|
-
end
|
135
|
-
|
136
|
-
# @deprecated `Timezone::Configure` will be removed in the release
|
137
|
-
# of the `timezone gem. Use `Timezone::Lookup instead.
|
138
|
-
def self.url=(url)
|
139
|
-
self.geonames_url = url
|
140
|
-
end
|
141
|
-
|
142
|
-
# @deprecated `Timezone::Configure` will be removed in the release
|
143
|
-
# of the `timezone gem. Use `Timezone::Lookup instead.
|
144
|
-
def self.google_url
|
145
|
-
@@google_url ||= 'maps.googleapis.com'
|
146
|
-
end
|
147
|
-
|
148
|
-
# @deprecated `Timezone::Configure` will be removed in the release
|
149
|
-
# of the `timezone gem. Use `Timezone::Lookup instead.
|
150
|
-
def self.google_url=(url)
|
151
|
-
@@google_url = url
|
152
|
-
end
|
153
|
-
|
154
|
-
# @deprecated `Timezone::Configure` will be removed in the release
|
155
|
-
# of the `timezone gem. Use `Timezone::Lookup instead.
|
156
|
-
def self.url
|
157
|
-
use_google? ? google_url : geonames_url
|
158
|
-
end
|
159
|
-
|
160
|
-
# @deprecated `Timezone::Configure` will be removed in the release
|
161
|
-
# of the `timezone gem. Use `Timezone::Lookup instead.
|
162
|
-
def self.geonames_protocol=(protocol)
|
163
|
-
@@geonames_protocol = protocol
|
164
|
-
end
|
165
|
-
|
166
|
-
# @deprecated `Timezone::Configure` will be removed in the release
|
167
|
-
# of the `timezone gem. Use `Timezone::Lookup instead.
|
168
|
-
def self.geonames_protocol
|
169
|
-
@@geonames_protocol ||= 'http'
|
170
|
-
end
|
171
|
-
|
172
|
-
# @deprecated `Timezone::Configure` will be removed in the release
|
173
|
-
# of the `timezone gem. Use `Timezone::Lookup instead.
|
174
|
-
def self.google_protocol=(protocol)
|
175
|
-
@@google_protocol = protocol
|
176
|
-
end
|
177
|
-
|
178
|
-
# @deprecated `Timezone::Configure` will be removed in the release
|
179
|
-
# of the `timezone gem. Use `Timezone::Lookup instead.
|
180
|
-
def self.google_protocol
|
181
|
-
@@google_protocol ||= 'https'
|
182
|
-
end
|
183
|
-
|
184
|
-
# @deprecated `Timezone::Configure` will be removed in the release
|
185
|
-
# of the `timezone gem. Use `Timezone::Lookup instead.
|
186
|
-
def self.protocol
|
187
|
-
use_google? ? google_protocol : geonames_protocol
|
188
|
-
end
|
189
|
-
|
190
|
-
# @deprecated `Timezone::Configure` will be removed in the release
|
191
|
-
# of the `timezone gem. Use `Timezone::Lookup instead.
|
192
|
-
def self.http_client
|
193
|
-
@@http_client ||= Timezone::NetHTTPClient
|
194
|
-
end
|
195
|
-
|
196
|
-
# @deprecated `Timezone::Configure` will be removed in the release
|
197
|
-
# of the `timezone gem. Use `Timezone::Lookup instead.
|
198
|
-
def self.http_client=(client)
|
199
|
-
@@http_client = client
|
200
|
-
end
|
201
|
-
|
202
|
-
# @deprecated `Timezone::Configure` will be removed in the release
|
203
|
-
# of the `timezone gem. Use `Timezone::Lookup instead.
|
204
|
-
def self.username
|
205
|
-
@@username ||= nil
|
206
|
-
end
|
207
|
-
|
208
|
-
# @deprecated `Timezone::Configure` will be removed in the release
|
209
|
-
# of the `timezone gem. Use `Timezone::Lookup instead.
|
210
|
-
def self.username=(username)
|
211
|
-
@@username = username
|
212
|
-
end
|
213
|
-
|
214
|
-
# @deprecated `Timezone::Configure` will be removed in the release
|
215
|
-
# of the `timezone gem. Use `Timezone::Lookup instead.
|
216
|
-
def self.begin
|
217
|
-
Deprecate.call(self, :begin, DEPRECATE)
|
218
|
-
yield self
|
219
|
-
end
|
220
|
-
|
221
|
-
# @deprecated `Timezone::Configure` will be removed in the release
|
222
|
-
# of the `timezone gem. Use `Timezone::Lookup instead.
|
223
|
-
def self.replace(what, with = {})
|
224
|
-
replacements # instantiate @@replacements
|
225
|
-
@@replacements[what] = with[:with]
|
226
|
-
end
|
227
|
-
|
228
|
-
# @deprecated `Timezone::Configure` will be removed in the release
|
229
|
-
# of the `timezone gem. Use `Timezone::Lookup instead.
|
230
|
-
def self.replacements
|
231
|
-
@@replacements ||= {}
|
232
|
-
end
|
233
|
-
|
234
|
-
# @deprecated `Timezone::Configure` will be removed in the release
|
235
|
-
# of the `timezone gem. Use `Timezone::Lookup instead.
|
236
|
-
def self.default_for_list
|
237
|
-
@@default_list ||= nil
|
238
|
-
end
|
239
|
-
|
240
|
-
# @deprecated `Timezone::Configure` will be removed in the release
|
241
|
-
# of the `timezone gem. Use `Timezone::Lookup instead.
|
242
|
-
def self.default_for_list=(*list)
|
243
|
-
@@default_list = list.flatten!
|
244
|
-
end
|
245
|
-
|
246
|
-
# @deprecated `Timezone::Configure` will be removed in the release
|
247
|
-
# of the `timezone gem. Use `Timezone::Lookup instead.
|
248
|
-
def self.order_list_by
|
249
|
-
@@order_by ||= :utc_offset
|
250
|
-
end
|
251
|
-
|
252
|
-
# @deprecated `Timezone::Configure` will be removed in the release
|
253
|
-
# of the `timezone gem. Use `Timezone::Lookup instead.
|
254
|
-
def self.order_list_by=(order)
|
255
|
-
@@order_by = order
|
256
|
-
end
|
257
|
-
end
|
258
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
require 'timezone/configure'
|
2
|
-
require 'timezone/lookup/geonames'
|
3
|
-
require 'minitest/autorun'
|
4
|
-
require_relative 'http_test_client'
|
5
|
-
|
6
|
-
class GeonamesLookupTest < ::Minitest::Unit::TestCase
|
7
|
-
def setup
|
8
|
-
Timezone::Configure.begin do |c|
|
9
|
-
c.google_api_key = nil
|
10
|
-
c.http_client = HTTPTestClient
|
11
|
-
c.username = 'timezone'
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def coordinates
|
16
|
-
[-34.92771808058, 138.477041423321]
|
17
|
-
end
|
18
|
-
|
19
|
-
def lookup
|
20
|
-
::Timezone::Configure.lookup
|
21
|
-
end
|
22
|
-
|
23
|
-
def clear
|
24
|
-
Timezone::Configure.instance_variable_set(:@lookup, nil)
|
25
|
-
Timezone::Configure.instance_variable_set(:@google_lookup, nil)
|
26
|
-
Timezone::Configure.instance_variable_set(:@geonames_lookup, nil)
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_missing_username
|
30
|
-
clear
|
31
|
-
Timezone::Configure.begin { |c| c.username = nil }
|
32
|
-
assert_raises(::Timezone::Error::InvalidConfig) { lookup }
|
33
|
-
ensure
|
34
|
-
Timezone::Configure.begin { |c| c.username = 'timezone' }
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_lookup
|
38
|
-
lookup.client.body = File.open(mock_path + '/lat_lon_coords.txt').read
|
39
|
-
|
40
|
-
assert_equal 'Australia/Adelaide', lookup.lookup(*coordinates)
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_api_limit
|
44
|
-
lookup.client.body = File.open(mock_path + '/api_limit_reached.txt').read
|
45
|
-
|
46
|
-
assert_raises Timezone::Error::GeoNames, 'api limit reached' do
|
47
|
-
lookup.lookup(*coordinates)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
private
|
52
|
-
|
53
|
-
def mock_path
|
54
|
-
File.expand_path(File.join(File.dirname(__FILE__), 'mocks'))
|
55
|
-
end
|
56
|
-
end
|