postcode_validation 0.0.12 → 0.0.13

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: 81b7f2c35a2e2a77cb0ba321af57f507b45ab31e
4
- data.tar.gz: 0c8b61dbb12285f18023a0d10fb7068fb8f55f70
3
+ metadata.gz: 874f4ef4bebde649baf380baf52b76802df6d10a
4
+ data.tar.gz: c3b9af4ce0ccddfd52a1a07199bdd598a1dab509
5
5
  SHA512:
6
- metadata.gz: f1ecf4638a02a8ff10c3f0dbfbdf29daf5b6950901a918956801063d719c80ffe5b9dd302858359ab4ec50e801717b05c48154354a68ea5aca39b146fb2e4031
7
- data.tar.gz: 8ab12a39697d09f02b155b9e64cd362e70909754317d07a79beb6b6d2a5ccb82d7dca4c217545f5de94b62547f0c153fa6721fa64ca612a9570b722a91a0170f
6
+ metadata.gz: 56c37f46432341f5ee4863b1a8259a29013da6e7f9a1263b3a19300cdb3ace9e42b64e2343ae4c43996f466abc41808d53e534488b19663ca83ffe2e597ebaf0
7
+ data.tar.gz: ce5481c78699cfd23cb8b298e7105883840d4036272043d49e402840c35a5710d7365f9201c2b53258c596eec26e2064f61cdf440c7b5870e994366d44dd6bf8
data/README.md CHANGED
@@ -76,7 +76,7 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/madete
76
76
 
77
77
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
78
78
 
79
- ##Credits
79
+ ## Credits
80
80
 
81
81
  Developed and maintained by [Made](http://www.madetech.co.uk?ref=github&repo=postcode_validation).
82
82
 
@@ -12,6 +12,11 @@ module PostcodeValidation
12
12
 
13
13
  def execute(postcode:, country:)
14
14
  check_country(country)
15
+
16
+ if country == 'SG'
17
+ return check_postcode_format(postcode_without_spaces(postcode), country)
18
+ end
19
+
15
20
  check_postcode_format(postcode, country)
16
21
  result = matched_addresses(postcode, country)
17
22
 
@@ -63,6 +68,10 @@ module PostcodeValidation
63
68
  on_error(error)
64
69
  { valid?: true, reason: ['unable_to_reach_service'] }
65
70
  end
71
+
72
+ def postcode_without_spaces(postcode)
73
+ postcode.gsub(' ', '')
74
+ end
66
75
  end
67
76
  end
68
77
  end
@@ -2,6 +2,7 @@ require_relative 'format_validators/nl_postcode_validator'
2
2
  require_relative 'format_validators/be_postcode_validator'
3
3
  require_relative 'format_validators/gb_postcode_validator'
4
4
  require_relative 'format_validators/fr_postcode_validator'
5
+ require_relative 'format_validators/sg_postcode_validator'
5
6
  require_relative 'format_validators/no_op_postcode_validator'
6
7
 
7
8
  module PostcodeValidation
@@ -18,6 +19,8 @@ module PostcodeValidation
18
19
  FormatValidators::BEPostcodeValidator.new
19
20
  when 'FR'
20
21
  FormatValidators::FRPostcodeValidator.new
22
+ when 'SG'
23
+ FormatValidators::SGPostcodeValidator.new
21
24
  else
22
25
  FormatValidators::NoOpPostcodeValidator.new
23
26
  end
@@ -0,0 +1,13 @@
1
+ require_relative 'regex_validator'
2
+
3
+ module PostcodeValidation
4
+ module UseCase
5
+ class ValidateAddress
6
+ module FormatValidators
7
+ class SGPostcodeValidator < RegexValidator
8
+ REGEX = /\d{6}$/
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,3 +1,3 @@
1
1
  module PostcodeValidation
2
- VERSION = '0.0.12'
2
+ VERSION = '0.0.13'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postcode_validation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Craig J. Bass
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-22 00:00:00.000000000 Z
11
+ date: 2017-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -143,6 +143,7 @@ files:
143
143
  - lib/postcode_validation/use_case/validate_address/format_validators/nl_postcode_validator.rb
144
144
  - lib/postcode_validation/use_case/validate_address/format_validators/no_op_postcode_validator.rb
145
145
  - lib/postcode_validation/use_case/validate_address/format_validators/regex_validator.rb
146
+ - lib/postcode_validation/use_case/validate_address/format_validators/sg_postcode_validator.rb
146
147
  - lib/postcode_validation/version.rb
147
148
  - postcode_validation.gemspec
148
149
  homepage: