parliament-grom-decorators 0.18.0 → 0.19.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: a37464b31a1038a3b556533191d1c290a8914399
4
- data.tar.gz: 4dc6e7f0c32b3bac054a4de54ee9aa383943f63e
3
+ metadata.gz: 742d93ef812fedee07314bb1ada949b19f74f792
4
+ data.tar.gz: 70597d5d914cbb9a69616b01212bc0d0fa19196c
5
5
  SHA512:
6
- metadata.gz: 219c237c04e747ffaa0ef2ebad94d011cdbfb7f1d58e4b681dcb72ea55826edbb3f1cad05261268b4a7b5b06da87ae5b0696128dab8e188a9ac803ecb106eca5
7
- data.tar.gz: df53ce058ebca4e96954a98c5e10d9374fff1c6e12b9a515dbb86406c04b9d97bdcd42978461c2f507d4dd3de7e6b5501cedee7cb7ee0a4000cb638835515789
6
+ metadata.gz: a7d9fad3a90a6a24f4a8f9dd0992362c7d0da67590c1841d0c78cc0f6092932e40330e697ad21c56328c0a77f371c72bb3d13ca89d8675f0e83c0575cea03b16
7
+ data.tar.gz: 531e1e5af2dd78b77bee189157393601f70c54755251a518737f1075fe069b2c5e91c4d9067a52c9e8e8d48f7710fb6d75c474d364102bef6b571c204cbd193b
@@ -3,32 +3,36 @@ module Parliament
3
3
  module Decorator
4
4
  # Decorator namespace for Grom::Node instances with type: https://id.parliament.uk/schema/ContactPoint
5
5
  module ContactPoint
6
+ # A hack has been added to postal_addresses, email, phone_number and fax_number
7
+ # to remove any details that are less than ATTRIBUTE_LENGTH_LIMIT_HACK in length
8
+ # including "." and "-" addresses when these have been mistakenly entered into Mnis
9
+ ATTRIBUTE_LENGTH_LIMIT_HACK = 1
6
10
  # Alias contactPointHasPostalAddress with fallback.
7
11
  #
8
12
  # @return [Array, Array] an array of the postal addresses for the Grom::Node or an empty array.
9
13
  def postal_addresses
10
- respond_to?(:contactPointHasPostalAddress) ? contactPointHasPostalAddress : []
14
+ @postal_addresses ||= respond_to?(:contactPointHasPostalAddress) ? contactPointHasPostalAddress.reject { |address| address.full_address.length <= ATTRIBUTE_LENGTH_LIMIT_HACK } : []
11
15
  end
12
16
 
13
17
  # Alias email with fallback.
14
18
  #
15
19
  # @return [String, String] the email of the Grom::Node or an empty string.
16
20
  def email
17
- instance_variable_get('@email'.to_sym).nil? ? '' : instance_variable_get('@email'.to_sym)
21
+ @email_decorator ||= instance_variable_get('@email'.to_sym) && instance_variable_get('@email'.to_sym).length > ATTRIBUTE_LENGTH_LIMIT_HACK ? instance_variable_get('@email'.to_sym).strip : ''
18
22
  end
19
23
 
20
24
  # Alias phoneNumber with fallback.
21
25
  #
22
26
  # @return [String, String] the phone number of the Grom::Node or an empty string.
23
27
  def phone_number
24
- respond_to?(:phoneNumber) ? phoneNumber : ''
28
+ @phone_number ||= respond_to?(:phoneNumber) && phoneNumber.length > ATTRIBUTE_LENGTH_LIMIT_HACK ? phoneNumber : ''
25
29
  end
26
30
 
27
31
  # Alias faxNumber with fallback.
28
32
  #
29
33
  # @return [String, String] the fax number of the Grom::Node or an empty string.
30
34
  def fax_number
31
- respond_to?(:faxNumber) ? faxNumber : ''
35
+ @fax_number ||= respond_to?(:faxNumber) && faxNumber.length > ATTRIBUTE_LENGTH_LIMIT_HACK ? faxNumber : ''
32
36
  end
33
37
 
34
38
  # Alias contactPointHasPerson with fallback.
@@ -1,7 +1,7 @@
1
1
  module Parliament
2
2
  module Grom
3
3
  module Decorator
4
- VERSION = '0.18.0'.freeze
4
+ VERSION = '0.19.0'.freeze
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parliament-grom-decorators
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.0
4
+ version: 0.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rebecca Appleyard
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-03-12 00:00:00.000000000 Z
11
+ date: 2018-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler