uk_postcode 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0a919ea202a84289397d9ee28a3cfeb13296c96f
4
- data.tar.gz: 61ae6cb187e332087b477335996e91a5f57a6bc5
3
+ metadata.gz: b5be9121c81ffedda98694f2c1fb84e769047d7c
4
+ data.tar.gz: 2f37c078760e05e293694dac94de9b98aac4226a
5
5
  SHA512:
6
- metadata.gz: aa9f41d0d1b1b9b2793cb6d5075e533f0f7364707b275ec34550ed3f401073de66158f08715ed55a5ac96bde1b12ddd0c9c7e5dd29a4054e0bec885e49f33c6f
7
- data.tar.gz: 96ba39a7b24beab30c4a80cbd37ff50f95a6ed2ab6bad84049fc864c8279608140accb6b579cca1084f8e1ab13414e463a7a00389449cc692716449d7244b4ef
6
+ metadata.gz: 88fd9a5d8b63c7f3325263708d6022b0f16209de37172b184ab014a0d75d575bf5d37159e730b2faee3c5832659a604d0aabb8123bda3175d7eb90464eb56d04
7
+ data.tar.gz: 35cf99808de33ec16f8e4a93b5c4e8efe1c0a9a88f14e0502696254b97ab7b0b7318aee102157c0d3de6d284775f6d694ada8fcf69068a3dcbee3058155f82e5
data/CHANGES ADDED
@@ -0,0 +1,35 @@
1
+ 2.1.0 (2015-03-21)
2
+
3
+ * Updated country lookup using latest ONS Postcode Database (November 2014).
4
+ * Added a #full_valid? method for convenience.
5
+ * Fix: corrected references to test/ in Makefile to be spec/.
6
+
7
+ 2.0.0 (2015-02-08)
8
+
9
+ * Significant breaking API change: UKPostcode.new -> UKPostcode.parse.
10
+ * Fix: gem now builds on Ruby 1.9.
11
+ * Moved tests to RSpec.
12
+ * Added #country method to return the country of a postcode (where known).
13
+ * Now testing with the ONS Postcode Database (includes Northern Ireland).
14
+
15
+ 1.0.1 (2014-12-14)
16
+
17
+ * Made licensing (MIT) explicit.
18
+ * Fix: Now works with Ruby 1.9.
19
+
20
+ 1.0.0 (2010-11-05)
21
+
22
+ * Fix: outcodes in the form [A-Z]1[0-9] are now parsed correctly.
23
+
24
+ 0.0.3 (2010-06-01)
25
+
26
+ * Automatically correct more 0s that should be Os.
27
+
28
+ 0.0.2 (2010-01-09)
29
+
30
+ * Fix: some real postcodes were not considered to be valid.
31
+ * Correct mistaken I/O/1/0 inputs.
32
+
33
+ 0.0.1 (2010-01-06)
34
+
35
+ * Initial release.
data/README.md CHANGED
@@ -23,52 +23,54 @@ Parse and extract sections of a full postcode:
23
23
 
24
24
  ```ruby
25
25
  pc = UKPostcode.parse("W1A 2AB")
26
- pc.valid? # => true
27
- pc.full? # => true
28
- pc.outcode # => "W1A"
29
- pc.incode # => "2AB"
30
- pc.area # => "W"
31
- pc.district # => "1A"
32
- pc.sector # => "2"
33
- pc.unit # => "AB"
26
+ pc.valid? # => true
27
+ pc.full? # => true
28
+ pc.full_valid? # => true
29
+ pc.outcode # => "W1A"
30
+ pc.incode # => "2AB"
31
+ pc.area # => "W"
32
+ pc.district # => "1A"
33
+ pc.sector # => "2"
34
+ pc.unit # => "AB"
34
35
  ```
35
36
 
36
37
  Or of a partial postcode:
37
38
 
38
39
  ```ruby
39
40
  pc = UKPostcode.parse("W1A")
40
- pc.valid? # => true
41
- pc.full? # => false
42
- pc.outcode # => "W1A"
43
- pc.incode # => nil
44
- pc.area # => "W"
45
- pc.district # => "1A"
46
- pc.sector # => nil
47
- pc.unit # => nil
41
+ pc.valid? # => true
42
+ pc.full? # => false
43
+ pc.full_valid? # => false
44
+ pc.outcode # => "W1A"
45
+ pc.incode # => nil
46
+ pc.area # => "W"
47
+ pc.district # => "1A"
48
+ pc.sector # => nil
49
+ pc.unit # => nil
48
50
  ```
49
51
 
50
52
  Postcodes are converted to a normal or canonical form:
51
53
 
52
54
  ```ruby
53
55
  pc = UKPostcode.parse("w1a1aa")
54
- pc.valid? # => true
55
- pc.area # => "W"
56
- pc.district # => "1A"
57
- pc.sector # => "1"
58
- pc.unit # => "AA
59
- pc.to_s # => "W1A 1AA"
56
+ pc.valid? # => true
57
+ pc.area # => "W"
58
+ pc.district # => "1A"
59
+ pc.sector # => "1"
60
+ pc.unit # => "AA
61
+ pc.to_s # => "W1A 1AA"
60
62
  ```
