uk_account_validator 0.0.5 → 0.0.6
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:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 06b6904edebd4d278f6e985ec8f8393bb2553c4a
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 52648d7abd5a27a2ee24e82d870e524c5a15b4b3
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 80627f545c2d711fac360c6fa954c160ba320eba4bb4038279f4df0e5aa4c3b517012604e3154d534459536b46c31decbdc564537a4d14514d3c827e4f2f49cc
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 8b9f289f57826746f929394d13c2a85ac5686d21e70d8763d057a6c1258ce19de57057ba67d6cec1aeef2914d05d08225b09957b69136e8e2cd75ca0d8de3739
         
     | 
    
        data/.travis.yml
    CHANGED
    
    
    
        data/lib/uk_account_validator.rb
    CHANGED
    
    
| 
         @@ -0,0 +1,33 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Copied from backports gem
         
     | 
| 
      
 2 
     | 
    
         
            +
            unless Array.method_defined? :bsearch_index
         
     | 
| 
      
 3 
     | 
    
         
            +
              class Array
         
     | 
| 
      
 4 
     | 
    
         
            +
                def bsearch_index
         
     | 
| 
      
 5 
     | 
    
         
            +
                  return to_enum(__method__) unless block_given?
         
     | 
| 
      
 6 
     | 
    
         
            +
                  from = 0
         
     | 
| 
      
 7 
     | 
    
         
            +
                  to   = size - 1
         
     | 
| 
      
 8 
     | 
    
         
            +
                  satisfied = nil
         
     | 
| 
      
 9 
     | 
    
         
            +
                  while from <= to do
         
     | 
| 
      
 10 
     | 
    
         
            +
                    midpoint = (from + to).div(2)
         
     | 
| 
      
 11 
     | 
    
         
            +
                    result = yield(self[midpoint])
         
     | 
| 
      
 12 
     | 
    
         
            +
                    case result
         
     | 
| 
      
 13 
     | 
    
         
            +
                    when Numeric
         
     | 
| 
      
 14 
     | 
    
         
            +
                      return midpoint if result == 0
         
     | 
| 
      
 15 
     | 
    
         
            +
                      result = result < 0
         
     | 
| 
      
 16 
     | 
    
         
            +
                    when true
         
     | 
| 
      
 17 
     | 
    
         
            +
                      satisfied = midpoint
         
     | 
| 
      
 18 
     | 
    
         
            +
                    when nil, false
         
     | 
| 
      
 19 
     | 
    
         
            +
                      # nothing to do
         
     | 
| 
      
 20 
     | 
    
         
            +
                    else
         
     | 
| 
      
 21 
     | 
    
         
            +
                      raise TypeError, "wrong argument type #{result.class} (must be numeric, true, false or nil)"
         
     | 
| 
      
 22 
     | 
    
         
            +
                    end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                    if result
         
     | 
| 
      
 25 
     | 
    
         
            +
                      to = midpoint - 1
         
     | 
| 
      
 26 
     | 
    
         
            +
                    else
         
     | 
| 
      
 27 
     | 
    
         
            +
                      from = midpoint + 1
         
     | 
| 
      
 28 
     | 
    
         
            +
                    end
         
     | 
| 
      
 29 
     | 
    
         
            +
                  end
         
     | 
| 
      
 30 
     | 
    
         
            +
                  satisfied
         
     | 
| 
      
 31 
     | 
    
         
            +
                end
         
     | 
| 
      
 32 
     | 
    
         
            +
              end
         
     | 
| 
      
 33 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -8,24 +8,28 @@ module UkAccountValidator 
     | 
|
| 
       8 
8 
     | 
    
         
             
                    @weights << ModulusWeight.from_line(line)
         
     | 
| 
       9 
9 
     | 
    
         
             
                  end
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
       11 
     | 
    
         
            -
                  @weights. 
     | 
| 
      
 11 
     | 
    
         
            +
                  @weights.sort_by! { |weight| -weight.sort_code_start.to_i }
         
     | 
| 
       12 
12 
     | 
    
         
             
                end
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
     | 
    
         
            -
                def find(sort_code 
     | 
| 
      
 14 
     | 
    
         
            +
                def find(sort_code)
         
     | 
| 
       15 
15 
     | 
    
         
             
                  sort_code = sort_code.to_i
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
                   
     | 
| 
       18 
     | 
    
         
            -
                    w.sort_code_start.to_i <= sort_code 
     | 
| 
      
 17 
     | 
    
         
            +
                  min_found_weight_index = @weights.bsearch_index do |w|
         
     | 
| 
      
 18 
     | 
    
         
            +
                    w.sort_code_start.to_i <= sort_code
         
     | 
| 
       19 
19 
     | 
    
         
             
                  end
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
                  return  
     | 
| 
       22 
     | 
    
         
            -
                  return found_weights unless
         
     | 
| 
       23 
     | 
    
         
            -
                    weight.sort_code_start.to_i <= sort_code &&
         
     | 
| 
       24 
     | 
    
         
            -
                    sort_code <= weight.sort_code_end.to_i
         
     | 
| 
      
 21 
     | 
    
         
            +
                  return [] if min_found_weight_index.nil?
         
     | 
| 
       25 
22 
     | 
    
         | 
| 
       26 
     | 
    
         
            -
                  found_weights  
     | 
| 
      
 23 
     | 
    
         
            +
                  found_weights = []
         
     | 
| 
      
 24 
     | 
    
         
            +
                  index = min_found_weight_index
         
     | 
| 
      
 25 
     | 
    
         
            +
                  while index < @weights.size &&
         
     | 
| 
      
 26 
     | 
    
         
            +
                          @weights[index].sort_code_start.to_i <= sort_code &&
         
     | 
| 
      
 27 
     | 
    
         
            +
                          sort_code <= @weights[index].sort_code_end.to_i
         
     | 
| 
      
 28 
     | 
    
         
            +
                    found_weights << @weights[index]
         
     | 
| 
      
 29 
     | 
    
         
            +
                    index += 1
         
     | 
| 
      
 30 
     | 
    
         
            +
                  end
         
     | 
| 
       27 
31 
     | 
    
         | 
| 
       28 
     | 
    
         
            -
                   
     | 
| 
      
 32 
     | 
    
         
            +
                  found_weights
         
     | 
| 
       29 
33 
     | 
    
         
             
                end
         
     | 
| 
       30 
34 
     | 
    
         
             
              end
         
     | 
| 
       31 
35 
     | 
    
         
             
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: uk_account_validator
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.6
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Hayden Ball
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2017- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2017-08-05 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies: []
         
     | 
| 
       13 
13 
     | 
    
         
             
            description: Validate UK Account Numbers and Sort Codes
         
     | 
| 
       14 
14 
     | 
    
         
             
            email:
         
     | 
| 
         @@ -39,6 +39,7 @@ files: 
     | 
|
| 
       39 
39 
     | 
    
         
             
            - features/support/env.rb
         
     | 
| 
       40 
40 
     | 
    
         
             
            - features/two_modulus_check.feature
         
     | 
| 
       41 
41 
     | 
    
         
             
            - lib/uk_account_validator.rb
         
     | 
| 
      
 42 
     | 
    
         
            +
            - lib/uk_account_validator/backports/array_bsearch_index.rb
         
     | 
| 
       42 
43 
     | 
    
         
             
            - lib/uk_account_validator/exceptions/base_exception.rb
         
     | 
| 
       43 
44 
     | 
    
         
             
            - lib/uk_account_validator/exceptions/exception_1.rb
         
     | 
| 
       44 
45 
     | 
    
         
             
            - lib/uk_account_validator/exceptions/exception_10.rb
         
     | 
| 
         @@ -82,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       82 
83 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       83 
84 
     | 
    
         
             
            requirements: []
         
     | 
| 
       84 
85 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       85 
     | 
    
         
            -
            rubygems_version: 2. 
     | 
| 
      
 86 
     | 
    
         
            +
            rubygems_version: 2.6.11
         
     | 
| 
       86 
87 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       87 
88 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       88 
89 
     | 
    
         
             
            summary: Validate UK Account Numbers and Sort Codes
         
     |