ziptz 2.0.12 → 2.0.13
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/Gemfile.lock +14 -12
- data/README.md +1 -1
- data/Rakefile +9 -5
- data/data/dst.data +5 -0
- data/data/tz.data +5 -0
- data/lib/ziptz.rb +1 -1
- data/spec/spec_helper.rb +2 -1
- data/spec/ziptz_spec.rb +12 -12
- 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: 72973320e13a5a4c4356e14344e14e7837e906d5e2ec9d3bbbd9d16099572816
|
4
|
+
data.tar.gz: a3579132181b258bbb2739afae37d05dca964f5b6d10fb065a305e40c1781cb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40ebf00788b9436ea940e649cc6fd3a338ad8d3fdec170b1a4438522587b47aff0db7f1ff5e84a159958a8cb98326e21660a26d03e45ecc1ee7ebba209050dfc
|
7
|
+
data.tar.gz: 69262cd17c8b74c18e3f1748273427248759391cfa5d3a518c5964d5be36cd60334e248be62fff44ca22d6dcfd5ff954036491736dca6baeb9990d47840f1db3
|
data/Gemfile.lock
CHANGED
@@ -23,7 +23,7 @@ GEM
|
|
23
23
|
coderay (1.1.2)
|
24
24
|
concurrent-ruby (1.1.5)
|
25
25
|
diff-lcs (1.3)
|
26
|
-
ffi (1.
|
26
|
+
ffi (1.10.0)
|
27
27
|
formatador (0.2.5)
|
28
28
|
guard (2.15.0)
|
29
29
|
formatador (>= 0.2.4)
|
@@ -56,11 +56,12 @@ GEM
|
|
56
56
|
nenv (~> 0.1)
|
57
57
|
shellany (~> 0.0)
|
58
58
|
parallel (1.17.0)
|
59
|
-
parser (2.6.
|
59
|
+
parser (2.6.2.1)
|
60
60
|
ast (~> 2.4.0)
|
61
61
|
pry (0.12.2)
|
62
62
|
coderay (~> 1.1.0)
|
63
63
|
method_source (~> 0.9.0)
|
64
|
+
psych (3.1.0)
|
64
65
|
rainbow (3.0.0)
|
65
66
|
rake (12.3.2)
|
66
67
|
rb-fsevent (0.10.3)
|
@@ -72,25 +73,26 @@ GEM
|
|
72
73
|
rspec-mocks (~> 3.8.0)
|
73
74
|
rspec-core (3.8.0)
|
74
75
|
rspec-support (~> 3.8.0)
|
75
|
-
rspec-expectations (3.8.
|
76
|
+
rspec-expectations (3.8.2)
|
76
77
|
diff-lcs (>= 1.2.0, < 2.0)
|
77
78
|
rspec-support (~> 3.8.0)
|
78
79
|
rspec-mocks (3.8.0)
|
79
80
|
diff-lcs (>= 1.2.0, < 2.0)
|
80
81
|
rspec-support (~> 3.8.0)
|
81
82
|
rspec-support (3.8.0)
|
82
|
-
rubocop (0.
|
83
|
+
rubocop (0.67.2)
|
83
84
|
jaro_winkler (~> 1.5.1)
|
84
85
|
parallel (~> 1.10)
|
85
|
-
parser (>= 2.
|
86
|
+
parser (>= 2.5, != 2.5.1.1)
|
87
|
+
psych (>= 3.1.0)
|
86
88
|
rainbow (>= 2.2.2, < 4.0)
|
87
89
|
ruby-progressbar (~> 1.7)
|
88
|
-
unicode-display_width (>= 1.4.0, < 1.
|
89
|
-
rubocop-performance (1.
|
90
|
-
rubocop (>= 0.
|
91
|
-
rubocop-rspec (1.
|
90
|
+
unicode-display_width (>= 1.4.0, < 1.6)
|
91
|
+
rubocop-performance (1.1.0)
|
92
|
+
rubocop (>= 0.67.0)
|
93
|
+
rubocop-rspec (1.32.0)
|
92
94
|
rubocop (>= 0.60.0)
|
93
|
-
ruby-progressbar (1.10.
|
95
|
+
ruby-progressbar (1.10.0)
|
94
96
|
ruby_dep (1.5.0)
|
95
97
|
shellany (0.0.1)
|
96
98
|
thor (0.20.3)
|
@@ -100,7 +102,7 @@ GEM
|
|
100
102
|
tty-cursor (~> 0.7)
|
101
103
|
tzinfo (1.2.5)
|
102
104
|
thread_safe (~> 0.1)
|
103
|
-
unicode-display_width (1.
|
105
|
+
unicode-display_width (1.5.0)
|
104
106
|
|
105
107
|
PLATFORMS
|
106
108
|
ruby
|
@@ -122,4 +124,4 @@ DEPENDENCIES
|
|
122
124
|
ziptz!
|
123
125
|
|
124
126
|
BUNDLED WITH
|
125
|
-
1.17.
|
127
|
+
1.17.3
|
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -38,6 +38,8 @@ task :create_ziptz do
|
|
38
38
|
alias_attribute :day_light_saving, :DayLightSaving
|
39
39
|
end
|
40
40
|
|
41
|
+
spinner = TTY::Spinner.new('[:spinner] :message')
|
42
|
+
spinner.update message: 'Retrieving zip codes from database'
|
41
43
|
data = {}
|
42
44
|
ZipCode.find_each do |zip|
|
43
45
|
next if zip.time_zone.blank? || zip.day_light_saving.blank?
|
@@ -46,21 +48,23 @@ task :create_ziptz do
|
|
46
48
|
data[zip.zip_code][:tz] ||= zip.time_zone
|
47
49
|
data[zip.zip_code][:dst] ||= zip.day_light_saving
|
48
50
|
end
|
49
|
-
spinner
|
51
|
+
spinner.update message: "Retrieving zip codes from database (#{data.size} records)"
|
50
52
|
spinner.success
|
51
53
|
|
52
|
-
spinner = TTY::Spinner.new('[:spinner]
|
54
|
+
spinner = TTY::Spinner.new('[:spinner] :message')
|
55
|
+
spinner.update message: 'Writing tz.data'
|
53
56
|
spinner.auto_spin
|
54
57
|
lines = data.map { |k, v| "#{k}=#{v[:tz]}" }
|
55
58
|
lines.sort!
|
56
59
|
File.open('data/tz.data', 'w') do |f|
|
57
60
|
lines.each { |line| f.puts line }
|
58
61
|
end
|
59
|
-
spinner
|
62
|
+
spinner.update message: "Writing tz.data (#{File.size('data/tz.data')} bytes)"
|
60
63
|
spinner.success
|
61
64
|
# puts File.size('data/tz.data').to_s
|
62
65
|
|
63
|
-
spinner = TTY::Spinner.new('[:spinner]
|
66
|
+
spinner = TTY::Spinner.new('[:spinner] :message')
|
67
|
+
spinner.update message: 'Writing dst.data'
|
64
68
|
spinner.auto_spin
|
65
69
|
lines = data.map { |k, v| "#{k}=#{v[:dst] =~ /y/i ? 1 : 0}" }
|
66
70
|
lines.sort!
|
@@ -68,7 +72,7 @@ task :create_ziptz do
|
|
68
72
|
File.open('data/dst.data', 'w') do |f|
|
69
73
|
lines.each { |line| f.puts line }
|
70
74
|
end
|
71
|
-
spinner
|
75
|
+
spinner.update message: "Writing dst.data (#{File.size('data/dst.data')} bytes)"
|
72
76
|
spinner.success
|
73
77
|
rescue StandardError
|
74
78
|
spinner && spinner.error
|
data/data/dst.data
CHANGED
@@ -3262,6 +3262,7 @@
|
|
3262
3262
|
09265=1
|
3263
3263
|
09266=1
|
3264
3264
|
09276=1
|
3265
|
+
09277=1
|
3265
3266
|
09278=1
|
3266
3267
|
09289=1
|
3267
3268
|
09290=1
|
@@ -3309,6 +3310,7 @@
|
|
3309
3310
|
09421=1
|
3310
3311
|
09447=1
|
3311
3312
|
09454=1
|
3313
|
+
09456=1
|
3312
3314
|
09459=1
|
3313
3315
|
09461=1
|
3314
3316
|
09463=1
|
@@ -3412,12 +3414,14 @@
|
|
3412
3414
|
09634=1
|
3413
3415
|
09635=1
|
3414
3416
|
09636=1
|
3417
|
+
09641=1
|
3415
3418
|
09642=1
|
3416
3419
|
09643=1
|
3417
3420
|
09645=1
|
3418
3421
|
09647=1
|
3419
3422
|
09648=1
|
3420
3423
|
09649=1
|
3424
|
+
09665=1
|
3421
3425
|
09701=1
|
3422
3426
|
09702=1
|
3423
3427
|
09703=1
|
@@ -27420,6 +27424,7 @@
|
|
27420
27424
|
63178=1
|
27421
27425
|
63179=1
|
27422
27426
|
63180=1
|
27427
|
+
63182=1
|
27423
27428
|
63188=1
|
27424
27429
|
63195=1
|
27425
27430
|
63197=1
|
data/data/tz.data
CHANGED
@@ -3262,6 +3262,7 @@
|
|
3262
3262
|
09265=0
|
3263
3263
|
09266=0
|
3264
3264
|
09276=0
|
3265
|
+
09277=0
|
3265
3266
|
09278=0
|
3266
3267
|
09289=0
|
3267
3268
|
09290=0
|
@@ -3309,6 +3310,7 @@
|
|
3309
3310
|
09421=0
|
3310
3311
|
09447=0
|
3311
3312
|
09454=0
|
3313
|
+
09456=0
|
3312
3314
|
09459=0
|
3313
3315
|
09461=0
|
3314
3316
|
09463=0
|
@@ -3412,12 +3414,14 @@
|
|
3412
3414
|
09634=0
|
3413
3415
|
09635=0
|
3414
3416
|
09636=0
|
3417
|
+
09641=0
|
3415
3418
|
09642=0
|
3416
3419
|
09643=0
|
3417
3420
|
09645=0
|
3418
3421
|
09647=0
|
3419
3422
|
09648=0
|
3420
3423
|
09649=0
|
3424
|
+
09665=0
|
3421
3425
|
09701=0
|
3422
3426
|
09702=0
|
3423
3427
|
09703=0
|
@@ -27420,6 +27424,7 @@
|
|
27420
27424
|
63178=6
|
27421
27425
|
63179=6
|
27422
27426
|
63180=6
|
27427
|
+
63182=6
|
27423
27428
|
63188=6
|
27424
27429
|
63195=6
|
27425
27430
|
63197=6
|
data/lib/ziptz.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
data/spec/ziptz_spec.rb
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Ziptz do
|
4
|
-
|
3
|
+
RSpec.describe Ziptz do
|
4
|
+
let(:ziptz) { Ziptz.new }
|
5
5
|
|
6
6
|
describe 'when inspected' do
|
7
7
|
it 'does not show internal instance variables' do
|
8
|
-
expect(
|
8
|
+
expect(ziptz.inspect).to match(/#<Ziptz:\d+>/)
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
12
|
describe '#time_zone_name' do
|
13
13
|
context 'when given a 5-digit zipcode' do
|
14
14
|
it 'returns the time zone number' do
|
15
|
-
expect(
|
15
|
+
expect(ziptz.time_zone_name('97034')).to eq 'America/Los_Angeles'
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
context 'when there is no matching zipcode' do
|
20
20
|
it 'returns nil' do
|
21
|
-
expect(
|
21
|
+
expect(ziptz.time_zone_name('xyz')).to be_nil
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -26,7 +26,7 @@ describe Ziptz do
|
|
26
26
|
describe '#time_zone_uses_dst?' do
|
27
27
|
context 'when given a 5-digit zipcode' do
|
28
28
|
it 'returns the time zone number' do
|
29
|
-
expect(
|
29
|
+
expect(ziptz.time_zone_name('97034')).to eq 'America/Los_Angeles'
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -34,14 +34,14 @@ describe Ziptz do
|
|
34
34
|
describe '#time_zone_offset' do
|
35
35
|
context 'when given a 5-digit zipcode' do
|
36
36
|
it 'returns a boolean' do
|
37
|
-
expect(
|
38
|
-
expect(
|
37
|
+
expect(ziptz.time_zone_uses_dst?('97034')).to eq true
|
38
|
+
expect(ziptz.time_zone_uses_dst?('85004')).to eq false
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
42
|
context 'when there is no matching zipcode' do
|
43
43
|
it 'returns nil' do
|
44
|
-
expect(
|
44
|
+
expect(ziptz.time_zone_offset('xyz')).to be_nil
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
@@ -49,15 +49,15 @@ describe Ziptz do
|
|
49
49
|
describe '#zips' do
|
50
50
|
context 'when given a time zone' do
|
51
51
|
it 'returns an array of zip codes' do
|
52
|
-
expect(
|
52
|
+
expect(ziptz.zips('Pacific/Pago_Pago')).to eq %w[96799]
|
53
53
|
end
|
54
54
|
|
55
55
|
it 'is case-insensitive' do
|
56
|
-
expect(
|
56
|
+
expect(ziptz.zips('pacific/pago_pago')).to eq %w[96799]
|
57
57
|
end
|
58
58
|
|
59
59
|
it 'returns nil for unknown time zones' do
|
60
|
-
expect(
|
60
|
+
expect(ziptz.zips('Glark')).to be_nil
|
61
61
|
end
|
62
62
|
end
|
63
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.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keith Morrison
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-07-01 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
|
@@ -51,7 +51,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: '0'
|
53
53
|
requirements: []
|
54
|
-
rubygems_version: 3.0.
|
54
|
+
rubygems_version: 3.0.4
|
55
55
|
signing_key:
|
56
56
|
specification_version: 4
|
57
57
|
summary: TimeZone info for any 5-digit US zip code
|