paf 0.1.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a90b60fc8b43ca2ff87c48f4f9f18d4a7e25e3fa
4
- data.tar.gz: 2b6baa0e31314fd255162ad545485c21079e68f3
3
+ metadata.gz: 6dd17987d33a92bdf4f5fe218b0ad72c570add4f
4
+ data.tar.gz: d8c7802c5b9bf6cd4cd02dbd6b56d33a8d89629d
5
5
  SHA512:
6
- metadata.gz: 236d1dbf47af7c6bf6f0e4dc90fb6bd9a4955d932e12e184dea32d01a768eaa900ae04483f295f09f14c24fd20b24c66c29a6694527349d52a8e6abd1f1025e7
7
- data.tar.gz: 26a859d3c1085e3722bb2641ca2ce72f0cb2b321747b68a175cacbad188717db4f00a3d3350f82c684df4f36f14e4371fc3788059219cf9b6b5665a67bfed1b6
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
- # BCore class from the elements of a UK Royal Mail Postcode Address File entry
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
@@ -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
@@ -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('. ')
@@ -9,6 +9,7 @@ class Paf
9
9
  def self.included(base)
10
10
  base.prepend Initializer
11
11
  end
12
+ private_class_method :included
12
13
 
13
14
  # initialize method to be prepended to the including class
14
15
  module Initializer
@@ -7,6 +7,10 @@ class Paf
7
7
 
8
8
  private
9
9
 
10
+ def concatenate?
11
+ concatenation_indicator == 'Y'
12
+ end
13
+
10
14
  def sub_name_and_name
11
15
  "#{sub_building_name} #{building_name}"
12
16
  end
@@ -13,10 +13,6 @@ class Paf
13
13
  true
14
14
  end
15
15
 
16
- def concatenate?
17
- concatenation_indicator == 'Y'
18
- end
19
-
20
16
  def number_sub_name_and_thoroughfare_or_locality
21
17
  "#{building_number}#{sub_building_name} "\
22
18
  "#{first_thoroughfare_or_locality}"
@@ -4,6 +4,7 @@ class Paf
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
@@ -1,4 +1,4 @@
1
1
  # PAF gem version
2
2
  class Paf
3
- VERSION = '0.1.0'.freeze
3
+ VERSION = '0.2.0'.freeze
4
4
  end
@@ -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.1.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-20 00:00:00.000000000 Z
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: []