validator-nric 0.0.2 → 0.0.3
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/.rubocop.yml +3 -0
- data/lib/validator/nric.rb +6 -6
- data/lib/validator/nric/version.rb +1 -1
- data/spec/spec_helper.rb +0 -1
- data/spec/validator/nric_spec.rb +0 -2
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4519cfffee6a44ba64c924238e8e340a101896a5
|
4
|
+
data.tar.gz: 9d6e02d7ac78bab245af14d9c2a3b790975b7458
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e699c33aaa09b4dcdab9c5d0869cceed42faca104a0e0f0272e5f1e9a204770641d1270879df4077e3cca9e0519303d33f68cd199bd215488731481085c78e0
|
7
|
+
data.tar.gz: 3d6d44c196a58ef6fc1753e5402d5beb48cd708bebd2b9952f1621e2fc692d8309057bd7f032af22c012c0ea339bdc1e0d251c083fd0d45d03e1b372b0f97d86
|
data/.rubocop.yml
CHANGED
data/lib/validator/nric.rb
CHANGED
@@ -12,7 +12,7 @@ module Validator
|
|
12
12
|
module_function
|
13
13
|
|
14
14
|
# The multiplier for each individual digit
|
15
|
-
WEIGHT = [2, 7, 6, 5, 4, 3, 2]
|
15
|
+
WEIGHT = [2, 7, 6, 5, 4, 3, 2].freeze
|
16
16
|
|
17
17
|
# Century prefix lookup tables
|
18
18
|
#
|
@@ -23,10 +23,10 @@ module Validator
|
|
23
23
|
#
|
24
24
|
# Notice the it is backward of ABCDEFGHIZJ
|
25
25
|
# For T and G, there is a shift of 4 places
|
26
|
-
S_TABLE = %w(J Z I H G F E D C B A)
|
27
|
-
T_TABLE = %w(G F E D C B A J Z I H)
|
28
|
-
F_TABLE = %w(X W U T R Q P N M L K)
|
29
|
-
G_TABLE = %w(R Q P N M L K X W U T)
|
26
|
+
S_TABLE = %w(J Z I H G F E D C B A).freeze
|
27
|
+
T_TABLE = %w(G F E D C B A J Z I H).freeze
|
28
|
+
F_TABLE = %w(X W U T R Q P N M L K).freeze
|
29
|
+
G_TABLE = %w(R Q P N M L K X W U T).freeze
|
30
30
|
|
31
31
|
def mod(value)
|
32
32
|
ic_array = value.each_char.map(&:to_i)
|
@@ -39,7 +39,7 @@ module Validator
|
|
39
39
|
|
40
40
|
def check(nric)
|
41
41
|
return false if nric.nil? || nric.size != 9
|
42
|
-
nric.upcase
|
42
|
+
nric = nric.upcase
|
43
43
|
return false unless %w(S T F G).include?(nric[0])
|
44
44
|
|
45
45
|
century_prefix = nric[0, 1]
|
data/spec/spec_helper.rb
CHANGED
data/spec/validator/nric_spec.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
RSpec.describe Validator::Nric do
|
2
|
-
|
3
2
|
describe 'check' do
|
4
3
|
it 'returns false if nric is nil' do
|
5
4
|
expect(subject.check(nil)).to be false
|
@@ -40,5 +39,4 @@ RSpec.describe Validator::Nric do
|
|
40
39
|
expect(subject.lookup('S', 10)).to eq 'A'
|
41
40
|
end
|
42
41
|
end
|
43
|
-
|
44
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: validator-nric
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mech
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -106,11 +106,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
106
|
version: '0'
|
107
107
|
requirements: []
|
108
108
|
rubyforge_project:
|
109
|
-
rubygems_version: 2.
|
109
|
+
rubygems_version: 2.6.10
|
110
110
|
signing_key:
|
111
111
|
specification_version: 4
|
112
112
|
summary: Validates Singapore NRIC
|
113
113
|
test_files:
|
114
114
|
- spec/spec_helper.rb
|
115
115
|
- spec/validator/nric_spec.rb
|
116
|
-
has_rdoc:
|