ziptz 1.0.5 → 1.0.6
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 +1 -1
- data/Rakefile +9 -10
- data/data/ziptz.data +43 -45
- data/lib/ziptz/version.rb +1 -1
- data/lib/ziptz.rb +7 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2e72adb89e8328659ec1624fc8b4560cce88a55
|
4
|
+
data.tar.gz: 28800ee56513ff4d9a9204a7d3317a950c3910e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8655d7e49e189f923be11470e34e4c1b4f3563f799bdae43f3a3c3b18d4582f458d7ed2e1e6ddc88b224ba681f68ccdf2a292f049fb28d9bdf8805a64ff8f84e
|
7
|
+
data.tar.gz: 2fa0e5bad359d9d5caa6273009185ed76e269f546d76f0387ca1b89cbdb20b3991c8830e211699ade6e2067833cfe523baa6ad06a873b9a948f681f8f233e62c
|
data/Gemfile.lock
CHANGED
data/Rakefile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'bundler/setup'
|
1
|
+
require 'bundler/setup'
|
2
2
|
Bundler.setup(:default, :development)
|
3
3
|
|
4
4
|
require 'rspec/core/rake_task'
|
@@ -10,11 +10,11 @@ RSpec::Core::RakeTask.new :specdoc do |t|
|
|
10
10
|
t.rspec_opts = %w(-fl)
|
11
11
|
end
|
12
12
|
|
13
|
-
task :
|
13
|
+
task default: :spec
|
14
14
|
|
15
|
-
desc
|
15
|
+
desc 'Open an irb session preloaded with this library'
|
16
16
|
task :console do
|
17
|
-
sh
|
17
|
+
sh 'irb -rubygems -I lib -r ziptz.rb'
|
18
18
|
end
|
19
19
|
|
20
20
|
desc 'Create ziptz.yml from zipcodes database'
|
@@ -22,7 +22,7 @@ task :create_ziptz do
|
|
22
22
|
require 'yaml'
|
23
23
|
require 'active_record'
|
24
24
|
|
25
|
-
db_config = YAML
|
25
|
+
db_config = YAML.load(File.open 'database.yml')
|
26
26
|
ActiveRecord::Base.establish_connection(db_config)
|
27
27
|
|
28
28
|
class ZipCode < ActiveRecord::Base
|
@@ -33,20 +33,19 @@ task :create_ziptz do
|
|
33
33
|
alias_attribute :time_zone, :TimeZone
|
34
34
|
end
|
35
35
|
|
36
|
-
puts
|
36
|
+
puts 'Retrieving zip codes from database'
|
37
37
|
|
38
38
|
data = {}
|
39
39
|
ZipCode.find_each do |zip|
|
40
40
|
data[zip.zip_code] ||= zip.time_zone
|
41
41
|
end
|
42
42
|
|
43
|
-
puts
|
43
|
+
puts 'Writing ziptz.data'
|
44
44
|
|
45
|
-
lines = data.map {|k, v| "#{k}=#{v}"}
|
45
|
+
lines = data.map { |k, v| "#{k}=#{v}" }
|
46
46
|
lines.sort!
|
47
47
|
|
48
48
|
File.open('data/ziptz.data', 'w') do |f|
|
49
|
-
lines.each {|line| f.puts line}
|
49
|
+
lines.each { |line| f.puts line }
|
50
50
|
end
|
51
|
-
|
52
51
|
end
|
data/data/ziptz.data
CHANGED
@@ -13685,8 +13685,8 @@
|
|
13685
13685
|
32449=6
|
13686
13686
|
32452=6
|
13687
13687
|
32455=6
|
13688
|
-
32456=
|
13689
|
-
32457=
|
13688
|
+
32456=5
|
13689
|
+
32457=5
|
13690
13690
|
32459=6
|
13691
13691
|
32460=6
|
13692
13692
|
32461=6
|
@@ -17785,7 +17785,7 @@
|
|
17785
17785
|
42035=6
|
17786
17786
|
42036=6
|
17787
17787
|
42037=6
|
17788
|
-
42038=
|
17788
|
+
42038=6
|
17789
17789
|
42039=6
|
17790
17790
|
42040=6
|
17791
17791
|
42041=6
|
@@ -17798,7 +17798,7 @@
|
|
17798
17798
|
42051=6
|
17799
17799
|
42053=6
|
17800
17800
|
42054=6
|
17801
|
-
42055=
|
17801
|
+
42055=6
|
17802
17802
|
42056=6
|
17803
17803
|
42058=6
|
17804
17804
|
42060=6
|
@@ -24562,8 +24562,8 @@
|
|
24562
24562
|
56965=5
|
24563
24563
|
56967=5
|
24564
24564
|
56972=5
|
24565
|
-
56998=
|
24566
|
-
56999=
|
24565
|
+
56998=5
|
24566
|
+
56999=5
|
24567
24567
|
57001=6
|
24568
24568
|
57002=6
|
24569
24569
|
57003=6
|
@@ -24828,7 +24828,7 @@
|
|
24828
24828
|
57533=6
|
24829
24829
|
57534=6
|
24830
24830
|
57536=6
|
24831
|
-
57537=
|
24831
|
+
57537=7
|
24832
24832
|
57538=6
|
24833
24833
|
57540=6
|
24834
24834
|
57541=6
|
@@ -25202,23 +25202,23 @@
|
|
25202
25202
|
58505=6
|
25203
25203
|
58506=6
|
25204
25204
|
58507=6
|
25205
|
-
58520=
|
25205
|
+
58520=6
|
25206
25206
|
58521=6
|
25207
|
-
58523=
|
25207
|
+
58523=6
|
25208
25208
|
58524=6
|
25209
|
-
58528=
|
25209
|
+
58528=6
|
25210
25210
|
58529=7
|
25211
|
-
58530=
|
25211
|
+
58530=6
|
25212
25212
|
58531=6
|
25213
25213
|
58532=6
|
25214
25214
|
58533=7
|
25215
25215
|
58535=6
|
25216
25216
|
58538=6
|
25217
25217
|
58540=6
|
25218
|
-
58541=
|
25218
|
+
58541=6
|
25219
25219
|
58542=6
|
25220
25220
|
58544=6
|
25221
|
-
58545=
|
25221
|
+
58545=6
|
25222
25222
|
58549=6
|
25223
25223
|
58552=6
|
25224
25224
|
58554=6
|
@@ -25230,18 +25230,18 @@
|
|
25230
25230
|
58563=6
|
25231
25231
|
58564=7
|
25232
25232
|
58565=6
|
25233
|
-
58566=
|
25234
|
-
58568=
|
25233
|
+
58566=6
|
25234
|
+
58568=6
|
25235
25235
|
58569=7
|
25236
|
-
58570=
|
25237
|
-
58571=
|
25236
|
+
58570=6
|
25237
|
+
58571=6
|
25238
25238
|
58572=6
|
25239
25239
|
58573=6
|
25240
25240
|
58575=6
|
25241
25241
|
58576=6
|
25242
25242
|
58577=6
|
25243
25243
|
58579=6
|
25244
|
-
58580=
|
25244
|
+
58580=6
|
25245
25245
|
58581=6
|
25246
25246
|
58601=7
|
25247
25247
|
58602=7
|
@@ -25253,7 +25253,7 @@
|
|
25253
25253
|
58626=7
|
25254
25254
|
58627=7
|
25255
25255
|
58630=7
|
25256
|
-
58631=
|
25256
|
+
58631=6
|
25257
25257
|
58632=7
|
25258
25258
|
58634=7
|
25259
25259
|
58636=7
|
@@ -25343,14 +25343,14 @@
|
|
25343
25343
|
58802=6
|
25344
25344
|
58803=6
|
25345
25345
|
58830=6
|
25346
|
-
58831=
|
25346
|
+
58831=6
|
25347
25347
|
58833=6
|
25348
|
-
58835=
|
25349
|
-
58838=
|
25348
|
+
58835=6
|
25349
|
+
58838=6
|
25350
25350
|
58843=6
|
25351
25351
|
58844=6
|
25352
25352
|
58845=6
|
25353
|
-
58847=
|
25353
|
+
58847=6
|
25354
25354
|
58849=6
|
25355
25355
|
58852=6
|
25356
25356
|
58853=6
|
@@ -25937,7 +25937,6 @@
|
|
25937
25937
|
60204=6
|
25938
25938
|
60208=6
|
25939
25939
|
60209=6
|
25940
|
-
60290=6
|
25941
25940
|
60301=6
|
25942
25941
|
60302=6
|
25943
25942
|
60303=6
|
@@ -27140,7 +27139,6 @@
|
|
27140
27139
|
62715=6
|
27141
27140
|
62716=6
|
27142
27141
|
62719=6
|
27143
|
-
62721=6
|
27144
27142
|
62722=6
|
27145
27143
|
62723=6
|
27146
27144
|
62726=6
|
@@ -29199,7 +29197,7 @@
|
|
29199
29197
|
67835=6
|
29200
29198
|
67836=7
|
29201
29199
|
67837=6
|
29202
|
-
67838=
|
29200
|
+
67838=6
|
29203
29201
|
67839=6
|
29204
29202
|
67840=6
|
29205
29203
|
67841=6
|
@@ -29215,7 +29213,7 @@
|
|
29215
29213
|
67855=6
|
29216
29214
|
67857=7
|
29217
29215
|
67859=6
|
29218
|
-
67860=
|
29216
|
+
67860=6
|
29219
29217
|
67861=6
|
29220
29218
|
67862=6
|
29221
29219
|
67863=6
|
@@ -29786,7 +29784,7 @@
|
|
29786
29784
|
69132=6
|
29787
29785
|
69133=7
|
29788
29786
|
69134=7
|
29789
|
-
69135=
|
29787
|
+
69135=6
|
29790
29788
|
69138=6
|
29791
29789
|
69140=7
|
29792
29790
|
69141=7
|
@@ -29818,17 +29816,17 @@
|
|
29818
29816
|
69170=6
|
29819
29817
|
69171=6
|
29820
29818
|
69190=7
|
29821
|
-
69201=
|
29819
|
+
69201=6
|
29822
29820
|
69210=6
|
29823
29821
|
69211=7
|
29824
|
-
69212=
|
29822
|
+
69212=6
|
29825
29823
|
69214=6
|
29826
29824
|
69216=7
|
29827
29825
|
69217=6
|
29828
29826
|
69218=7
|
29829
29827
|
69219=7
|
29830
|
-
69220=
|
29831
|
-
69221=
|
29828
|
+
69220=6
|
29829
|
+
69221=6
|
29832
29830
|
69301=7
|
29833
29831
|
69331=7
|
29834
29832
|
69333=7
|
@@ -35570,7 +35568,7 @@
|
|
35570
35568
|
83544=8
|
35571
35569
|
83545=8
|
35572
35570
|
83546=8
|
35573
|
-
83547=
|
35571
|
+
83547=7
|
35574
35572
|
83548=8
|
35575
35573
|
83549=8
|
35576
35574
|
83552=8
|
@@ -35628,7 +35626,7 @@
|
|
35628
35626
|
83666=7
|
35629
35627
|
83669=7
|
35630
35628
|
83670=7
|
35631
|
-
83671=
|
35629
|
+
83671=7
|
35632
35630
|
83672=7
|
35633
35631
|
83676=7
|
35634
35632
|
83677=7
|
@@ -37356,7 +37354,7 @@
|
|
37356
37354
|
89833=8
|
37357
37355
|
89834=8
|
37358
37356
|
89835=8
|
37359
|
-
89883=
|
37357
|
+
89883=7
|
37360
37358
|
90001=8
|
37361
37359
|
90002=8
|
37362
37360
|
90003=8
|
@@ -40251,7 +40249,7 @@
|
|
40251
40249
|
96860=10
|
40252
40250
|
96861=10
|
40253
40251
|
96863=10
|
40254
|
-
96898=
|
40252
|
+
96898=13
|
40255
40253
|
96910=14
|
40256
40254
|
96912=14
|
40257
40255
|
96913=14
|
@@ -40267,10 +40265,10 @@
|
|
40267
40265
|
96932=14
|
40268
40266
|
96939=15
|
40269
40267
|
96940=15
|
40270
|
-
96941=
|
40271
|
-
96942=
|
40272
|
-
96943=
|
40273
|
-
96944=
|
40268
|
+
96941=16
|
40269
|
+
96942=14
|
40270
|
+
96943=14
|
40271
|
+
96944=16
|
40274
40272
|
96950=14
|
40275
40273
|
96951=14
|
40276
40274
|
96952=14
|
@@ -41493,8 +41491,8 @@
|
|
41493
41491
|
99530=9
|
41494
41492
|
99540=9
|
41495
41493
|
99545=9
|
41496
|
-
99546=
|
41497
|
-
99547=
|
41494
|
+
99546=9
|
41495
|
+
99547=9
|
41498
41496
|
99548=9
|
41499
41497
|
99549=9
|
41500
41498
|
99550=9
|
@@ -41533,7 +41531,7 @@
|
|
41533
41531
|
99588=9
|
41534
41532
|
99589=9
|
41535
41533
|
99590=9
|
41536
|
-
99591=
|
41534
|
+
99591=9
|
41537
41535
|
99599=9
|
41538
41536
|
99602=9
|
41539
41537
|
99603=9
|
@@ -41568,7 +41566,7 @@
|
|
41568
41566
|
99635=9
|
41569
41567
|
99636=9
|
41570
41568
|
99637=9
|
41571
|
-
99638=
|
41569
|
+
99638=9
|
41572
41570
|
99639=9
|
41573
41571
|
99640=9
|
41574
41572
|
99641=9
|
@@ -41588,7 +41586,7 @@
|
|
41588
41586
|
99657=9
|
41589
41587
|
99658=9
|
41590
41588
|
99659=9
|
41591
|
-
99660=
|
41589
|
+
99660=9
|
41592
41590
|
99661=9
|
41593
41591
|
99662=9
|
41594
41592
|
99663=9
|
data/lib/ziptz/version.rb
CHANGED
data/lib/ziptz.rb
CHANGED
@@ -37,18 +37,18 @@ class Ziptz
|
|
37
37
|
protected
|
38
38
|
|
39
39
|
def zips_by_code(tz_code)
|
40
|
-
|
41
|
-
selected.keys.sort
|
40
|
+
@zips.select { |_, v| v == tz_code.to_s }.keys.sort
|
42
41
|
end
|
43
42
|
|
44
43
|
def time_zone_hash(zip)
|
45
|
-
|
44
|
+
key = @zips[zip.to_s]
|
45
|
+
TZ_INFO[key]
|
46
46
|
end
|
47
47
|
|
48
48
|
def tz_name_to_code
|
49
|
-
@tz_name_to_code ||= TZ_INFO.
|
50
|
-
|
51
|
-
data
|
49
|
+
@tz_name_to_code ||= TZ_INFO.each_with_object({}) do |(code, tz), data|
|
50
|
+
key = tz[:name].downcase
|
51
|
+
data[key] = code
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
@@ -58,7 +58,7 @@ class Ziptz
|
|
58
58
|
|
59
59
|
def load_data
|
60
60
|
File.foreach(data_path).with_object({}) do |line, data|
|
61
|
-
zip, tz = line.split('=')
|
61
|
+
zip, tz = line.strip.split('=')
|
62
62
|
data[zip] = tz
|
63
63
|
end
|
64
64
|
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: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keith Morrison
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-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
|