paf 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/paf.rb +4 -1
- data/lib/paf/attribute.rb +2 -1
- data/lib/paf/formattable.rb +5 -0
- data/lib/paf/premises.rb +1 -0
- data/lib/paf/premises/common.rb +4 -0
- data/lib/paf/premises/rule101.rb +0 -4
- data/lib/paf/thoroughfare_locality.rb +1 -0
- data/lib/paf/version.rb +1 -1
- data/paf.gemspec +7 -1
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6dd17987d33a92bdf4f5fe218b0ad72c570add4f
|
4
|
+
data.tar.gz: d8c7802c5b9bf6cd4cd02dbd6b56d33a8d89629d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a38a0e2a2922cbaa10f98adfb594ae3abdddf7283d0cc08c4266ab88ecfa0de8cac08f25a185aa8b32325f7c484d3fb0a3fcc083ad7bbd6b5362d8b7a643ea8d
|
7
|
+
data.tar.gz: b3ba1f6afaca1d5b4654f0186f99e2465be036550310757a15090fae9aee65d2ce14e0cec066e14043bc84f4ccb53348df8115c5c9b79e5cb279d0b9bba259d2
|
data/lib/paf.rb
CHANGED
@@ -2,7 +2,7 @@ require 'paf/version'
|
|
2
2
|
require 'paf/attribute'
|
3
3
|
require 'paf/formattable'
|
4
4
|
|
5
|
-
#
|
5
|
+
# Base class from the elements of a UK Royal Mail Postcode Address File entry
|
6
6
|
class Paf
|
7
7
|
include Paf::Attribute
|
8
8
|
include Paf::Formattable
|
@@ -14,14 +14,17 @@ class Paf
|
|
14
14
|
args.each { |k, v| send("#{k}=", v) }
|
15
15
|
end
|
16
16
|
|
17
|
+
# PO Box number prepended with the string PO BOX
|
17
18
|
def po_box
|
18
19
|
"PO BOX #{po_box_number}" unless po_box_number.to_s.empty?
|
19
20
|
end
|
20
21
|
|
22
|
+
# Dependent thoroughfare name and descriptor
|
21
23
|
def dependent_thoroughfare
|
22
24
|
concatenated(self.class.dependent_thoroughfare_attrs)
|
23
25
|
end
|
24
26
|
|
27
|
+
# Thoroughfare name and descriptor
|
25
28
|
def thoroughfare
|
26
29
|
concatenated(self.class.thoroughfare_attrs)
|
27
30
|
end
|
data/lib/paf/attribute.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
class Paf
|
2
|
-
# Basic attributes that make up a PAF entry
|
2
|
+
# Basic attributes or elements that make up a PAF entry
|
3
3
|
module Attribute
|
4
4
|
def self.included(base)
|
5
5
|
base.extend ClassMethods
|
6
6
|
end
|
7
|
+
private_class_method :included
|
7
8
|
|
8
9
|
# Methods to be added to the including class
|
9
10
|
module ClassMethods
|
data/lib/paf/formattable.rb
CHANGED
@@ -11,6 +11,7 @@ class Paf
|
|
11
11
|
include ThoroughfareLocality
|
12
12
|
end
|
13
13
|
end
|
14
|
+
private_class_method :included
|
14
15
|
|
15
16
|
# Methods to be added to the including class
|
16
17
|
module ClassMethods
|
@@ -24,16 +25,19 @@ class Paf
|
|
24
25
|
]
|
25
26
|
end
|
26
27
|
|
28
|
+
# Formats a hash of PAF address elements into an array of strings
|
27
29
|
def format(args)
|
28
30
|
new(args).format
|
29
31
|
end
|
30
32
|
|
33
|
+
# Formats a hash of PAF address elements into a string
|
31
34
|
def to_s(*args)
|
32
35
|
return super if args.empty?
|
33
36
|
new(args[0]).to_s
|
34
37
|
end
|
35
38
|
end
|
36
39
|
|
40
|
+
# Formats a Paf instance into an array of strings
|
37
41
|
def format
|
38
42
|
array = lines
|
39
43
|
%i[post_town postcode].each do |attr|
|
@@ -42,6 +46,7 @@ class Paf
|
|
42
46
|
array
|
43
47
|
end
|
44
48
|
|
49
|
+
# Formats a Paf instance into a string
|
45
50
|
def to_s
|
46
51
|
string = (lines + [post_town.to_s]).reject(&:empty?).join(', ')
|
47
52
|
([string] + [postcode]).reject(&:empty?).join('. ')
|
data/lib/paf/premises.rb
CHANGED
data/lib/paf/premises/common.rb
CHANGED
data/lib/paf/premises/rule101.rb
CHANGED
data/lib/paf/version.rb
CHANGED
data/paf.gemspec
CHANGED
@@ -10,7 +10,13 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.authors = ['John Bard']
|
11
11
|
spec.email = ['johnbard@globalnet.co.uk']
|
12
12
|
|
13
|
-
spec.summary = 'Royal Mail PAF Formatter'
|
13
|
+
spec.summary = 'Royal Mail Postcode Address File (PAF) Formatter'
|
14
|
+
spec.description = <<-EOF
|
15
|
+
A gem to format the elements of a Royal Mail Postcode Address File entry
|
16
|
+
according to the rules described in the Royal Mail Programmer's Guide
|
17
|
+
Edition 7, Version 5.0
|
18
|
+
(http://www.royalmail.com/sites/default/files/docs/pdf/programmers_guide_edition_7_v5.pdf)
|
19
|
+
EOF
|
14
20
|
spec.license = 'MIT'
|
15
21
|
|
16
22
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Bard
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,7 +80,11 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '1.4'
|
83
|
-
description:
|
83
|
+
description: |2
|
84
|
+
A gem to format the elements of a Royal Mail Postcode Address File entry
|
85
|
+
according to the rules described in the Royal Mail Programmer's Guide
|
86
|
+
Edition 7, Version 5.0
|
87
|
+
(http://www.royalmail.com/sites/default/files/docs/pdf/programmers_guide_edition_7_v5.pdf)
|
84
88
|
email:
|
85
89
|
- johnbard@globalnet.co.uk
|
86
90
|
executables: []
|
@@ -137,5 +141,5 @@ rubyforge_project:
|
|
137
141
|
rubygems_version: 2.5.2
|
138
142
|
signing_key:
|
139
143
|
specification_version: 4
|
140
|
-
summary: Royal Mail PAF Formatter
|
144
|
+
summary: Royal Mail Postcode Address File (PAF) Formatter
|
141
145
|
test_files: []
|