ibandit 0.11.5 → 0.11.6
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/.travis.yml +4 -3
- data/CHANGELOG.md +4 -0
- data/lib/ibandit/check_digit.rb +15 -10
- data/lib/ibandit/version.rb +1 -1
- data/spec/ibandit/iban_assembler_spec.rb +7 -2
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41544fc88196be92db16efd014ebef39d902edae
|
4
|
+
data.tar.gz: 49c61566ecd2544e39806d9ffed03b396cc26657
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5db651c124eee33c8feb7d4bd6b90b11a0f994c943b17e92b724cca35ed61ee25840bfbd96d37c07e91d1bee312c5faae88bda1c22ace03bb2a897cceb3bf35e
|
7
|
+
data.tar.gz: a47561f912533e01a0befbc694a9ceeb94b8665c080e15244323c57dc8bbce207f728a964e654c698e09917fc03fb1bb2344627288e4e295217880e810e70d12
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/lib/ibandit/check_digit.rb
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
module Ibandit
|
2
2
|
module CheckDigit
|
3
|
+
ITALIAN_ODD_MAPPING = {
|
4
|
+
'A' => 1, 'B' => 0, 'C' => 5, 'D' => 7, 'E' => 9, 'F' => 13,
|
5
|
+
'G' => 15, 'H' => 17, 'I' => 19, 'J' => 21, 'K' => 2, 'L' => 4,
|
6
|
+
'M' => 18, 'N' => 20, 'O' => 11, 'P' => 3, 'Q' => 6, 'R' => 8,
|
7
|
+
'S' => 12, 'T' => 14, 'U' => 16, 'V' => 10, 'W' => 22, 'X' => 25,
|
8
|
+
'Y' => 24, 'Z' => 23, '0' => 1, '1' => 0, '2' => 5, '3' => 7,
|
9
|
+
'4' => 9, '5' => 13, '6' => 15, '7' => 17, '8' => 19, '9' => 21
|
10
|
+
}.freeze
|
11
|
+
|
3
12
|
def self.iban(country_code, bban)
|
4
13
|
chars = bban + country_code + '00'
|
5
14
|
digits = chars.bytes.map do |byte|
|
@@ -16,18 +25,14 @@ module Ibandit
|
|
16
25
|
end
|
17
26
|
|
18
27
|
def self.italian(string)
|
19
|
-
odd_mapping = {
|
20
|
-
'A' => 1, 'B' => 0, 'C' => 5, 'D' => 7, 'E' => 9, 'F' => 13,
|
21
|
-
'G' => 15, 'H' => 17, 'I' => 19, 'J' => 21, 'K' => 2, 'L' => 4,
|
22
|
-
'M' => 18, 'N' => 20, 'O' => 11, 'P' => 3, 'Q' => 6, 'R' => 8,
|
23
|
-
'S' => 12, 'T' => 14, 'U' => 16, 'V' => 10, 'W' => 22, 'X' => 25,
|
24
|
-
'Y' => 24, 'Z' => 23, '0' => 1, '1' => 0, '2' => 5, '3' => 7,
|
25
|
-
'4' => 9, '5' => 13, '6' => 15, '7' => 17, '8' => 19, '9' => 21
|
26
|
-
}
|
27
|
-
|
28
28
|
scaled_values = string.chars.map.with_index do |char, index|
|
29
29
|
if index.even?
|
30
|
-
|
30
|
+
if ITALIAN_ODD_MAPPING.include?(char)
|
31
|
+
ITALIAN_ODD_MAPPING[char]
|
32
|
+
else
|
33
|
+
raise InvalidCharacterError,
|
34
|
+
"Unexpected character '#{char}'"
|
35
|
+
end
|
31
36
|
else
|
32
37
|
case char.ord
|
33
38
|
when 48..57 then char.to_i # 0..9
|
data/lib/ibandit/version.rb
CHANGED
@@ -498,8 +498,13 @@ describe Ibandit::IBANAssembler do
|
|
498
498
|
it { is_expected.to eq('IT64Y0542811101000000123456') }
|
499
499
|
end
|
500
500
|
|
501
|
-
context 'with a bad character' do
|
502
|
-
before { args[:account_number] = '
|
501
|
+
context 'with a bad character in an odd position' do
|
502
|
+
before { args[:account_number] = '000000123h00' }
|
503
|
+
it { is_expected.to be_nil }
|
504
|
+
end
|
505
|
+
|
506
|
+
context 'with a bad character in an even position' do
|
507
|
+
before { args[:account_number] = '0000001230h0' }
|
503
508
|
it { is_expected.to be_nil }
|
504
509
|
end
|
505
510
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ibandit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Grey Baker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -182,4 +182,3 @@ signing_key:
|
|
182
182
|
specification_version: 4
|
183
183
|
summary: Convert national banking details into IBANs, and vice-versa.
|
184
184
|
test_files: []
|
185
|
-
has_rdoc:
|