61
63
 
62
64
  And mistakes with I/1 and O/0 are corrected:
63
65
 
64
66
  ```ruby
65
67
  pc = UKPostcode.parse("WIA OAA")
66
- pc.valid? # => true
67
- pc.area # => "W"
68
- pc.district # => "1A"
69
- pc.sector # => "0"
70
- pc.unit # => "AA
71
- pc.to_s # => "W1A 0AA"
68
+ pc.valid? # => true
69
+ pc.area # => "W"
70
+ pc.district # => "1A"
71
+ pc.sector # => "0"
72
+ pc.unit # => "AA
73
+ pc.to_s # => "W1A 0AA"
72
74
  ```
73
75
 
74
76
  Find the country of a full or partial postcode (if possible: some outcodes span
@@ -93,11 +95,12 @@ Invalid postcodes:
93
95
 
94
96
  ```ruby
95
97
  pc = UKPostcode.parse("Not Valid")
96
- pc.valid? # => false
97
- pc.full? # => false
98
- pc.area # => nil
99
- pc.to_s # => "Not valid"
100
- pc.country # => :unknown
98
+ pc.valid? # => false
99
+ pc.full? # => false
100
+ pc.full_valid? # => false
101
+ pc.area # => nil
102
+ pc.to_s # => "Not valid"
103
+ pc.country # => :unknown
101
104
  ```
102
105
 
103
106
  ## Tips for Rails
@@ -121,7 +124,7 @@ To validate, use something like this:
121
124
  class PostcodeValidator < ActiveModel::EachValidator
122
125
  def validate_each(record, attribute, value)
123
126
  ukpc = UKPostcode.parse(value)
124
- unless ukpc.valid? && ukpc.full?
127
+ unless ukpc.full_valid?
125
128
  record.errors[attribute] << "not recognised as a UK postcode"
126
129
  end
127
130
  end
@@ -171,14 +174,60 @@ files and run the tests via Rake instead:
171
174
  $ rake
172
175
  ```
173
176
 
177
+ ## Occasionally asked questions
178
+
179
+ ### Does it support Father Christmas's postcode?
180
+
181
+ No. The old postcode was SAN TA1; the current one is [XM4 5HQ][santa].
182
+ (XMAS HQ, geddit?)
183
+ For most people, these probably aren't useful, as they don't correspond to
184
+ actual locations, and are only used by Royal Mail internally.
185
+
186
+ See "Adding additional formats" if you'd like to support this.
187
+
188
+ ### Does it support BFPO?
189
+
190
+ No. They're not really postcodes, though they serve a similar purpose.
191
+ Some of them are abroad; some of them are on boats that move around; some of
192
+ them are ephemeral and exists only for particular operations.
193
+ This library has been designed with the assumption that most people won't want
194
+ to handle BFPO codes, and that those that do can do so explicitly.
195
+
196
+ See "Adding additional formats" if you'd like to support them.
197
+
198
+ The new [BF1 format][bfpo] postcodes *can* be parsed, although their location
199
+ is always unknown.
200
+
201
+ ## Adding additional formats
202
+
203
+ Parsing is implemented via the `ParserChain` class, which attempts to parse
204
+ the supplied text via each parser in turn.
205
+ The `UKPostcode.parse` method is effectively a thin wrapper that does this:
206
+
207
+ ```ruby
208
+ chain = ParserChain.new(GiroPostcode, GeographicPostcode, InvalidPostcode)
209
+ chain.parse(str)
210
+ ```
211
+
212
+ Each class passed to `ParserChain.new` must implement a class method
213
+ `parse(str)` and return either a postcode object (see `AbstractPostcode`) or
214
+ nil.
215
+ The first non-nil object is returned.
216
+
217
+ `InvalidPostcode` is at the end of the chain to ensure that a postcode object
218
+ is always returned.
219
+
220
+ To add an additional class, subclass `AbstractPostcode`, implement the abstract
221
+ methods, and instantiate your own `ParserChain`.
222
+
174
223
  ## Licensing
175
224
 
176
225
  You may use this library according to the terms of the MIT License; see
177
226
  COPYING.txt for details.
178
227
 
179
- The regular expressions in `lookup.rb` are derived from the ONS Postcode
180
- Directory according to the terms of the [Open Government
181
- Licence][onspd-lic].
228
+ The regular expressions in `country_lookup.rb` are derived from the ONS
229
+ Postcode Directory according to the terms of the
230
+ [Open Government Licence][onspd-lic].
182
231
 
183
232
  > Under the terms of the Open Government Licence (OGL) […] anyone wishing to
184
233
  > use or re-use ONS material, whether commercially or privately, may do so
@@ -191,6 +240,8 @@ data in the ONSPD, this is not used to generate the regular expressions.
191
240
  Fortunately, Northern Ireland postcodes are very simple: they all start with
192
241
  `BT`!
193
242
 
243
+ [bfpo]: https://www.gov.uk/government/publications/british-forces-post-office-locations
194
244
  [mys]: http://parlvid.mysociety.org/os/
195
245
  [onspd]: http://www.ons.gov.uk/ons/guide-method/geography/products/postcode-directories/-nspp-/index.html
196
246
  [onspd-lic]: http://www.ons.gov.uk/ons/guide-method/geography/beginner-s-guide/licences/index.html
247
+ [santa]: http://services.royalmail.com/santa-schools
@@ -29,6 +29,10 @@ module UKPostcode
29
29
  raise NotImplemented
30
30
  end
31
31
 
32
+ def full_valid?
33
+ full? && valid?
34
+ end
35
+
32
36
  def country
33
37
  :unknown
34
38
  end
@@ -1,8 +1,8 @@
1
1
  module UKPostcode
2
2
  COUNTRY_LOOKUP = {
3
- england: /^(?:AL|B[123456789ABDHLNRS]|C(?:A(?:1|2|3|4|5|6(?:4|5(?:G|H[TU]|L[GHJLNPQRSTUWXYZ]|N|P|Q|R|S|T|U|W|X|Y)|6|7)|7|8|9)|B|H(?:1(?:1|2|3|4(?:A|B|D|E|F|G|H|J|L|N|P|Q[ABDFGHJNPQRSTUWX]|R|S|W|X|Y|Z)|5|6(?:A|B[DEFGHJU]|D[ABEFGHLNPQRSTUWXYZ]|E[ADEFGHJLNPQRSTUWXYZ]|F|G|H[DEFGJLNQSTUWXYZ]|J|L|N|P|Q[AP]|R|W|X|Y|Z)|9)|2(?:1|2|3|4|5|6|7|89(?:A[ABEFGHJLNPQRSTUWXYZ]|B)|99(?:A[BDEFGHJLNPQRSTUWXYZ]|B|D|E))|3(?:5|6|7|8|9|0|1|2|3|49(?:A[ABDEFGHJLNQRSTUWXYZ]|B|D|E|S|T|Z))|4(?:0(?:EJ|W[BDFGHRU]|Y[HJ]|Z[ADEFGHJLPTUWY])|7|8(?:A|B|D|E|H|J|L[BDEFLNPSUXYZ]|N[DEFGLNPQRSTUWXYZ]|P[ADEFGHJLNPQRSTUWXZ]|Q[ADU]|R[AD]|W[ABDEFGHJLPQRSTUWXYZ]|X|Y|Z|0|1|2|3|4|5|6|7|8|9)|9(?:A[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:A[DEFGHJLNPQRSTUWXYZ]|B|D|E|G|H|J[AB]|NZ|P[ABDE]|W[BE])|4RE)|47(?:A[NZ]|HY|J[HTUZ]|L|N[ABD])|97|0(?:0(?:A|B|D|E|G|H|J|L|N|P|W[BDEFG])|7(?:J[EFGHJLNQW]|N[EFSTUXYZ]|P[AGSTUXYZ]|Q)|9(?:B[PW]|HZ|J[GHJLNPRSTUWXYZ]|L[ABDEFGHJLNPQRTW]|PA))|56(?:A[ABDEFGHJLNPQRSTUWZ]|B[AB]|D[HJLNQSTUWXYZ]|E[ABFGHJLNQRSTUWXYZ]|H[ABDEFGHJLNPQRSWXZ]|J|L|N|P|Q|R|S[ABDEFGHQRSTUX]|T[ABDEFGHJLNPQWY]|U[AJLNPR]|W|Y)|6|7|8)|2(?:2(?:5(?:A|B|D|E|H|J|L|N|W[ABPZ])|6(?:A|B|D|E[NPRSTUWXYZ]|F|G|H[AEFLNPRSTUWXYZ]|J[ABDEFGHJLNPQRSTWYZ]|L[ABDEFHJPRST]|N[ABDEFGHJLNPQRSXYZ]|P|Q|R|S|T|U|W[DFG]|X|Y))|56|0|1(?:0|1|7|8(?:A|B|D[ABDEFGHJPQRSTUWXYZ]|E[ABDEFGHJLNQSTUXYZ]|F|G|H|J[ABDEFGHJZ]|L[ADEFGHJLNPQRSTUWXYZ]|N|P|Q|R|S|T|W|X|Z)|9)|3|4)|5(?:0J[JLN]|9(?:A[RSTUWXYZ]|B[ABDEFGHJLNPQSTUW]|EU|FB|GN|LD|SB))|78PS|95J[PW])))/,
6
6
  channel_islands: /^(?:GY|J)/,
7
7
  isle_of_man: /^IM/,
8
8
  northern_ireland: /^BT/
@@ -1,3 +1,3 @@
1
1
  module UKPostcode
2
- VERSION = "2.0.0"
2
+ VERSION = "2.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uk_postcode
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Battley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-08 00:00:00.000000000 Z
11
+ date: 2015-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -44,6 +44,7 @@ executables: []
44
44
  extensions: []
45
45
  extra_rdoc_files: []
46
46
  files:
47
+ - CHANGES
47
48
  - COPYING.txt
48
49
  - README.md
49
50
  - lib/uk_postcode.rb