security_identifiers 0.2.0 → 0.2.1

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: 8d4a1a164bc410f563cc724a23854d04ecfa5f56
4
- data.tar.gz: 6ae673ffb5413e871201358c2b2c2da695b81a75
3
+ metadata.gz: 3a88bacdf6ac2b2f9d3c900dd868b5a18f2cc50d
4
+ data.tar.gz: 91d6c999fa5d23c3fa9287b9e05ca9b842fa0aa7
5
5
  SHA512:
6
- metadata.gz: 16cd1df966a268205dc28469b74b873196466576f7e4f689072f4f2301ea77831a4cdf93f6f41a40bb28c578e7483c8bda290e4fbeea5eaf6d072d5ae07df0cd
7
- data.tar.gz: 4faeb36286a5d64b6b2f57b1bf9e7afb57c6664cc3a53932d013bee1f12d1143967e325b49a2dc09f2c393eda37568a8cc0a1e97a5e5bbfd78664b1d5e27a73f
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
- first_group, second_group = digit_groups
17
- first_group.map! { |d| d * 2 }
16
+ @check_digit ||= begin
17
+ first_group = digit_groups[0].map { |d| d * 2 }
18
+ second_group = digit_groups[1]
18
19
 
19
- sum = (first_group + second_group).join.each_char.inject(0) { |result, i| result + i.to_i }
20
+ sum = (first_group + second_group).join.each_char.inject(0) { |result, i| result + i.to_i }
20
21
 
21
- mod_10(sum)
22
+ mod_10(sum)
23
+ end
22
24
  end
23
25
 
24
26
  private
@@ -1,3 +1,3 @@
1
1
  module SecurityIdentifiers
2
- VERSION = '0.2.0'.freeze
2
+ VERSION = '0.2.1'.freeze
3
3
  end
@@ -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.0
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-03-08 00:00:00.000000000 Z
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.4.5.1
175
+ rubygems_version: 2.6.11
176
176
  signing_key:
177
177
  specification_version: 4
178
178
  summary: Security Identifier validation library for Ruby