postcode_validation 0.0.12 → 0.0.13
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 +4 -4
 - data/README.md +1 -1
 - data/lib/postcode_validation/use_case/validate_address.rb +9 -0
 - data/lib/postcode_validation/use_case/validate_address/format_validator.rb +3 -0
 - data/lib/postcode_validation/use_case/validate_address/format_validators/sg_postcode_validator.rb +13 -0
 - data/lib/postcode_validation/version.rb +1 -1
 - metadata +3 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 874f4ef4bebde649baf380baf52b76802df6d10a
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: c3b9af4ce0ccddfd52a1a07199bdd598a1dab509
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 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
         
     | 
    
        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. 
     | 
| 
      
 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- 
     | 
| 
      
 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: 
         
     |