number_plate_validator 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/lib/number_plate_validator.rb +1 -2
- data/lib/number_plate_validator/active_model.rb +2 -2
- data/lib/number_plate_validator/my_validator.rb +2 -2
- data/lib/number_plate_validator/sg_validator.rb +1 -1
- data/lib/number_plate_validator/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7817ece4c99f143b32360eefae4294cdc75da963
|
4
|
+
data.tar.gz: c037f19a7daed0d99d98ae479e2da51294f21911
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43b5c161270128cef30f8e3e41f8ad7076898815949b92e3d0c02cca88e6e38d1ed4280f1e8fb5eb7d9cbc33ecdad17d89c800b0afbd2a95dd27aee3612219fd
|
7
|
+
data.tar.gz: 8f3f9f188ec20dedfd7de89c69cdede3837320bef8992c43ef3ec7a3d64c889e2916ff946d6e2482ce42c9306ca344d860cee7cbd52d91f088bdc78a01b03f08
|
data/.travis.yml
CHANGED
@@ -12,11 +12,10 @@ module NumberPlateValidator
|
|
12
12
|
|
13
13
|
class << self
|
14
14
|
def validator(country_code)
|
15
|
-
validator_class =
|
15
|
+
validator_class = Object.const_get "NumberPlateValidator::#{country_code}Validator"
|
16
16
|
validator = validator_class.new
|
17
17
|
Validator.new(validator)
|
18
18
|
end
|
19
19
|
end
|
20
|
-
|
21
20
|
end
|
22
21
|
|
@@ -1,9 +1,9 @@
|
|
1
|
-
module ActiveModel
|
1
|
+
module ActiveModel
|
2
2
|
module Validations
|
3
3
|
class NumberPlateValidator < ActiveModel::EachValidator
|
4
4
|
def validate_each(record, attribute, value)
|
5
5
|
country = case(options[:country])
|
6
|
-
when Proc
|
6
|
+
when Proc
|
7
7
|
options[:country].call(record)
|
8
8
|
when Symbol
|
9
9
|
record.send(options[:country])
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module NumberPlateValidator
|
1
|
+
module NumberPlateValidator
|
2
2
|
class MYValidator < CountryValidatorBase
|
3
3
|
|
4
4
|
PATTERNS = [
|
@@ -22,7 +22,7 @@ module NumberPlateValidator
|
|
22
22
|
|
23
23
|
def is_valid?(registration_number)
|
24
24
|
return false unless super
|
25
|
-
PATTERNS.any? { |pattern| @license =~ pattern }
|
25
|
+
PATTERNS.any? { |pattern| @license =~ pattern }
|
26
26
|
end
|
27
27
|
|
28
28
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module NumberPlateValidator
|
1
|
+
module NumberPlateValidator
|
2
2
|
class SGValidator < CountryValidatorBase
|
3
3
|
CHECK_SUM = { 0 => "A", 1 => "Z", 2 => "Y", 3 => "X", 4 => "U", 5 => "T", 6 => "S", 7 => "R", 8 => "P", 9 => "M", 10 => "L", 11 => "K", 12 => "J", 13 => "H", 14 => "G", 15 => "E", 16 => "D", 17 => "C", 18 => "B" }
|
4
4
|
MULTIPLIER = [9, 4, 5, 4, 3, 2]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: number_plate_validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edgar
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|