validates_russian 0.0.8 → 0.0.9
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/.gitignore +2 -0
- data/lib/validates_russian/version.rb +1 -1
- data/lib/validators/okpo_format_validator.rb +12 -1
- data/spec/validators/okpo_format_validator_spec.rb +4 -1
- metadata +3 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 895f186530e57b3009037436810f6f832baeb63c
         | 
| 4 | 
            +
              data.tar.gz: 3828f4bae242c267b5ccf8a0ef6e0538afd267c4
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: aae5bd3478e863d862037eca35fcb3311d76772a4db021b804f03a1fdd116d44cad5b978bae26d673d3f5dd9807219e6af612a127db9b10947e3bb8a097b0671
         | 
| 7 | 
            +
              data.tar.gz: bc282cb216daba3c485c3fdd41e476a4ff352fe8774e23c44f8c3cdc522ce725a7a9612b3744e5069fe110c7b0ce2e4682ab35812bdca2d0321e571e840cc7bd
         | 
    
        data/.gitignore
    CHANGED
    
    
| @@ -11,6 +11,17 @@ class OkpoFormatValidator < ValidatesRussian::Validator | |
| 11 11 | 
             
              private
         | 
| 12 12 |  | 
| 13 13 | 
             
              def self.calc(okpo)
         | 
| 14 | 
            -
                okpo[0..-2] | 
| 14 | 
            +
                nums = okpo[0..-2]
         | 
| 15 | 
            +
                check_digit = weight(nums, 1) % 11
         | 
| 16 | 
            +
                check_digit = weight(nums, 3) % 11 if check_digit == 10
         | 
| 17 | 
            +
                check_digit == 10 ? 0 : check_digit
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
              def self.weight(nums, shift)
         | 
| 21 | 
            +
                nums.each_with_index.inject(0) { |a, e| a + e[0] * calc_weight(e[1] + shift) }
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
              def self.calc_weight(num)
         | 
| 25 | 
            +
                num == 11 ? 1 : num
         | 
| 15 26 | 
             
              end
         | 
| 16 27 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: validates_russian
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0. | 
| 4 | 
            +
              version: 0.0.9
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Alex Antonov
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2015- | 
| 11 | 
            +
            date: 2015-10-27 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: activemodel
         | 
| @@ -133,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 133 133 | 
             
                  version: '0'
         | 
| 134 134 | 
             
            requirements: []
         | 
| 135 135 | 
             
            rubyforge_project: 
         | 
| 136 | 
            -
            rubygems_version: 2.4. | 
| 136 | 
            +
            rubygems_version: 2.4.8
         | 
| 137 137 | 
             
            signing_key: 
         | 
| 138 138 | 
             
            specification_version: 4
         | 
| 139 139 | 
             
            summary: validates specific russian values
         |