ziptz 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +30 -28
- data/README.md +2 -2
- data/data/dst.data +0 -1
- data/data/tz.data +0 -1
- data/lib/ziptz.rb +12 -9
- data/spec/ziptz_spec.rb +12 -20
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb4a040a495a6e662dd381cd1139ad36adf6bd02b2ef74cacab9c8c17d94fdfe
|
4
|
+
data.tar.gz: 1bf6d78106c9fd549c178a3b091d2ed7bc3f13b7d535eaf3e5a511ebf8614644
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1cd28d0d78664eb7b4a050f7d1e732a8be9fbed14d233b1837e6b202ece32d7722223e6643f785dd0e89580708148b2767b39151cfcab7adcd1da3e2a39d0ed8
|
7
|
+
data.tar.gz: b52d7e5a0977761a97f35a29b4a573f7bb7f4f717f3f1db79dc87d1534a64531e467be10b724e69ba232e22e031bb43359dc53daeb651a9dd8388d7954a342b8
|
data/Gemfile.lock
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ziptz (2.0.
|
4
|
+
ziptz (2.0.2)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
activemodel (5.2.
|
10
|
-
activesupport (= 5.2.
|
11
|
-
activerecord (5.2.
|
12
|
-
activemodel (= 5.2.
|
13
|
-
activesupport (= 5.2.
|
9
|
+
activemodel (5.2.1)
|
10
|
+
activesupport (= 5.2.1)
|
11
|
+
activerecord (5.2.1)
|
12
|
+
activemodel (= 5.2.1)
|
13
|
+
activesupport (= 5.2.1)
|
14
14
|
arel (>= 9.0)
|
15
|
-
activesupport (5.2.
|
15
|
+
activesupport (5.2.1)
|
16
16
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
17
|
i18n (>= 0.7, < 2)
|
18
18
|
minitest (~> 5.1)
|
@@ -23,7 +23,7 @@ GEM
|
|
23
23
|
coderay (1.1.2)
|
24
24
|
concurrent-ruby (1.0.5)
|
25
25
|
diff-lcs (1.3)
|
26
|
-
ffi (1.9.
|
26
|
+
ffi (1.9.25)
|
27
27
|
formatador (0.2.5)
|
28
28
|
guard (2.14.2)
|
29
29
|
formatador (>= 0.2.4)
|
@@ -39,8 +39,9 @@ GEM
|
|
39
39
|
guard (~> 2.1)
|
40
40
|
guard-compat (~> 1.1)
|
41
41
|
rspec (>= 2.99.0, < 4.0)
|
42
|
-
i18n (1.0
|
42
|
+
i18n (1.1.0)
|
43
43
|
concurrent-ruby (~> 1.0)
|
44
|
+
jaro_winkler (1.5.1)
|
44
45
|
listen (3.1.5)
|
45
46
|
rb-fsevent (~> 0.9, >= 0.9.4)
|
46
47
|
rb-inotify (~> 0.9, >= 0.9.7)
|
@@ -48,15 +49,15 @@ GEM
|
|
48
49
|
lumberjack (1.0.13)
|
49
50
|
method_source (0.9.0)
|
50
51
|
minitest (5.11.3)
|
51
|
-
mysql2 (0.5.
|
52
|
+
mysql2 (0.5.2)
|
52
53
|
nenv (0.3.0)
|
53
54
|
notiffany (0.1.1)
|
54
55
|
nenv (~> 0.1)
|
55
56
|
shellany (~> 0.0)
|
56
57
|
parallel (1.12.1)
|
57
|
-
parser (2.5.1.
|
58
|
+
parser (2.5.1.2)
|
58
59
|
ast (~> 2.4.0)
|
59
|
-
powerpack (0.1.
|
60
|
+
powerpack (0.1.2)
|
60
61
|
pry (0.11.3)
|
61
62
|
coderay (~> 1.1.0)
|
62
63
|
method_source (~> 0.9.0)
|
@@ -65,34 +66,35 @@ GEM
|
|
65
66
|
rb-fsevent (0.10.3)
|
66
67
|
rb-inotify (0.9.10)
|
67
68
|
ffi (>= 0.5.0, < 2)
|
68
|
-
rspec (3.
|
69
|
-
rspec-core (~> 3.
|
70
|
-
rspec-expectations (~> 3.
|
71
|
-
rspec-mocks (~> 3.
|
72
|
-
rspec-core (3.
|
73
|
-
rspec-support (~> 3.
|
74
|
-
rspec-expectations (3.
|
69
|
+
rspec (3.8.0)
|
70
|
+
rspec-core (~> 3.8.0)
|
71
|
+
rspec-expectations (~> 3.8.0)
|
72
|
+
rspec-mocks (~> 3.8.0)
|
73
|
+
rspec-core (3.8.0)
|
74
|
+
rspec-support (~> 3.8.0)
|
75
|
+
rspec-expectations (3.8.1)
|
75
76
|
diff-lcs (>= 1.2.0, < 2.0)
|
76
|
-
rspec-support (~> 3.
|
77
|
-
rspec-mocks (3.
|
77
|
+
rspec-support (~> 3.8.0)
|
78
|
+
rspec-mocks (3.8.0)
|
78
79
|
diff-lcs (>= 1.2.0, < 2.0)
|
79
|
-
rspec-support (~> 3.
|
80
|
-
rspec-support (3.
|
81
|
-
rubocop (0.
|
80
|
+
rspec-support (~> 3.8.0)
|
81
|
+
rspec-support (3.8.0)
|
82
|
+
rubocop (0.58.2)
|
83
|
+
jaro_winkler (~> 1.5.1)
|
82
84
|
parallel (~> 1.10)
|
83
|
-
parser (>= 2.5)
|
85
|
+
parser (>= 2.5, != 2.5.1.1)
|
84
86
|
powerpack (~> 0.1)
|
85
87
|
rainbow (>= 2.2.2, < 4.0)
|
86
88
|
ruby-progressbar (~> 1.7)
|
87
89
|
unicode-display_width (~> 1.0, >= 1.0.1)
|
88
|
-
ruby-progressbar (1.
|
90
|
+
ruby-progressbar (1.10.0)
|
89
91
|
ruby_dep (1.5.0)
|
90
92
|
shellany (0.0.1)
|
91
93
|
thor (0.20.0)
|
92
94
|
thread_safe (0.3.6)
|
93
95
|
tzinfo (1.2.5)
|
94
96
|
thread_safe (~> 0.1)
|
95
|
-
unicode-display_width (1.
|
97
|
+
unicode-display_width (1.4.0)
|
96
98
|
|
97
99
|
PLATFORMS
|
98
100
|
ruby
|
@@ -109,4 +111,4 @@ DEPENDENCIES
|
|
109
111
|
ziptz!
|
110
112
|
|
111
113
|
BUNDLED WITH
|
112
|
-
1.16.
|
114
|
+
1.16.4
|
data/README.md
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# Ziptz
|
2
2
|
[![Version](http://img.shields.io/gem/v/ziptz.svg?style=flat)](https://rubygems.org/gems/ziptz)
|
3
3
|
[![Build Status](http://img.shields.io/travis/infused/ziptz/master.svg?style=flat)](http://travis-ci.org/infused/ziptz)
|
4
|
-
[![Dependency Status](http://img.shields.io/gemnasium/infused/ziptz.svg?style=flat)](https://gemnasium.com/infused/ziptz)
|
5
4
|
[![Total Downloads](https://img.shields.io/gem/dt/ziptz.svg)](https://rubygems.org/gems/ziptz/)
|
5
|
+
[![License](https://img.shields.io/github/license/infused/ziptz.svg)](https://github.com/infused/ziptz)
|
6
6
|
|
7
7
|
Get time zone and daylight saving time for any US ZIP code.
|
8
8
|
|
9
|
-
<i>ZIP codes are up to date as of <b>
|
9
|
+
<i>ZIP codes are up to date as of <b>September 2018</b>.</i>
|
10
10
|
|
11
11
|
## Installation
|
12
12
|
|
data/data/dst.data
CHANGED
@@ -29182,7 +29182,6 @@
|
|
29182
29182
|
68005=1
|
29183
29183
|
68007=1
|
29184
29184
|
68008=1
|
29185
|
-
68009=1
|
29186
29185
|
68010=1
|
29187
29186
|
68014=1
|
29188
29187
|
68015=1
|
data/data/tz.data
CHANGED
@@ -29182,7 +29182,6 @@
|
|
29182
29182
|
68005=6
|
29183
29183
|
68007=6
|
29184
29184
|
68008=6
|
29185
|
-
68009=6
|
29186
29185
|
68010=6
|
29187
29186
|
68014=6
|
29188
29187
|
68015=6
|
data/lib/ziptz.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
|
3
3
|
class Ziptz
|
4
|
-
VERSION = '2.0.
|
4
|
+
VERSION = '2.0.2'
|
5
5
|
|
6
6
|
TZ_INFO = {
|
7
7
|
'0' => {name: 'APO/FPO (time zone unknown)', offset: 0},
|
@@ -19,11 +19,6 @@ class Ziptz
|
|
19
19
|
'16' => {name: 'Pacific/Pohnpei', offset: 11}
|
20
20
|
}
|
21
21
|
|
22
|
-
def initialize
|
23
|
-
@tz = load_tz_data
|
24
|
-
@dst = load_dst_data
|
25
|
-
end
|
26
|
-
|
27
22
|
def time_zone_name(zip)
|
28
23
|
hash = time_zone_info(zip)
|
29
24
|
hash && hash[:name]
|
@@ -35,7 +30,7 @@ class Ziptz
|
|
35
30
|
end
|
36
31
|
|
37
32
|
def time_zone_uses_dst?(zip)
|
38
|
-
|
33
|
+
dst[zip.to_s]
|
39
34
|
end
|
40
35
|
|
41
36
|
def zips(tz_name)
|
@@ -49,8 +44,16 @@ class Ziptz
|
|
49
44
|
|
50
45
|
protected
|
51
46
|
|
47
|
+
def tz
|
48
|
+
@tz ||= load_tz_data
|
49
|
+
end
|
50
|
+
|
51
|
+
def dst
|
52
|
+
@dst ||= load_dst_data
|
53
|
+
end
|
54
|
+
|
52
55
|
def zips_by_code(tz_code)
|
53
|
-
|
56
|
+
tz.select { |_, v| v == tz_code.to_s }.keys.sort
|
54
57
|
end
|
55
58
|
|
56
59
|
def time_zone_info(zip)
|
@@ -58,7 +61,7 @@ class Ziptz
|
|
58
61
|
end
|
59
62
|
|
60
63
|
def get_time_zone(zip)
|
61
|
-
|
64
|
+
tz[zip.to_s]
|
62
65
|
end
|
63
66
|
|
64
67
|
def tz_name_to_code
|
data/spec/ziptz_spec.rb
CHANGED
@@ -1,71 +1,63 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Ziptz do
|
4
|
-
|
5
|
-
let(:ziptz) { Ziptz.new }
|
4
|
+
before(:all) { @ziptz = Ziptz.new }
|
6
5
|
|
6
|
+
describe 'when inspected' do
|
7
7
|
it 'does not show internal instance variables' do
|
8
|
-
expect(ziptz.inspect).to match
|
8
|
+
expect(@ziptz.inspect).to match(/#<Ziptz:\d+>/)
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
12
|
describe '#time_zone_name' do
|
13
|
-
let(:ziptz) { Ziptz.new }
|
14
|
-
|
15
13
|
context 'when given a 5-digit zipcode' do
|
16
14
|
it 'returns the time zone number' do
|
17
|
-
expect(ziptz.time_zone_name('97034')).to eq 'America/Los_Angeles'
|
15
|
+
expect(@ziptz.time_zone_name('97034')).to eq 'America/Los_Angeles'
|
18
16
|
end
|
19
17
|
end
|
20
18
|
|
21
19
|
context 'when there is no matching zipcode' do
|
22
20
|
it 'returns nil' do
|
23
|
-
expect(ziptz.time_zone_name('xyz')).to be_nil
|
21
|
+
expect(@ziptz.time_zone_name('xyz')).to be_nil
|
24
22
|
end
|
25
23
|
end
|
26
24
|
end
|
27
25
|
|
28
26
|
describe '#time_zone_uses_dst?' do
|
29
|
-
let(:ziptz) { Ziptz.new }
|
30
|
-
|
31
27
|
context 'when given a 5-digit zipcode' do
|
32
28
|
it 'returns the time zone number' do
|
33
|
-
expect(ziptz.time_zone_name('97034')).to eq 'America/Los_Angeles'
|
29
|
+
expect(@ziptz.time_zone_name('97034')).to eq 'America/Los_Angeles'
|
34
30
|
end
|
35
31
|
end
|
36
32
|
end
|
37
33
|
|
38
34
|
describe '#time_zone_offset' do
|
39
|
-
let(:ziptz) { Ziptz.new }
|
40
|
-
|
41
35
|
context 'when given a 5-digit zipcode' do
|
42
36
|
it 'returns a boolean' do
|
43
|
-
expect(ziptz.time_zone_uses_dst?('97034')).to eq true
|
44
|
-
expect(ziptz.time_zone_uses_dst?('85004')).to eq false
|
37
|
+
expect(@ziptz.time_zone_uses_dst?('97034')).to eq true
|
38
|
+
expect(@ziptz.time_zone_uses_dst?('85004')).to eq false
|
45
39
|
end
|
46
40
|
end
|
47
41
|
|
48
42
|
context 'when there is no matching zipcode' do
|
49
43
|
it 'returns nil' do
|
50
|
-
expect(ziptz.time_zone_offset('xyz')).to be_nil
|
44
|
+
expect(@ziptz.time_zone_offset('xyz')).to be_nil
|
51
45
|
end
|
52
46
|
end
|
53
47
|
end
|
54
48
|
|
55
49
|
describe '#zips' do
|
56
50
|
context 'when given a time zone' do
|
57
|
-
let(:ziptz) { Ziptz.new }
|
58
|
-
|
59
51
|
it 'returns an array of zip codes' do
|
60
|
-
expect(ziptz.zips('Pacific/Pago_Pago')).to eq %w
|
52
|
+
expect(@ziptz.zips('Pacific/Pago_Pago')).to eq %w[96799]
|
61
53
|
end
|
62
54
|
|
63
55
|
it 'is case-insensitive' do
|
64
|
-
expect(ziptz.zips('Pacific/Pago_Pago')).to eq %w
|
56
|
+
expect(@ziptz.zips('Pacific/Pago_Pago')).to eq %w[96799]
|
65
57
|
end
|
66
58
|
|
67
59
|
it 'returns nil for unknown time zones' do
|
68
|
-
expect(ziptz.zips('Glark')).to be_nil
|
60
|
+
expect(@ziptz.zips('Glark')).to be_nil
|
69
61
|
end
|
70
62
|
end
|
71
63
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ziptz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keith Morrison
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Get timezone info for all 5-digit US zip codes
|
14
14
|
email: keithm@infused.org
|