locality 1.0.6 → 1.1.0
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/README.md +4 -0
- data/lib/locality/postnummerservice.rb +9 -0
- data/lib/locality/postnummerservice/zip_code.rb +34 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eaefcc57f303581f6956a376a5941e8bcd53e478
|
4
|
+
data.tar.gz: 1bceaa3943402b4d057e83969690170cd9eadd9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a5495eb0b8b59d7b37eb91b9a775f2613704f4fa0b850da65d1f374041a58d64087d4e3bd393c22d274065b816e42f3f5cfac00fdbd8a0455740bef5f1b64b7
|
7
|
+
data.tar.gz: fd8a22a3ae4a3e93ede8fdb3019e17fa9eed8b445e362501855e2f8aa08b54714bdee115672838ef9c02163785306b70298820b9150210b19b520f8db0c0406b
|
data/README.md
CHANGED
@@ -40,6 +40,10 @@ lookup = Locality::Postnummerservice::State.new 7 # Kronoberg
|
|
40
40
|
available_codes = Locality::Postnummerservice::Province.codes
|
41
41
|
lookup = Locality::Postnummerservice::Province.new '0182' # Nacka
|
42
42
|
|
43
|
+
# Zip Codes
|
44
|
+
# See https://sv.wikipedia.org/wiki/Postnummer_i_Sverige
|
45
|
+
lookup = Locality::Postnummerservice::ZipCode.new '11417' # Stockholm
|
46
|
+
|
43
47
|
# On all of the above lookups you have the following attributes
|
44
48
|
lookup.code
|
45
49
|
lookup.name
|
@@ -3,6 +3,7 @@ require 'locality/postnummerservice/entry'
|
|
3
3
|
require 'locality/postnummerservice/aregion'
|
4
4
|
require 'locality/postnummerservice/province'
|
5
5
|
require 'locality/postnummerservice/state'
|
6
|
+
require 'locality/postnummerservice/zip_code'
|
6
7
|
|
7
8
|
module Locality
|
8
9
|
module Postnummerservice
|
@@ -22,6 +23,11 @@ module Locality
|
|
22
23
|
@provinces
|
23
24
|
end
|
24
25
|
|
26
|
+
def self.zip_codes
|
27
|
+
load
|
28
|
+
@zip_codes
|
29
|
+
end
|
30
|
+
|
25
31
|
private
|
26
32
|
|
27
33
|
def self.load
|
@@ -38,6 +44,7 @@ module Locality
|
|
38
44
|
@aregions = {}
|
39
45
|
@states = {}
|
40
46
|
@provinces = {}
|
47
|
+
@zip_codes = {}
|
41
48
|
end
|
42
49
|
|
43
50
|
def self.load!
|
@@ -49,6 +56,8 @@ module Locality
|
|
49
56
|
@states[entry.state_code] << entry
|
50
57
|
@provinces[entry.province_code] ||= []
|
51
58
|
@provinces[entry.province_code] << entry
|
59
|
+
@zip_codes[entry.zip_code] ||= []
|
60
|
+
@zip_codes[entry.zip_code] << entry
|
52
61
|
end
|
53
62
|
|
54
63
|
@loaded = true
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Locality
|
2
|
+
module Postnummerservice
|
3
|
+
class ZipCode
|
4
|
+
include Postnummerservice::Collection
|
5
|
+
|
6
|
+
def code
|
7
|
+
raw_code.to_i
|
8
|
+
end
|
9
|
+
|
10
|
+
def state
|
11
|
+
Locality::Postnummerservice::State.new(state_code)
|
12
|
+
end
|
13
|
+
|
14
|
+
def aregion
|
15
|
+
Locality::Postnummerservice::Aregion.new(aregion_code)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def state_code
|
21
|
+
state_codes.first
|
22
|
+
end
|
23
|
+
|
24
|
+
def aregion_code
|
25
|
+
aregion_codes.first
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.backend
|
29
|
+
Postnummerservice.zip_codes
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: locality
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bukowskis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -195,6 +195,7 @@ files:
|
|
195
195
|
- lib/locality/postnummerservice/entry.rb
|
196
196
|
- lib/locality/postnummerservice/province.rb
|
197
197
|
- lib/locality/postnummerservice/state.rb
|
198
|
+
- lib/locality/postnummerservice/zip_code.rb
|
198
199
|
homepage: https://github.com/bukowskis/locality
|
199
200
|
licenses: []
|
200
201
|
metadata: {}
|
@@ -219,3 +220,4 @@ signing_key:
|
|
219
220
|
specification_version: 4
|
220
221
|
summary: Wrapping databases provided by maxmind.com and postnummerservice.se
|
221
222
|
test_files: []
|
223
|
+
has_rdoc:
|