ziptz 3.0.1 → 3.0.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +4 -4
- data/data/tz.data +0 -0
- data/data/tzm.data +0 -0
- data/lib/ziptz.rb +22 -4
- data/spec/ziptz_spec.rb +14 -0
- data/ziptz.gemspec +2 -2
- metadata +6 -12
- data/Gemfile +0 -18
- data/Gemfile.lock +0 -134
- data/Gemfile.travis +0 -7
- data/Guardfile +0 -8
- data/Rakefile +0 -18
- data/database.yml +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8584f30a48d305cf57165059fdf89bc90ff1169b540b07e4810dd08facf3bb76
|
4
|
+
data.tar.gz: 974d31d4c7ab3f17e7e5bf86d875eca5b29f9d44087a09ae9b83c4694fd68945
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e12dbe849abc336a65894be858be518433b97b9b9ac2622581534b7da9078de2f10fe21270dfed58cee58bb7a0f2003f40f86d9d3e1dcf662cad952dd2e41e20
|
7
|
+
data.tar.gz: dd9b487f4a8a868e07c39837732433662879696f12378666d700a69ed561743e47dd5a0bd607b87e381b7abe63ffe6d36ebfba61a7efc848e95fedfd7cf4f0f8
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
# Ziptz
|
2
2
|
[![Version](http://img.shields.io/gem/v/ziptz.svg?style=flat)](https://rubygems.org/gems/ziptz)
|
3
|
-
[![Build Status](
|
3
|
+
[![Build Status](https://github.com/infused/ziptz/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/infused/ziptz/actions/workflows/build.yml)
|
4
4
|
[![Total Downloads](https://img.shields.io/gem/dt/ziptz.svg)](https://rubygems.org/gems/ziptz/)
|
5
5
|
[![License](https://img.shields.io/github/license/infused/ziptz.svg)](https://github.com/infused/ziptz)
|
6
6
|
|
7
7
|
Get time zone, daylight saving time, and base offset 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>July 2023</b>.</i>
|
10
10
|
|
11
11
|
## Compatibility
|
12
12
|
|
13
13
|
Ziptz is tested to work with the following versions of Ruby:
|
14
14
|
|
15
|
-
* Ruby 2.3.x, 2.4.x, 2.5.x, 2.6.x, 2.7.x, 3.
|
15
|
+
* Ruby 2.3.x, 2.4.x, 2.5.x, 2.6.x, 2.7.x, 3.x
|
16
16
|
|
17
17
|
## Installation
|
18
18
|
|
@@ -160,7 +160,7 @@ Time zone names now reflect standard tz-database names.
|
|
160
160
|
|
161
161
|
## License
|
162
162
|
|
163
|
-
Copyright (c) 2015-
|
163
|
+
Copyright (c) 2015-2023 Keith Morrison <<keithm@infused.org>>
|
164
164
|
|
165
165
|
Permission is hereby granted, free of charge, to any person
|
166
166
|
obtaining a copy of this software and associated documentation
|
data/data/tz.data
CHANGED
Binary file
|
data/data/tzm.data
CHANGED
Binary file
|
data/lib/ziptz.rb
CHANGED
@@ -2,7 +2,11 @@ require 'yaml'
|
|
2
2
|
require 'zlib'
|
3
3
|
|
4
4
|
class Ziptz
|
5
|
-
VERSION = '3.0.
|
5
|
+
VERSION = '3.0.18'.freeze
|
6
|
+
|
7
|
+
def self.instance
|
8
|
+
@instance ||= new
|
9
|
+
end
|
6
10
|
|
7
11
|
def time_zone_name(zip)
|
8
12
|
tz_info = time_zone_info(zip)
|
@@ -40,12 +44,19 @@ class Ziptz
|
|
40
44
|
@tzm ||= load_tzm_data
|
41
45
|
end
|
42
46
|
|
47
|
+
def lazy_tz
|
48
|
+
@lazy_tz ||= lazy_load_tz_data
|
49
|
+
end
|
50
|
+
|
43
51
|
def tz
|
44
52
|
@tz ||= load_tz_data
|
45
53
|
end
|
46
54
|
|
47
55
|
def time_zone_info(zip)
|
48
|
-
|
56
|
+
if (data = lazy_tz[zip.to_s.slice(0, 5)])
|
57
|
+
_, tz, dst = data.strip.split('|')
|
58
|
+
{tz: tz, dst: dst == '1'}
|
59
|
+
end
|
49
60
|
end
|
50
61
|
|
51
62
|
def tzm_data_path
|
@@ -56,10 +67,17 @@ class Ziptz
|
|
56
67
|
File.join(File.dirname(__FILE__), '..', 'data', 'tz.data')
|
57
68
|
end
|
58
69
|
|
70
|
+
def lazy_load_tz_data
|
71
|
+
uncompressed = Zlib::Inflate.inflate(File.read(tz_data_path, encoding: 'ASCII-8BIT'))
|
72
|
+
uncompressed.each_line.with_object({}) do |line, data|
|
73
|
+
data[line.slice(0, 5)] = line
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
59
77
|
def load_tz_data
|
60
78
|
uncompressed = Zlib::Inflate.inflate(File.read(tz_data_path, encoding: 'ASCII-8BIT'))
|
61
79
|
uncompressed.each_line.with_object({}) do |line, data|
|
62
|
-
zip, tz, dst = line.strip.split('
|
80
|
+
zip, tz, dst = line.strip.split('|')
|
63
81
|
data[zip] = {tz: tz, dst: dst == '1'}
|
64
82
|
end
|
65
83
|
end
|
@@ -67,7 +85,7 @@ class Ziptz
|
|
67
85
|
def load_tzm_data
|
68
86
|
uncompressed = Zlib::Inflate.inflate(File.read(tzm_data_path, encoding: 'ASCII-8BIT'))
|
69
87
|
uncompressed.each_line.with_object({}) do |line, data|
|
70
|
-
tz, offset = line.strip.split('
|
88
|
+
tz, offset = line.strip.split('|')
|
71
89
|
data[tz] = {offset: offset}
|
72
90
|
end
|
73
91
|
end
|
data/spec/ziptz_spec.rb
CHANGED
@@ -106,4 +106,18 @@ RSpec.describe Ziptz do
|
|
106
106
|
end
|
107
107
|
end
|
108
108
|
end
|
109
|
+
|
110
|
+
describe '#instance' do
|
111
|
+
context 'when given a 5 digit zip code' do
|
112
|
+
it 'matches the behavior of Ziptz.new' do
|
113
|
+
expect(Ziptz.instance.time_zone_name('97034')).to eq ziptz.time_zone_name('97034')
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
context 'when called twice' do
|
118
|
+
it 'returns identical instances' do
|
119
|
+
expect(Ziptz.instance.object_id).to eq Ziptz.instance.object_id
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
109
123
|
end
|
data/ziptz.gemspec
CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
|
|
13
13
|
|
14
14
|
s.rdoc_options = ['--charset=UTF-8']
|
15
15
|
s.extra_rdoc_files = ['README.md', 'LICENSE']
|
16
|
-
s.files = Dir['
|
17
|
-
s.test_files = Dir.glob('spec/**/*_spec.rb')
|
16
|
+
s.files = Dir['README.md', 'LICENSE', '{data,lib,spec}/**/*', 'ziptz.gemspec']
|
18
17
|
s.require_paths = ['lib']
|
19
18
|
s.required_ruby_version = '>= 2.0.0'
|
19
|
+
s.metadata['rubygems_mfa_required'] = 'true'
|
20
20
|
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: 3.0.
|
4
|
+
version: 3.0.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keith Morrison
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-10-02 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
|
@@ -18,16 +18,10 @@ extra_rdoc_files:
|
|
18
18
|
- README.md
|
19
19
|
- LICENSE
|
20
20
|
files:
|
21
|
-
- Gemfile
|
22
|
-
- Gemfile.lock
|
23
|
-
- Gemfile.travis
|
24
|
-
- Guardfile
|
25
21
|
- LICENSE
|
26
22
|
- README.md
|
27
|
-
- Rakefile
|
28
23
|
- data/tz.data
|
29
24
|
- data/tzm.data
|
30
|
-
- database.yml
|
31
25
|
- lib/ziptz.rb
|
32
26
|
- spec/spec_helper.rb
|
33
27
|
- spec/ziptz_spec.rb
|
@@ -35,7 +29,8 @@ files:
|
|
35
29
|
homepage: http://github.com/infused/ziptz
|
36
30
|
licenses:
|
37
31
|
- MIT
|
38
|
-
metadata:
|
32
|
+
metadata:
|
33
|
+
rubygems_mfa_required: 'true'
|
39
34
|
post_install_message:
|
40
35
|
rdoc_options:
|
41
36
|
- "--charset=UTF-8"
|
@@ -52,9 +47,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
52
47
|
- !ruby/object:Gem::Version
|
53
48
|
version: '0'
|
54
49
|
requirements: []
|
55
|
-
rubygems_version: 3.
|
50
|
+
rubygems_version: 3.4.10
|
56
51
|
signing_key:
|
57
52
|
specification_version: 4
|
58
53
|
summary: TimeZone info for any 5-digit US zip code
|
59
|
-
test_files:
|
60
|
-
- spec/ziptz_spec.rb
|
54
|
+
test_files: []
|
data/Gemfile
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
gemspec
|
2
|
-
source 'https://rubygems.org'
|
3
|
-
|
4
|
-
group :development, :test do
|
5
|
-
gem 'activerecord'
|
6
|
-
gem 'bundler'
|
7
|
-
gem 'byebug'
|
8
|
-
gem 'guard'
|
9
|
-
gem 'guard-rspec'
|
10
|
-
gem 'irb'
|
11
|
-
gem 'mysql2'
|
12
|
-
gem 'rake'
|
13
|
-
gem 'rspec'
|
14
|
-
gem 'rubocop'
|
15
|
-
gem 'rubocop-performance'
|
16
|
-
gem 'rubocop-rspec'
|
17
|
-
gem 'tty-spinner'
|
18
|
-
end
|
data/Gemfile.lock
DELETED
@@ -1,134 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
ziptz (3.0.0)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
activemodel (6.0.3.4)
|
10
|
-
activesupport (= 6.0.3.4)
|
11
|
-
activerecord (6.0.3.4)
|
12
|
-
activemodel (= 6.0.3.4)
|
13
|
-
activesupport (= 6.0.3.4)
|
14
|
-
activesupport (6.0.3.4)
|
15
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
16
|
-
i18n (>= 0.7, < 2)
|
17
|
-
minitest (~> 5.1)
|
18
|
-
tzinfo (~> 1.1)
|
19
|
-
zeitwerk (~> 2.2, >= 2.2.2)
|
20
|
-
ast (2.4.1)
|
21
|
-
byebug (11.1.3)
|
22
|
-
coderay (1.1.3)
|
23
|
-
concurrent-ruby (1.1.7)
|
24
|
-
diff-lcs (1.4.4)
|
25
|
-
ffi (1.13.1)
|
26
|
-
formatador (0.2.5)
|
27
|
-
guard (2.16.2)
|
28
|
-
formatador (>= 0.2.4)
|
29
|
-
listen (>= 2.7, < 4.0)
|
30
|
-
lumberjack (>= 1.0.12, < 2.0)
|
31
|
-
nenv (~> 0.1)
|
32
|
-
notiffany (~> 0.0)
|
33
|
-
pry (>= 0.9.12)
|
34
|
-
shellany (~> 0.0)
|
35
|
-
thor (>= 0.18.1)
|
36
|
-
guard-compat (1.2.1)
|
37
|
-
guard-rspec (4.7.3)
|
38
|
-
guard (~> 2.1)
|
39
|
-
guard-compat (~> 1.1)
|
40
|
-
rspec (>= 2.99.0, < 4.0)
|
41
|
-
i18n (1.8.5)
|
42
|
-
concurrent-ruby (~> 1.0)
|
43
|
-
io-console (0.5.6)
|
44
|
-
irb (1.2.7)
|
45
|
-
reline (>= 0.1.5)
|
46
|
-
listen (3.2.1)
|
47
|
-
rb-fsevent (~> 0.10, >= 0.10.3)
|
48
|
-
rb-inotify (~> 0.9, >= 0.9.10)
|
49
|
-
lumberjack (1.2.8)
|
50
|
-
method_source (1.0.0)
|
51
|
-
minitest (5.14.2)
|
52
|
-
mysql2 (0.5.3)
|
53
|
-
nenv (0.3.0)
|
54
|
-
notiffany (0.1.3)
|
55
|
-
nenv (~> 0.1)
|
56
|
-
shellany (~> 0.0)
|
57
|
-
parallel (1.19.2)
|
58
|
-
parser (2.7.2.0)
|
59
|
-
ast (~> 2.4.1)
|
60
|
-
pry (0.13.1)
|
61
|
-
coderay (~> 1.1)
|
62
|
-
method_source (~> 1.0)
|
63
|
-
rainbow (3.0.0)
|
64
|
-
rake (13.0.1)
|
65
|
-
rb-fsevent (0.10.4)
|
66
|
-
rb-inotify (0.10.1)
|
67
|
-
ffi (~> 1.0)
|
68
|
-
regexp_parser (1.8.2)
|
69
|
-
reline (0.1.7)
|
70
|
-
io-console (~> 0.5)
|
71
|
-
rexml (3.2.4)
|
72
|
-
rspec (3.10.0)
|
73
|
-
rspec-core (~> 3.10.0)
|
74
|
-
rspec-expectations (~> 3.10.0)
|
75
|
-
rspec-mocks (~> 3.10.0)
|
76
|
-
rspec-core (3.10.0)
|
77
|
-
rspec-support (~> 3.10.0)
|
78
|
-
rspec-expectations (3.10.0)
|
79
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
80
|
-
rspec-support (~> 3.10.0)
|
81
|
-
rspec-mocks (3.10.0)
|
82
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
83
|
-
rspec-support (~> 3.10.0)
|
84
|
-
rspec-support (3.10.0)
|
85
|
-
rubocop (0.93.1)
|
86
|
-
parallel (~> 1.10)
|
87
|
-
parser (>= 2.7.1.5)
|
88
|
-
rainbow (>= 2.2.2, < 4.0)
|
89
|
-
regexp_parser (>= 1.8)
|
90
|
-
rexml
|
91
|
-
rubocop-ast (>= 0.6.0)
|
92
|
-
ruby-progressbar (~> 1.7)
|
93
|
-
unicode-display_width (>= 1.4.0, < 2.0)
|
94
|
-
rubocop-ast (1.1.0)
|
95
|
-
parser (>= 2.7.1.5)
|
96
|
-
rubocop-performance (1.8.1)
|
97
|
-
rubocop (>= 0.87.0)
|
98
|
-
rubocop-ast (>= 0.4.0)
|
99
|
-
rubocop-rspec (1.44.1)
|
100
|
-
rubocop (~> 0.87)
|
101
|
-
rubocop-ast (>= 0.7.1)
|
102
|
-
ruby-progressbar (1.10.1)
|
103
|
-
shellany (0.0.1)
|
104
|
-
thor (1.0.1)
|
105
|
-
thread_safe (0.3.6)
|
106
|
-
tty-cursor (0.7.1)
|
107
|
-
tty-spinner (0.9.3)
|
108
|
-
tty-cursor (~> 0.7)
|
109
|
-
tzinfo (1.2.7)
|
110
|
-
thread_safe (~> 0.1)
|
111
|
-
unicode-display_width (1.7.0)
|
112
|
-
zeitwerk (2.4.1)
|
113
|
-
|
114
|
-
PLATFORMS
|
115
|
-
ruby
|
116
|
-
|
117
|
-
DEPENDENCIES
|
118
|
-
activerecord
|
119
|
-
bundler
|
120
|
-
byebug
|
121
|
-
guard
|
122
|
-
guard-rspec
|
123
|
-
irb
|
124
|
-
mysql2
|
125
|
-
rake
|
126
|
-
rspec
|
127
|
-
rubocop
|
128
|
-
rubocop-performance
|
129
|
-
rubocop-rspec
|
130
|
-
tty-spinner
|
131
|
-
ziptz!
|
132
|
-
|
133
|
-
BUNDLED WITH
|
134
|
-
2.1.4
|
data/Gemfile.travis
DELETED
data/Guardfile
DELETED
data/Rakefile
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'bundler/setup'
|
2
|
-
Bundler.setup(:default, :development)
|
3
|
-
|
4
|
-
require 'rspec/core/rake_task'
|
5
|
-
RSpec::Core::RakeTask.new :spec do |t|
|
6
|
-
t.rspec_opts = %w[--color]
|
7
|
-
end
|
8
|
-
|
9
|
-
RSpec::Core::RakeTask.new :specdoc do |t|
|
10
|
-
t.rspec_opts = %w[-fl]
|
11
|
-
end
|
12
|
-
|
13
|
-
task default: :spec
|
14
|
-
|
15
|
-
desc 'Open an irb session preloaded with this library'
|
16
|
-
task :console do
|
17
|
-
sh 'irb -r rubygems -I lib -r ziptz.rb'
|
18
|
-
end
|
data/database.yml
DELETED