security_identifiers 0.2.0 → 0.2.1
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/lib/security_identifiers/isin.rb +6 -4
- data/lib/security_identifiers/version.rb +1 -1
- data/spec/isin_spec.rb +7 -0
- 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: 3a88bacdf6ac2b2f9d3c900dd868b5a18f2cc50d
|
4
|
+
data.tar.gz: 91d6c999fa5d23c3fa9287b9e05ca9b842fa0aa7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77875202ca0c7f59eca1e1b298ad134095bf832dc31da81d204efd9ab2358b8f03be3171e43a61eb37991a6e170c468e1486c1fb623cc7729439ecdc4f25fe01
|
7
|
+
data.tar.gz: 6a5b377a556283f97ce453d41f01add3ee9f3475f9a777e17c18d072c29c208d237f011cb963b0f505f302ef531a1d5c0b6b76b5a89cb15dc26f25d62e3b87d4
|
@@ -13,12 +13,14 @@ module SecurityIdentifiers
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def check_digit
|
16
|
-
|
17
|
-
|
16
|
+
@check_digit ||= begin
|
17
|
+
first_group = digit_groups[0].map { |d| d * 2 }
|
18
|
+
second_group = digit_groups[1]
|
18
19
|
|
19
|
-
|
20
|
+
sum = (first_group + second_group).join.each_char.inject(0) { |result, i| result + i.to_i }
|
20
21
|
|
21
|
-
|
22
|
+
mod_10(sum)
|
23
|
+
end
|
22
24
|
end
|
23
25
|
|
24
26
|
private
|
data/spec/isin_spec.rb
CHANGED
@@ -27,6 +27,13 @@ describe ISIN do
|
|
27
27
|
it 'validates the check digit' do
|
28
28
|
expect(isin).to be_valid
|
29
29
|
end
|
30
|
+
|
31
|
+
it 'generates consistent check digit' do
|
32
|
+
cd1 = ISIN.new('XS1294343337').check_digit
|
33
|
+
cd2 = ISIN.new('XS1294343337').check_digit
|
34
|
+
|
35
|
+
expect(cd1).to eq(cd2)
|
36
|
+
end
|
30
37
|
end
|
31
38
|
|
32
39
|
context 'Valid alphanumeric ISIN' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: security_identifiers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kieran Johnson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -172,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
172
172
|
version: '0'
|
173
173
|
requirements: []
|
174
174
|
rubyforge_project:
|
175
|
-
rubygems_version: 2.
|
175
|
+
rubygems_version: 2.6.11
|
176
176
|
signing_key:
|
177
177
|
specification_version: 4
|
178
178
|
summary: Security Identifier validation library for Ruby
|