simple_zip_code 0.3.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7f1bd265288ec068978299a10be0e7082de4fd94
4
+ data.tar.gz: f4e55c3014feed4cd9d8b9eabcf1e160cef617e3
5
+ SHA512:
6
+ metadata.gz: 52fd10572b8ce50306a1b197b997d6511d979d82360174017477b908e627f2391dfa867b2befe4d1032a3344b92a7e6ac6c82099b9db08b83863b6d46a324922
7
+ data.tar.gz: e0be59c09b7e55b64410bc76bd49f7cb703d16421b7c68281ffbd97c0e182cdf1f4c31a5c8229a23ef3cd75e69f3f67e286e2de4c77417cbea6e3384eda46640
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in simple_zip_code.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016 Madeline Carson
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # SimpleZipCode
2
+
3
+ Super lightweight solution to get a US state abbreviation from a valid zip code!
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'simple_zip_code'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install simple_zip_code
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+
25
+ us_state = SimpleZipCode::DeduceState.get_state_from_zip(98230) # valid zip integer
26
+ p us_state
27
+ > "WA"
28
+
29
+ # ...that's all there is
30
+ ```
31
+
32
+ ## Contributing
33
+
34
+ 1. Fork it ( https://github.com/[my-github-username]/simple_zip_code/fork )
35
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
36
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
37
+ 4. Push to the branch (`git push origin my-new-feature`)
38
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,6 @@
1
+ require "simple_zip_code/version"
2
+ require "simple_zip_code/deduce_state"
3
+
4
+ module SimpleZipCode
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,374 @@
1
+ require 'simple_zip_code/in_range'
2
+
3
+ module SimpleZipCode
4
+ module DeduceState
5
+ include Contracts::Core
6
+
7
+ extend self
8
+
9
+ Contract InRange[99501..99950] => String
10
+ def get_state_from_zip(_zip)
11
+ "AK"
12
+ end
13
+
14
+ Contract InRange[35004..36925] => String
15
+ def get_state_from_zip(_zip)
16
+ "AL"
17
+ end
18
+
19
+ Contract InRange[71601..72959] => String
20
+ def get_state_from_zip(_zip)
21
+ "AR"
22
+ end
23
+
24
+ Contract InRange[75502..75502] => String
25
+ def get_state_from_zip(_zip)
26
+ "AR"
27
+ end
28
+
29
+ Contract InRange[85001..86556] => String
30
+ def get_state_from_zip(_zip)
31
+ "AZ"
32
+ end
33
+
34
+ Contract InRange[90001..96162] => String
35
+ def get_state_from_zip(_zip)
36
+ "CA"
37
+ end
38
+
39
+ Contract InRange[80001..81658] => String
40
+ def get_state_from_zip(_zip)
41
+ "CO"
42
+ end
43
+
44
+ Contract InRange[6001..6389] => String
45
+ def get_state_from_zip(_zip)
46
+ "CT"
47
+ end
48
+
49
+ Contract InRange[6401..6928] => String
50
+ def get_state_from_zip(_zip)
51
+ "CT"
52
+ end
53
+
54
+ Contract InRange[20001..20039] => String
55
+ def get_state_from_zip(_zip)
56
+ "DC"
57
+ end
58
+
59
+ Contract InRange[20042..20599] => String
60
+ def get_state_from_zip(_zip)
61
+ "DC"
62
+ end
63
+
64
+ Contract InRange[20799..20799] => String
65
+ def get_state_from_zip(_zip)
66
+ "DC"
67
+ end
68
+
69
+ Contract InRange[19701..19980] => String
70
+ def get_state_from_zip(_zip)
71
+ "DE"
72
+ end
73
+
74
+ Contract InRange[32004..34997] => String
75
+ def get_state_from_zip(_zip)
76
+ "FL"
77
+ end
78
+
79
+ Contract InRange[30001..31999] => String
80
+ def get_state_from_zip(_zip)
81
+ "GA"
82
+ end
83
+
84
+ Contract InRange[39901..39901] => String
85
+ def get_state_from_zip(_zip)
86
+ "GA"
87
+ end
88
+
89
+ Contract InRange[96701..96898] => String
90
+ def get_state_from_zip(_zip)
91
+ "HI"
92
+ end
93
+
94
+ Contract InRange[50001..52809] => String
95
+ def get_state_from_zip(_zip)
96
+ "IA"
97
+ end
98
+
99
+ Contract InRange[68119..68120] => String
100
+ def get_state_from_zip(_zip)
101
+ "IA"
102
+ end
103
+
104
+ Contract InRange[83201..83876] => String
105
+ def get_state_from_zip(_zip)
106
+ "ID"
107
+ end
108
+
109
+ Contract InRange[60001..62999] => String
110
+ def get_state_from_zip(_zip)
111
+ "IL"
112
+ end
113
+
114
+ Contract InRange[46001..47997] => String
115
+ def get_state_from_zip(_zip)
116
+ "IN"
117
+ end
118
+
119
+ Contract InRange[66002..67954] => String
120
+ def get_state_from_zip(_zip)
121
+ "KS"
122
+ end
123
+
124
+ Contract InRange[40003..42788] => String
125
+ def get_state_from_zip(_zip)
126
+ "KY"
127
+ end
128
+
129
+ Contract InRange[70001..71232] => String
130
+ def get_state_from_zip(_zip)
131
+ "LA"
132
+ end
133
+
134
+ Contract InRange[71234..71497] => String
135
+ def get_state_from_zip(_zip)
136
+ "LA"
137
+ end
138
+
139
+ Contract InRange[1001..2791] => String
140
+ def get_state_from_zip(_zip)
141
+ "MA"
142
+ end
143
+
144
+ Contract InRange[5501..5544] => String
145
+ def get_state_from_zip(_zip)
146
+ "MA"
147
+ end
148
+
149
+ Contract InRange[20331..20331] => String
150
+ def get_state_from_zip(_zip)
151
+ "MD"
152
+ end
153
+
154
+ Contract InRange[20335..20797] => String
155
+ def get_state_from_zip(_zip)
156
+ "MD"
157
+ end
158
+
159
+ Contract InRange[20812..21930] => String
160
+ def get_state_from_zip(_zip)
161
+ "MD"
162
+ end
163
+
164
+ Contract InRange[3901..4992] => String
165
+ def get_state_from_zip(_zip)
166
+ "ME"
167
+ end
168
+
169
+ Contract InRange[48001..49971] => String
170
+ def get_state_from_zip(_zip)
171
+ "MI"
172
+ end
173
+
174
+ Contract InRange[55001..56763] => String
175
+ def get_state_from_zip(_zip)
176
+ "MN"
177
+ end
178
+
179
+ Contract InRange[63001..65899] => String
180
+ def get_state_from_zip(_zip)
181
+ "MO"
182
+ end
183
+
184
+ Contract InRange[38601..39776] => String
185
+ def get_state_from_zip(_zip)
186
+ "MS"
187
+ end
188
+
189
+ Contract InRange[71233..71233] => String
190
+ def get_state_from_zip(_zip)
191
+ "MS"
192
+ end
193
+
194
+ Contract InRange[59001..59937] => String
195
+ def get_state_from_zip(_zip)
196
+ "MT"
197
+ end
198
+
199
+ Contract InRange[27006..28909] => String
200
+ def get_state_from_zip(_zip)
201
+ "NC"
202
+ end
203
+
204
+ Contract InRange[58001..58856] => String
205
+ def get_state_from_zip(_zip)
206
+ "ND"
207
+ end
208
+
209
+ Contract InRange[68001..68118] => String
210
+ def get_state_from_zip(_zip)
211
+ "NE"
212
+ end
213
+
214
+ Contract InRange[68122..69367] => String
215
+ def get_state_from_zip(_zip)
216
+ "NE"
217
+ end
218
+
219
+ Contract InRange[3031..3897] => String
220
+ def get_state_from_zip(_zip)
221
+ "NH"
222
+ end
223
+
224
+ Contract InRange[7001..8989] => String
225
+ def get_state_from_zip(_zip)
226
+ "NJ"
227
+ end
228
+
229
+ Contract InRange[87001..88441] => String
230
+ def get_state_from_zip(_zip)
231
+ "NM"
232
+ end
233
+
234
+ Contract InRange[88901..89883] => String
235
+ def get_state_from_zip(_zip)
236
+ "NV"
237
+ end
238
+
239
+ Contract InRange[6390..6390] => String
240
+ def get_state_from_zip(_zip)
241
+ "NY"
242
+ end
243
+
244
+ Contract InRange[10001..14975] => String
245
+ def get_state_from_zip(_zip)
246
+ "NY"
247
+ end
248
+
249
+ Contract InRange[43001..45999] => String
250
+ def get_state_from_zip(_zip)
251
+ "OH"
252
+ end
253
+
254
+ Contract InRange[73001..73199] => String
255
+ def get_state_from_zip(_zip)
256
+ "OK"
257
+ end
258
+
259
+ Contract InRange[73401..74966] => String
260
+ def get_state_from_zip(_zip)
261
+ "OK"
262
+ end
263
+
264
+ Contract InRange[97001..97920] => String
265
+ def get_state_from_zip(_zip)
266
+ "OR"
267
+ end
268
+
269
+ Contract InRange[15001..19640] => String
270
+ def get_state_from_zip(_zip)
271
+ "PA"
272
+ end
273
+
274
+ Contract InRange[0..0] => String
275
+ def get_state_from_zip(_zip)
276
+ "PR"
277
+ end
278
+
279
+ Contract InRange[2801..2940] => String
280
+ def get_state_from_zip(_zip)
281
+ "RI"
282
+ end
283
+
284
+ Contract InRange[29001..29948] => String
285
+ def get_state_from_zip(_zip)
286
+ "SC"
287
+ end
288
+
289
+ Contract InRange[57001..57799] => String
290
+ def get_state_from_zip(_zip)
291
+ "SD"
292
+ end
293
+
294
+ Contract InRange[37010..38589] => String
295
+ def get_state_from_zip(_zip)
296
+ "TN"
297
+ end
298
+
299
+ Contract InRange[73301..73301] => String
300
+ def get_state_from_zip(_zip)
301
+ "TX"
302
+ end
303
+
304
+ Contract InRange[75001..75501] => String
305
+ def get_state_from_zip(_zip)
306
+ "TX"
307
+ end
308
+
309
+ Contract InRange[75503..79999] => String
310
+ def get_state_from_zip(_zip)
311
+ "TX"
312
+ end
313
+
314
+ Contract InRange[88510..88589] => String
315
+ def get_state_from_zip(_zip)
316
+ "TX"
317
+ end
318
+
319
+ Contract InRange[84001..84784] => String
320
+ def get_state_from_zip(_zip)
321
+ "UT"
322
+ end
323
+
324
+ Contract InRange[20040..20041] => String
325
+ def get_state_from_zip(_zip)
326
+ "VA"
327
+ end
328
+
329
+ Contract InRange[20040..20167] => String
330
+ def get_state_from_zip(_zip)
331
+ "VA"
332
+ end
333
+
334
+ Contract InRange[20042..20042] => String
335
+ def get_state_from_zip(_zip)
336
+ "VA"
337
+ end
338
+
339
+ Contract InRange[22001..24658] => String
340
+ def get_state_from_zip(_zip)
341
+ "VA"
342
+ end
343
+
344
+ Contract InRange[5001..5495] => String
345
+ def get_state_from_zip(_zip)
346
+ "VT"
347
+ end
348
+
349
+ Contract InRange[5601..5907] => String
350
+ def get_state_from_zip(_zip)
351
+ "VT"
352
+ end
353
+
354
+ Contract InRange[98001..99403] => String
355
+ def get_state_from_zip(_zip)
356
+ "WA"
357
+ end
358
+
359
+ Contract InRange[53001..54990] => String
360
+ def get_state_from_zip(_zip)
361
+ "WI"
362
+ end
363
+
364
+ Contract InRange[24701..26886] => String
365
+ def get_state_from_zip(_zip)
366
+ "WV"
367
+ end
368
+
369
+ Contract InRange[82001..83128] => String
370
+ def get_state_from_zip(_zip)
371
+ "WY"
372
+ end
373
+ end
374
+ end
@@ -0,0 +1,12 @@
1
+ module SimpleZipCode
2
+ class InRange < Contracts::Builtin::CallableClass
3
+
4
+ def initialize(range)
5
+ @range = range
6
+ end
7
+
8
+ def valid?(value)
9
+ @range.include?(value)
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,3 @@
1
+ module SimpleZipCode
2
+ VERSION = "0.3.1"
3
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'simple_zip_code/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "simple_zip_code"
8
+ spec.version = SimpleZipCode::VERSION
9
+ spec.authors = ["Madeline Carson"]
10
+ spec.email = ["madeline.carson@gmail.com"]
11
+ spec.summary = %q{Simple gem to determine the US state abbreviation from a postal code.}
12
+ spec.homepage = ""
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.7"
21
+ spec.add_development_dependency "rake", "~> 10.0"
22
+
23
+ spec.add_development_dependency "contracts", "~> 0.12.0"
24
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simple_zip_code
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.1
5
+ platform: ruby
6
+ authors:
7
+ - Madeline Carson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-02-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: contracts
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.12.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.12.0
55
+ description:
56
+ email:
57
+ - madeline.carson@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - lib/simple_zip_code.rb
68
+ - lib/simple_zip_code/deduce_state.rb
69
+ - lib/simple_zip_code/in_range.rb
70
+ - lib/simple_zip_code/version.rb
71
+ - simple_zip_code.gemspec
72
+ homepage: ''
73
+ licenses:
74
+ - MIT
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.4.5
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: Simple gem to determine the US state abbreviation from a postal code.
96
+ test_files: []
97
+ has_rdoc: