ibandit 1.6.1 → 1.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +1 -1
- data/.ruby-version +1 -1
- data/CHANGELOG.md +17 -0
- data/bin/build_structure_file.rb +3 -2
- data/data/german_iban_rules.yml +9 -3
- data/data/raw/BLZ2.txt +448 -494
- data/data/structures.yml +5 -2
- data/ibandit.gemspec +2 -2
- data/lib/ibandit/german_details_converter.rb +4 -2
- data/lib/ibandit/local_details_cleaner.rb +3 -3
- data/lib/ibandit/version.rb +1 -1
- data/lib/ibandit.rb +3 -2
- data/spec/ibandit/german_details_converter_spec.rb +2 -2
- data/spec/ibandit/iban_spec.rb +22 -22
- data/spec/ibandit/local_details_cleaner_spec.rb +2 -2
- data/spec/ibandit/structure_spec.rb +2 -2
- metadata +7 -7
data/data/structures.yml
CHANGED
@@ -983,9 +983,12 @@ EG:
|
|
983
983
|
AU:
|
984
984
|
:bank_code_length: 0
|
985
985
|
:branch_code_length: 6
|
986
|
-
:account_number_length:
|
986
|
+
:account_number_length: !ruby/range
|
987
|
+
begin: 5
|
988
|
+
end: 10
|
989
|
+
excl: false
|
987
990
|
:branch_code_format: "\\d{6}"
|
988
|
-
:account_number_format: "[A-Z0-9]{10}"
|
991
|
+
:account_number_format: "[A-Z0-9]{5,10}"
|
989
992
|
:pseudo_iban_bank_code_length: 0
|
990
993
|
:pseudo_iban_branch_code_length: 6
|
991
994
|
:pseudo_iban_account_number_length: 10
|
data/ibandit.gemspec
CHANGED
@@ -3,13 +3,13 @@
|
|
3
3
|
require File.expand_path("lib/ibandit/version", __dir__)
|
4
4
|
|
5
5
|
Gem::Specification.new do |gem|
|
6
|
-
gem.add_development_dependency "gc_ruboconfig", "~> 2.
|
6
|
+
gem.add_development_dependency "gc_ruboconfig", "~> 2.31.0"
|
7
7
|
gem.add_development_dependency "nokogiri", "~> 1.6"
|
8
8
|
gem.add_development_dependency "pry", "~> 0.13"
|
9
9
|
gem.add_development_dependency "pry-byebug", "~> 3.9"
|
10
10
|
gem.add_development_dependency "rspec", "~> 3.3"
|
11
11
|
gem.add_development_dependency "rspec-its", "~> 1.2"
|
12
|
-
gem.add_development_dependency "rspec_junit_formatter", "~> 0.
|
12
|
+
gem.add_development_dependency "rspec_junit_formatter", "~> 0.5.0"
|
13
13
|
gem.add_development_dependency "sax-machine", "~> 1.3"
|
14
14
|
|
15
15
|
gem.add_runtime_dependency "i18n"
|
@@ -270,13 +270,15 @@ module Ibandit
|
|
270
270
|
when "13"
|
271
271
|
if unpadded_account_number.size.between?(6, 7)
|
272
272
|
unpadded_account_number + "00"
|
273
|
-
else
|
273
|
+
else
|
274
|
+
@account_number
|
274
275
|
end
|
275
276
|
when "76"
|
276
277
|
case unpadded_account_number.size
|
277
278
|
when 7..8
|
278
279
|
if Check76.new(@account_number).valid? then @account_number
|
279
|
-
else
|
280
|
+
else
|
281
|
+
unpadded_account_number + "00"
|
280
282
|
end
|
281
283
|
when 5..6 then unpadded_account_number + "00"
|
282
284
|
else @account_number
|
@@ -42,7 +42,8 @@ module Ibandit
|
|
42
42
|
%i[account_number]
|
43
43
|
when "GB", "IE", "MT"
|
44
44
|
if Ibandit.bic_finder.nil? then %i[bank_code branch_code account_number]
|
45
|
-
else
|
45
|
+
else
|
46
|
+
%i[branch_code account_number]
|
46
47
|
end
|
47
48
|
when "AU"
|
48
49
|
%i[branch_code account_number]
|
@@ -68,14 +69,13 @@ module Ibandit
|
|
68
69
|
|
69
70
|
def self.clean_au_details(local_details)
|
70
71
|
# Account number may be up to 10 digits long.
|
71
|
-
# Add leading zeros to account number if < 10 digits.
|
72
72
|
#
|
73
73
|
# Minimum account_number length is 5
|
74
74
|
return {} unless local_details[:account_number].length >= 5
|
75
75
|
|
76
76
|
{
|
77
77
|
branch_code: local_details[:branch_code].delete("-"),
|
78
|
-
account_number: local_details[:account_number]
|
78
|
+
account_number: local_details[:account_number],
|
79
79
|
}
|
80
80
|
end
|
81
81
|
|
data/lib/ibandit/version.rb
CHANGED
data/lib/ibandit.rb
CHANGED
@@ -30,8 +30,9 @@ module Ibandit
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def structures
|
33
|
-
@structures ||= YAML.
|
34
|
-
File.expand_path("../data/structures.yml", __dir__),
|
33
|
+
@structures ||= YAML.safe_load(
|
34
|
+
File.read(File.expand_path("../data/structures.yml", __dir__)),
|
35
|
+
permitted_classes: [Range, Symbol],
|
35
36
|
)
|
36
37
|
end
|
37
38
|
|
@@ -19,7 +19,7 @@ describe Ibandit::GermanDetailsConverter do
|
|
19
19
|
|
20
20
|
convertor.fetch("valid", []).each do |tuple|
|
21
21
|
context "bank code: #{tuple['bank_code']} account number " \
|
22
|
-
|
22
|
+
"#{tuple['account_number']}" do
|
23
23
|
let(:bank_code) do
|
24
24
|
tuple["bank_code"]
|
25
25
|
end
|
@@ -44,7 +44,7 @@ describe Ibandit::GermanDetailsConverter do
|
|
44
44
|
|
45
45
|
convertor.fetch("invalid", []).each do |tuple|
|
46
46
|
context "bank code: #{tuple['bank_code']} account number " \
|
47
|
-
|
47
|
+
"#{tuple['account_number']}" do
|
48
48
|
let(:bank_code) { tuple["bank_code"] || "00000000" }
|
49
49
|
let(:account_number) { tuple["account_number"] }
|
50
50
|
|
data/spec/ibandit/iban_spec.rb
CHANGED
@@ -201,13 +201,13 @@ describe Ibandit::IBAN do
|
|
201
201
|
its(:country_code) { is_expected.to eq("AU") }
|
202
202
|
its(:bank_code) { is_expected.to be_nil }
|
203
203
|
its(:branch_code) { is_expected.to eq("123456") }
|
204
|
-
its(:account_number) { is_expected.to eq("
|
204
|
+
its(:account_number) { is_expected.to eq("123456789") }
|
205
205
|
its(:swift_bank_code) { is_expected.to be_nil }
|
206
206
|
its(:swift_branch_code) { is_expected.to eq("123456") }
|
207
|
-
its(:swift_account_number) { is_expected.to eq("
|
207
|
+
its(:swift_account_number) { is_expected.to eq("123456789") }
|
208
208
|
its(:swift_national_id) { is_expected.to eq("123456") }
|
209
209
|
its(:iban) { is_expected.to be_nil }
|
210
|
-
its(:pseudo_iban) { is_expected.to eq("
|
210
|
+
its(:pseudo_iban) { is_expected.to eq("AUZZ123456_123456789") }
|
211
211
|
its(:valid?) { is_expected.to eq(true) }
|
212
212
|
its(:to_s) { is_expected.to eq("") }
|
213
213
|
end
|
@@ -218,13 +218,13 @@ describe Ibandit::IBAN do
|
|
218
218
|
its(:country_code) { is_expected.to eq("AU") }
|
219
219
|
its(:bank_code) { is_expected.to be_nil }
|
220
220
|
its(:branch_code) { is_expected.to eq("123456") }
|
221
|
-
its(:account_number) { is_expected.to eq("
|
221
|
+
its(:account_number) { is_expected.to eq("12345") }
|
222
222
|
its(:swift_bank_code) { is_expected.to be_nil }
|
223
223
|
its(:swift_branch_code) { is_expected.to eq("123456") }
|
224
|
-
its(:swift_account_number) { is_expected.to eq("
|
224
|
+
its(:swift_account_number) { is_expected.to eq("12345") }
|
225
225
|
its(:swift_national_id) { is_expected.to eq("123456") }
|
226
226
|
its(:iban) { is_expected.to be_nil }
|
227
|
-
its(:pseudo_iban) { is_expected.to eq("
|
227
|
+
its(:pseudo_iban) { is_expected.to eq("AUZZ123456_____12345") }
|
228
228
|
its(:valid?) { is_expected.to eq(true) }
|
229
229
|
its(:to_s) { is_expected.to eq("") }
|
230
230
|
end
|
@@ -235,13 +235,13 @@ describe Ibandit::IBAN do
|
|
235
235
|
its(:country_code) { is_expected.to eq("AU") }
|
236
236
|
its(:bank_code) { is_expected.to be_nil }
|
237
237
|
its(:branch_code) { is_expected.to eq("123456") }
|
238
|
-
its(:account_number) { is_expected.to eq("
|
238
|
+
its(:account_number) { is_expected.to eq("123456") }
|
239
239
|
its(:swift_bank_code) { is_expected.to be_nil }
|
240
240
|
its(:swift_branch_code) { is_expected.to eq("123456") }
|
241
|
-
its(:swift_account_number) { is_expected.to eq("
|
241
|
+
its(:swift_account_number) { is_expected.to eq("123456") }
|
242
242
|
its(:swift_national_id) { is_expected.to eq("123456") }
|
243
243
|
its(:iban) { is_expected.to be_nil }
|
244
|
-
its(:pseudo_iban) { is_expected.to eq("
|
244
|
+
its(:pseudo_iban) { is_expected.to eq("AUZZ123456____123456") }
|
245
245
|
its(:valid?) { is_expected.to eq(true) }
|
246
246
|
its(:to_s) { is_expected.to eq("") }
|
247
247
|
end
|
@@ -269,13 +269,13 @@ describe Ibandit::IBAN do
|
|
269
269
|
its(:country_code) { is_expected.to eq("AU") }
|
270
270
|
its(:bank_code) { is_expected.to be_nil }
|
271
271
|
its(:branch_code) { is_expected.to eq("123456") }
|
272
|
-
its(:account_number) { is_expected.to eq("
|
272
|
+
its(:account_number) { is_expected.to eq("XX1234567") }
|
273
273
|
its(:swift_bank_code) { is_expected.to be_nil }
|
274
274
|
its(:swift_branch_code) { is_expected.to eq("123456") }
|
275
|
-
its(:swift_account_number) { is_expected.to eq("
|
275
|
+
its(:swift_account_number) { is_expected.to eq("XX1234567") }
|
276
276
|
its(:swift_national_id) { is_expected.to eq("123456") }
|
277
277
|
its(:iban) { is_expected.to be_nil }
|
278
|
-
its(:pseudo_iban) { is_expected.to eq("
|
278
|
+
its(:pseudo_iban) { is_expected.to eq("AUZZ123456_XX1234567") }
|
279
279
|
its(:valid?) { is_expected.to eq(true) }
|
280
280
|
its(:to_s) { is_expected.to eq("") }
|
281
281
|
end
|
@@ -303,13 +303,13 @@ describe Ibandit::IBAN do
|
|
303
303
|
its(:country_code) { is_expected.to eq("AU") }
|
304
304
|
its(:bank_code) { is_expected.to be_nil }
|
305
305
|
its(:branch_code) { is_expected.to eq("123456") }
|
306
|
-
its(:account_number) { is_expected.to eq("
|
306
|
+
its(:account_number) { is_expected.to eq("000000") }
|
307
307
|
its(:swift_bank_code) { is_expected.to be_nil }
|
308
308
|
its(:swift_branch_code) { is_expected.to eq("123456") }
|
309
|
-
its(:swift_account_number) { is_expected.to eq("
|
309
|
+
its(:swift_account_number) { is_expected.to eq("000000") }
|
310
310
|
its(:swift_national_id) { is_expected.to eq("123456") }
|
311
311
|
its(:iban) { is_expected.to be_nil }
|
312
|
-
its(:pseudo_iban) { is_expected.to eq("
|
312
|
+
its(:pseudo_iban) { is_expected.to eq("AUZZ123456____000000") }
|
313
313
|
its(:valid?) { is_expected.to eq(false) }
|
314
314
|
its(:to_s) { is_expected.to eq("") }
|
315
315
|
end
|
@@ -321,13 +321,13 @@ describe Ibandit::IBAN do
|
|
321
321
|
its(:country_code) { is_expected.to eq("AU") }
|
322
322
|
its(:bank_code) { is_expected.to be_nil }
|
323
323
|
its(:branch_code) { is_expected.to eq("123456") }
|
324
|
-
its(:account_number) { is_expected.to eq("
|
324
|
+
its(:account_number) { is_expected.to eq("123456789") }
|
325
325
|
its(:swift_bank_code) { is_expected.to be_nil }
|
326
326
|
its(:swift_branch_code) { is_expected.to eq("123456") }
|
327
|
-
its(:swift_account_number) { is_expected.to eq("
|
327
|
+
its(:swift_account_number) { is_expected.to eq("123456789") }
|
328
328
|
its(:swift_national_id) { is_expected.to eq("123456") }
|
329
329
|
its(:iban) { is_expected.to be_nil }
|
330
|
-
its(:pseudo_iban) { is_expected.to eq("
|
330
|
+
its(:pseudo_iban) { is_expected.to eq("AUZZ123456_123456789") }
|
331
331
|
its(:valid?) { is_expected.to eq(true) }
|
332
332
|
its(:to_s) { is_expected.to eq("") }
|
333
333
|
|
@@ -358,7 +358,7 @@ describe Ibandit::IBAN do
|
|
358
358
|
it "is invalid and has the correct errors" do
|
359
359
|
expect(subject.valid?).to eq(false)
|
360
360
|
expect(subject.errors).
|
361
|
-
to eq(account_number: "is the wrong length (should be 10 characters)")
|
361
|
+
to eq(account_number: "is the wrong length (should be 5..10 characters)")
|
362
362
|
end
|
363
363
|
end
|
364
364
|
|
@@ -377,7 +377,7 @@ describe Ibandit::IBAN do
|
|
377
377
|
it "is invalid and has the correct errors" do
|
378
378
|
expect(subject.valid?).to eq(false)
|
379
379
|
expect(subject.errors).to eq(
|
380
|
-
account_number: "is the wrong length (should be 10 characters)",
|
380
|
+
account_number: "is the wrong length (should be 5..10 characters)",
|
381
381
|
)
|
382
382
|
end
|
383
383
|
end
|
@@ -1061,7 +1061,7 @@ describe Ibandit::IBAN do
|
|
1061
1061
|
iban.valid_length?
|
1062
1062
|
expect(iban.errors).
|
1063
1063
|
to include(length: "Length doesn't match SWIFT specification " \
|
1064
|
-
|
1064
|
+
"(expected 22 characters, received 20)")
|
1065
1065
|
end
|
1066
1066
|
end
|
1067
1067
|
|
@@ -1313,7 +1313,7 @@ describe Ibandit::IBAN do
|
|
1313
1313
|
iban.valid_branch_code_length?
|
1314
1314
|
expect(iban.errors).
|
1315
1315
|
to include(branch_code: "is the wrong length (should be 6 " \
|
1316
|
-
|
1316
|
+
"characters)")
|
1317
1317
|
end
|
1318
1318
|
end
|
1319
1319
|
|
@@ -95,7 +95,7 @@ describe Ibandit::LocalDetailsCleaner do
|
|
95
95
|
let(:branch_code) { "123-456" }
|
96
96
|
|
97
97
|
its([:country_code]) { is_expected.to eq(country_code) }
|
98
|
-
its([:account_number]) { is_expected.to eq("
|
98
|
+
its([:account_number]) { is_expected.to eq("123456789") }
|
99
99
|
its([:branch_code]) { is_expected.to eq("123456") }
|
100
100
|
end
|
101
101
|
|
@@ -103,7 +103,7 @@ describe Ibandit::LocalDetailsCleaner do
|
|
103
103
|
let(:branch_code) { "123456" }
|
104
104
|
|
105
105
|
its([:country_code]) { is_expected.to eq(country_code) }
|
106
|
-
its([:account_number]) { is_expected.to eq("
|
106
|
+
its([:account_number]) { is_expected.to eq("123456789") }
|
107
107
|
its([:branch_code]) { is_expected.to eq("123456") }
|
108
108
|
end
|
109
109
|
end
|
@@ -3,8 +3,8 @@
|
|
3
3
|
require "spec_helper"
|
4
4
|
|
5
5
|
describe "structures.yml" do
|
6
|
-
structure_file = File.expand_path("../../data/structures.yml", __dir__)
|
7
|
-
structures = YAML.
|
6
|
+
structure_file = File.read(File.expand_path("../../data/structures.yml", __dir__))
|
7
|
+
structures = YAML.safe_load(structure_file, permitted_classes: [Range, Symbol])
|
8
8
|
|
9
9
|
structures.each do |country, rules|
|
10
10
|
context country do
|
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: 1.
|
4
|
+
version: 1.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GoCardless
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gc_ruboconfig
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.
|
19
|
+
version: 2.31.0
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.
|
26
|
+
version: 2.31.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: nokogiri
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.
|
103
|
+
version: 0.5.0
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.
|
110
|
+
version: 0.5.0
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: sax-machine
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -226,7 +226,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
226
226
|
- !ruby/object:Gem::Version
|
227
227
|
version: '0'
|
228
228
|
requirements: []
|
229
|
-
rubygems_version: 3.
|
229
|
+
rubygems_version: 3.3.3
|
230
230
|
signing_key:
|
231
231
|
specification_version: 4
|
232
232
|
summary: Convert national banking details into IBANs, and vice-versa.
|