license_plate_validator 1.1.1 → 1.2.0

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: e5826727591b17c4bb025685484a4c77d14a67f3
4
- data.tar.gz: a41695ad821764c0b49d2407c5d748088be2e2e7
3
+ metadata.gz: e5410ab6ff6ba06432f84418f8f468a25abf081c
4
+ data.tar.gz: 569f7247789876b239bafeda9978f563ab89e7fd
5
5
  SHA512:
6
- metadata.gz: da9f5aa4b9fc7a3497e9ab32b8bf09435559600de325943b529e65a8f19b7d712d5314b99b386e21298821f5fb5700fbec631cd1cac479a020a1f7c86fa78a35
7
- data.tar.gz: 87b1edd259336840b6b5d4641fc53ebfdd05d697a92da81f62ab1bfd5b3e846dc4c0615f02dfe094f79035be782a984c337b1c90d325fa0e4d75ae5d66ce8d24
6
+ metadata.gz: 5ebc4e2aa79baa457bcd8561cc32b5ec40ce1d2c7290a40780d6c1cadc2434552a6db08a5cc1bae18d32dd3f6d19c8e3bea3cb58aca0749af6c15d4d1d553d6c
7
+ data.tar.gz: 6794cbfee6d307b02357ea69b36aeffbde7f352e7028410d7713cd3e4e770088e69d9b99870154d407228735a5dd39cb5a34d609ad0103f9550a0b508d46aa7b
@@ -1,7 +1,19 @@
1
1
  language: ruby
2
+
3
+ notifications:
4
+ email: false
5
+
2
6
  rvm:
3
7
  - 2.0.0
4
- - 1.9.3
8
+ - 2.1.1
9
+ - jruby-19mode
10
+ - ruby-head
11
+
12
+ matrix:
13
+ allow_failures:
14
+ - rvm: jruby-19mode
15
+ - rvm: ruby-head
16
+
5
17
  gemfile:
6
18
  - gemfiles/activemodel-4
7
19
  - gemfiles/activemodel-3-2
@@ -0,0 +1,12 @@
1
+ 1.2.0 - 2014-07-28
2
+
3
+ * German license plate support
4
+ * German language support
5
+
6
+ 1.1.1 - 2014-04-25
7
+
8
+ * Fix i18n key
9
+
10
+ 1.0 - 2013-04-23
11
+
12
+ * Initial release with Dutch license plate support
data/README.md CHANGED
@@ -11,11 +11,13 @@ only validate Dutch license plates.
11
11
 
12
12
  ## Features
13
13
 
14
- Validate Dutch license plates ("kentekens"), includes all ten common Dutch license
14
+ Validates Dutch license plates ("kentekens"), includes all ten common Dutch license
15
15
  plate types.
16
16
 
17
17
  Special license plates (like those for the Royal family) are not supported.
18
18
 
19
+ Also supports most german license plates, including most diplomatic formats.
20
+
19
21
  ## Installation
20
22
 
21
23
  Add this line to your application's Gemfile:
@@ -66,10 +68,11 @@ The `Proc` must return either `nil` (accept all the things) or a valid country c
66
68
  ### Supported countries
67
69
 
68
70
  * `:nl` Netherlands; all common "sidecode" number formats.
71
+ * `:de` Germany; all regular forms as well as the common diplomatic variants
69
72
 
70
73
  ## I18n
71
74
 
72
- Locales for English and Dutch are provided. See [`lib/license_plate_validator/locales`](https://github.com/ariejan/license_plate_validator/tree/master/lib/license_plate_validator/locales)
75
+ Locales for English, Dutch and German are provided. See [`lib/license_plate_validator/locales`](https://github.com/ariejan/license_plate_validator/tree/master/lib/license_plate_validator/locales)
73
76
  for details.
74
77
 
75
78
  ## Contributing
@@ -99,6 +102,7 @@ specs.
99
102
  ## Contributor
100
103
 
101
104
  * Pascal Widdershoven - for the original regexes for Dutch license plate numbers.
105
+ * Marcus Ilgner, evopark - for german license plates
102
106
 
103
107
  ## License
104
108
 
@@ -13,6 +13,19 @@ class LicensePlateValidator
13
13
  /^([0-9]{1})-?([a-zA-Z]{3})-?([0-9]{2})$/,
14
14
  /^([a-zA-Z]{2})-?([0-9]{3})-?([a-zA-Z]{1})$/,
15
15
  /^([a-zA-Z]{1})-?([0-9]{3})-?([a-zA-Z]{2})$/
16
+ ],
17
+ # Germany
18
+ de: [
19
+ # first part: distinguisher for area
20
+ # second part (a) 1-2 characters followed by 1-4 numbers
21
+ # or (b) for diplomatic purposes:
22
+ # 1. a 4-digit number starting with 9
23
+ # 2. a 2-3-digit-number (country identifier) followed by 1-3 digits
24
+ # diplomatic license plates can be followed by a single letter
25
+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[a-z]{1,2}[\- ]\d{1,4}H?)|(9\d{3})|(\d{2,3}\-\d{1,3})[a-z]?)$/i,
27
+ # more diplomatic license plates ;)
28
+ /^0[\- ]\d{1,3}[\- ]\d{1,3}\w?$/i
16
29
  ]
17
30
  }.freeze
18
31
 
@@ -21,7 +34,7 @@ class LicensePlateValidator
21
34
  country: nil
22
35
  }.merge(options)
23
36
 
24
- @raw = normalize(raw || "")
37
+ @raw = raw || ''
25
38
  end
26
39
 
27
40
  attr_reader :raw
@@ -47,12 +60,6 @@ class LicensePlateValidator
47
60
  def to_s
48
61
  raw
49
62
  end
50
-
51
- private
52
-
53
- def normalize(input)
54
- input.to_s.upcase.strip.gsub(/[^A-Z0-9]/, '')
55
- end
56
63
  end
57
64
 
58
65
  require 'license_plate_validator/version'
@@ -0,0 +1,4 @@
1
+ de:
2
+ errors:
3
+ messages:
4
+ invalid_license_plate: ist kein gültiges Kennzeichen
@@ -1,4 +1,4 @@
1
- en:
1
+ nl:
2
2
  errors:
3
3
  messages:
4
4
  invalid_license_plate: is geen geldig kenteken
@@ -1,3 +1,3 @@
1
1
  class LicensePlateValidator
2
- VERSION = "1.1.1"
2
+ VERSION = "1.2.0"
3
3
  end
@@ -12,18 +12,13 @@ describe LicensePlateValidator do
12
12
  expect { LicensePlateValidator.new("a", country: :nl) }.not_to raise_error
13
13
  expect { LicensePlateValidator.new("a", country: nil) }.not_to raise_error
14
14
  end
15
-
16
- it 'normalizes the input string' do
17
- expect(LicensePlateValidator.new('60-NFH-1').to_s).to eql('60NFH1')
18
- expect(LicensePlateValidator.new('fz-xx-61').to_s).to eql('FZXX61')
19
- end
20
15
  end
21
16
 
22
17
  context "#supported countries" do
23
18
  subject { LicensePlateValidator.new("a") }
24
19
 
25
20
  it "returns array of symbols" do
26
- expect(subject.supported_countries).to eql([:nl])
21
+ expect(subject.supported_countries).to eql([:nl, :de])
27
22
  end
28
23
  end
29
24
 
@@ -91,7 +86,7 @@ describe LicensePlateValidator do
91
86
  "DEF-123",
92
87
  "123-DEF",
93
88
  "DEFGHI",
94
- "123456"
89
+ "123456",
95
90
  ]
96
91
 
97
92
  NL_VALID_SAMPLES.each do |number|
@@ -108,4 +103,34 @@ describe LicensePlateValidator do
108
103
  end
109
104
  end
110
105
  end
106
+
107
+ context "DE - Germany" do
108
+ DE_VALID_SAMPLES = [
109
+ "K-AB-123",
110
+ "GL-A-123H",
111
+ "K-9123",
112
+ "0-12-123",
113
+ "0-12-234H"
114
+ ]
115
+
116
+ DE_INVALID_SAMPLES = [
117
+ "FOO-AB-123",
118
+ "123",
119
+ "K-2"
120
+ ]
121
+
122
+ DE_VALID_SAMPLES.each do |sample|
123
+ it "accepts '#{sample}'" do
124
+ license = LicensePlateValidator.new(sample, country: :de)
125
+ expect(license).to be_valid
126
+ end
127
+ end
128
+
129
+ DE_INVALID_SAMPLES.each do |sample|
130
+ it "rejects '#{sample}'" do
131
+ license = LicensePlateValidator.new(sample, country: :de)
132
+ expect(license).to_not be_valid
133
+ end
134
+ end
135
+ end
111
136
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: license_plate_validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ariejan de Vroom
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-25 00:00:00.000000000 Z
11
+ date: 2014-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -77,6 +77,7 @@ files:
77
77
  - ".gitignore"
78
78
  - ".rspec"
79
79
  - ".travis.yml"
80
+ - CHANGELOG
80
81
  - Gemfile
81
82
  - LICENSE.txt
82
83
  - README.md
@@ -88,6 +89,7 @@ files:
88
89
  - gemfiles/standalone
89
90
  - lib/license_plate_validator.rb
90
91
  - lib/license_plate_validator/active_model.rb
92
+ - lib/license_plate_validator/locales/de.yml
91
93
  - lib/license_plate_validator/locales/en.yml
92
94
  - lib/license_plate_validator/locales/nl.yml
93
95
  - lib/license_plate_validator/version.rb
@@ -115,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
117
  version: '0'
116
118
  requirements: []
117
119
  rubyforge_project:
118
- rubygems_version: 2.2.1
120
+ rubygems_version: 2.2.2
119
121
  signing_key:
120
122
  specification_version: 4
121
123
  summary: Validate license plate numbers for countries that support it.