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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f365d97d443247790fa0c8b6942be2dd5b151d2e
4
- data.tar.gz: 12294a51b413f1d5f9a372d72834dd5ccb9ebecc
3
+ metadata.gz: 41544fc88196be92db16efd014ebef39d902edae
4
+ data.tar.gz: 49c61566ecd2544e39806d9ffed03b396cc26657
5
5
  SHA512:
6
- metadata.gz: dd29024ac1f67cdc9b1241510328d14dd11ee1c45ab744750ee4f1ad705becab8fc5334db48c0ab1930e81d2199e156d7216582de6c86b7fda6ed7f24446519b
7
- data.tar.gz: d19e80eaa7d3fc9f0d614210a36abaeeba40821e93af57708509992cc9198c34c93fbabc4952528d6769eac6623bb9b8c7b5cb71650af62ddc324dad8b9ca595
6
+ metadata.gz: 5db651c124eee33c8feb7d4bd6b90b11a0f994c943b17e92b724cca35ed61ee25840bfbd96d37c07e91d1bee312c5faae88bda1c22ace03bb2a897cceb3bf35e
7
+ data.tar.gz: a47561f912533e01a0befbc694a9ceeb94b8665c080e15244323c57dc8bbce207f728a964e654c698e09917fc03fb1bb2344627288e4e295217880e810e70d12
data/.travis.yml CHANGED
@@ -4,9 +4,10 @@ matrix:
4
4
  allow_failures:
5
5
 
6
6
  rvm:
7
- - 2.1
8
- - 2.2
9
- - 2.3.0
7
+ - 2.1.10
8
+ - 2.2.7
9
+ - 2.3.4
10
+ - 2.4.1
10
11
 
11
12
  sudo: false
12
13
 
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.11.6 - August 16, 2017
2
+
3
+ - Handle invalid characters when computing check digits for Italy
4
+
1
5
  ## 0.11.5 - June 16, 2017
2
6
 
3
7
  - Fix invalid regular expression `account_number_format` for Dominican Republic IBANs.
@@ -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
- odd_mapping[char]
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
@@ -1,3 +1,3 @@
1
1
  module Ibandit
2
- VERSION = '0.11.5'.freeze
2
+ VERSION = '0.11.6'.freeze
3
3
  end
@@ -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] = '000000123hhh' }
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.5
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-06-16 00:00:00.000000000 Z
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: