ibandit 1.1.0.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -0
- data/.rubocop_todo.yml +12 -11
- data/CHANGELOG.md +6 -0
- data/Rakefile +8 -0
- data/data/structures.yml +2 -2
- data/ibandit.gemspec +1 -1
- data/lib/ibandit/iban.rb +15 -6
- data/lib/ibandit/local_details_cleaner.rb +5 -3
- data/lib/ibandit/version.rb +1 -1
- data/spec/ibandit/iban_spec.rb +27 -4
- data/spec/ibandit/local_details_cleaner_spec.rb +6 -0
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce9c18eff5b207baa0033413309a91725ee47d144a89d73a4bcd2d97f04d5b11
|
4
|
+
data.tar.gz: ba2ede678314e2e635c709dd946e55fd03b540357d4cf91bb1be2ce4b2d804a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cbcd99312290c857c48287c4f401fac1774a17e53f18064199f437df1e246a78e220ac73751ea44b6201a16508aa329a796142b7c46146ac4143b2fb082150f0
|
7
|
+
data.tar.gz: '0289e1cf17c880b4b34f6f8f89cdc37f3cb5348a5f47bfab04b7aa19bd3dd0e58021d96f58cfb4bbd0117813cfff35e796ebc090fd1152ec25b65fb5a7ca4398'
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,16 +1,18 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
3
|
+
# on 2020-08-25 10:15:35 UTC using RuboCop version 0.89.1.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
|
-
# Offense count:
|
9
|
+
# Offense count: 8
|
10
|
+
# Configuration parameters: IgnoredMethods.
|
10
11
|
Metrics/AbcSize:
|
11
12
|
Max: 25
|
12
13
|
|
13
|
-
# Offense count:
|
14
|
+
# Offense count: 2
|
15
|
+
# Configuration parameters: IgnoredMethods.
|
14
16
|
Metrics/CyclomaticComplexity:
|
15
17
|
Max: 8
|
16
18
|
|
@@ -23,7 +25,7 @@ Naming/MemoizedInstanceVariableName:
|
|
23
25
|
|
24
26
|
# Offense count: 1
|
25
27
|
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
|
26
|
-
# AllowedNames:
|
28
|
+
# AllowedNames: at, by, db, id, in, io, ip, of, on, os, pp, to
|
27
29
|
Naming/MethodParameterName:
|
28
30
|
Exclude:
|
29
31
|
- 'lib/ibandit/german_details_converter.rb'
|
@@ -45,25 +47,24 @@ RSpec/ExpectInHook:
|
|
45
47
|
- 'spec/ibandit/german_details_converter_spec.rb'
|
46
48
|
|
47
49
|
# Offense count: 12
|
48
|
-
# Configuration parameters: AggregateFailuresByDefault.
|
49
50
|
RSpec/MultipleExpectations:
|
50
51
|
Max: 2
|
51
52
|
|
53
|
+
# Offense count: 182
|
54
|
+
# Configuration parameters: AllowSubject.
|
55
|
+
RSpec/MultipleMemoizedHelpers:
|
56
|
+
Max: 7
|
57
|
+
|
52
58
|
# Offense count: 20
|
53
59
|
# Configuration parameters: IgnoreSharedExamples.
|
54
60
|
RSpec/NamedSubject:
|
55
61
|
Exclude:
|
56
62
|
- 'spec/ibandit/iban_spec.rb'
|
57
63
|
|
58
|
-
# Offense count:
|
64
|
+
# Offense count: 368
|
59
65
|
RSpec/NestedGroups:
|
60
66
|
Max: 6
|
61
67
|
|
62
|
-
# Offense count: 3
|
63
|
-
RSpec/ScatteredLet:
|
64
|
-
Exclude:
|
65
|
-
- 'spec/ibandit/iban_spec.rb'
|
66
|
-
|
67
68
|
# Offense count: 18
|
68
69
|
RSpec/ScatteredSetup:
|
69
70
|
Exclude:
|
data/CHANGELOG.md
CHANGED
data/Rakefile
ADDED
data/data/structures.yml
CHANGED
@@ -95,7 +95,7 @@ BE:
|
|
95
95
|
:national_id_length: 3
|
96
96
|
:bban_format: "\\d{3}\\d{7}\\d{2}"
|
97
97
|
:bank_code_format: "\\d{3}"
|
98
|
-
:account_number_format: "\\d{7}\\d{2}"
|
98
|
+
:account_number_format: "\\d{7}\\d{2}\\d{3}"
|
99
99
|
:local_check_digit_position: 15
|
100
100
|
:local_check_digit_length: 2
|
101
101
|
BG:
|
@@ -902,7 +902,7 @@ US:
|
|
902
902
|
:branch_code_length: 0
|
903
903
|
:account_number_length: 17
|
904
904
|
:bank_code_format: "\\d{9}"
|
905
|
-
:account_number_format: "
|
905
|
+
:account_number_format: "_*\\d{1,17}"
|
906
906
|
:national_id_length: 9
|
907
907
|
:pseudo_iban_bank_code_length: 9
|
908
908
|
:pseudo_iban_branch_code_length: 0
|
data/ibandit.gemspec
CHANGED
@@ -3,7 +3,7 @@
|
|
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.17.0"
|
7
7
|
gem.add_development_dependency "nokogiri", "~> 1.6"
|
8
8
|
gem.add_development_dependency "pry", "~> 0.10"
|
9
9
|
gem.add_development_dependency "pry-nav", "~> 0.2"
|
data/lib/ibandit/iban.rb
CHANGED
@@ -9,7 +9,8 @@ module Ibandit
|
|
9
9
|
:swift_account_number, :source
|
10
10
|
|
11
11
|
def initialize(argument)
|
12
|
-
|
12
|
+
case argument
|
13
|
+
when String
|
13
14
|
input = argument.to_s.gsub(/\s+/, "").upcase
|
14
15
|
|
15
16
|
pseudo_iban_splitter = PseudoIBANSplitter.new(input)
|
@@ -24,7 +25,7 @@ module Ibandit
|
|
24
25
|
@iban = input
|
25
26
|
extract_swift_details_from_iban!
|
26
27
|
end
|
27
|
-
|
28
|
+
when Hash
|
28
29
|
@source = :local_details
|
29
30
|
build_iban_from_local_details(argument)
|
30
31
|
else
|
@@ -225,7 +226,7 @@ module Ibandit
|
|
225
226
|
return unless valid_country_code?
|
226
227
|
return unless structure[:bban_format]
|
227
228
|
|
228
|
-
if bban&.match?(
|
229
|
+
if bban&.match?(entire_string_regex(structure[:bban_format]))
|
229
230
|
true
|
230
231
|
else
|
231
232
|
@errors[:format] = Ibandit.translate(:invalid_format,
|
@@ -238,7 +239,9 @@ module Ibandit
|
|
238
239
|
return unless valid_bank_code_length?
|
239
240
|
return true if structure[:bank_code_length]&.zero?
|
240
241
|
|
241
|
-
if swift_bank_code&.match?(
|
242
|
+
if swift_bank_code&.match?(
|
243
|
+
entire_string_regex(structure[:bank_code_format]),
|
244
|
+
)
|
242
245
|
true
|
243
246
|
else
|
244
247
|
@errors[:bank_code] = Ibandit.translate(:is_invalid)
|
@@ -250,7 +253,9 @@ module Ibandit
|
|
250
253
|
return unless valid_branch_code_length?
|
251
254
|
return true unless structure[:branch_code_format]
|
252
255
|
|
253
|
-
if swift_branch_code&.match?(
|
256
|
+
if swift_branch_code&.match?(
|
257
|
+
entire_string_regex(structure[:branch_code_format]),
|
258
|
+
)
|
254
259
|
true
|
255
260
|
else
|
256
261
|
@errors[:branch_code] = Ibandit.translate(:is_invalid)
|
@@ -262,7 +267,7 @@ module Ibandit
|
|
262
267
|
return unless valid_account_number_length?
|
263
268
|
|
264
269
|
if swift_account_number&.match?(
|
265
|
-
|
270
|
+
entire_string_regex(structure[:account_number_format]),
|
266
271
|
)
|
267
272
|
true
|
268
273
|
else
|
@@ -499,6 +504,10 @@ module Ibandit
|
|
499
504
|
Ibandit.structures[country_code]
|
500
505
|
end
|
501
506
|
|
507
|
+
def entire_string_regex(pattern)
|
508
|
+
Regexp.new("\\A#{pattern}\\z")
|
509
|
+
end
|
510
|
+
|
502
511
|
def formatted
|
503
512
|
iban.to_s.gsub(/(.{4})/, '\1 ').strip
|
504
513
|
end
|
@@ -89,7 +89,9 @@ module Ibandit
|
|
89
89
|
end
|
90
90
|
|
91
91
|
def self.clean_ca_details(local_details)
|
92
|
-
|
92
|
+
account_number = local_details[:account_number].tr("-", "")
|
93
|
+
|
94
|
+
return {} if account_number.length < 7 # minimum length
|
93
95
|
|
94
96
|
bank_code = if local_details[:bank_code].length == 3
|
95
97
|
local_details[:bank_code].rjust(4, "0")
|
@@ -98,7 +100,7 @@ module Ibandit
|
|
98
100
|
end
|
99
101
|
|
100
102
|
{
|
101
|
-
account_number:
|
103
|
+
account_number: account_number.rjust(12, "0"),
|
102
104
|
bank_code: bank_code,
|
103
105
|
}
|
104
106
|
end
|
@@ -512,7 +514,7 @@ module Ibandit
|
|
512
514
|
bank_code = local_details[:bank_code]
|
513
515
|
account_number = local_details[:account_number]
|
514
516
|
else
|
515
|
-
cleaned_acct_number = local_details[:account_number].gsub(
|
517
|
+
cleaned_acct_number = local_details[:account_number].gsub(/\s/, "")
|
516
518
|
|
517
519
|
bank_code = cleaned_acct_number.slice(2, 8)
|
518
520
|
account_number = cleaned_acct_number[10..-1]
|
data/lib/ibandit/version.rb
CHANGED
data/spec/ibandit/iban_spec.rb
CHANGED
@@ -112,6 +112,22 @@ describe Ibandit::IBAN do
|
|
112
112
|
its(:local_check_digits) { is_expected.to be_nil }
|
113
113
|
end
|
114
114
|
|
115
|
+
context "when the IBAN was created from a Belgian IBAN" do
|
116
|
+
let(:iban_code) { "BE62510007547061" }
|
117
|
+
|
118
|
+
its(:country_code) { is_expected.to eq("BE") }
|
119
|
+
its(:bank_code) { is_expected.to eq("510") }
|
120
|
+
its(:branch_code) { is_expected.to be_nil }
|
121
|
+
its(:account_number) { is_expected.to eq("510007547061") }
|
122
|
+
its(:account_number_suffix) { is_expected.to be_nil }
|
123
|
+
its(:swift_bank_code) { is_expected.to eq("510") }
|
124
|
+
its(:swift_branch_code) { is_expected.to be_nil }
|
125
|
+
its(:swift_account_number) { is_expected.to eq("510007547061") }
|
126
|
+
its(:swift_national_id) { is_expected.to eq("510") }
|
127
|
+
its(:local_check_digits) { is_expected.to eq("61") }
|
128
|
+
its(:bban) { is_expected.to eq("510007547061") }
|
129
|
+
end
|
130
|
+
|
115
131
|
context "when the IBAN was created with local details" do
|
116
132
|
let(:arg) do
|
117
133
|
{
|
@@ -452,6 +468,13 @@ describe Ibandit::IBAN do
|
|
452
468
|
its(:to_s) { is_expected.to eq("") }
|
453
469
|
end
|
454
470
|
|
471
|
+
context "and account number has invalid characters in" do
|
472
|
+
let(:account_number) { "123456XX789" }
|
473
|
+
let(:bank_code) { "0036" }
|
474
|
+
|
475
|
+
its(:valid?) { is_expected.to be false }
|
476
|
+
end
|
477
|
+
|
455
478
|
context "and a 12 digit account number" do
|
456
479
|
let(:account_number) { "012345678900" }
|
457
480
|
let(:bank_code) { "0036" }
|
@@ -2247,16 +2270,16 @@ describe Ibandit::IBAN do
|
|
2247
2270
|
|
2248
2271
|
context "with an invalid branch code" do
|
2249
2272
|
let(:iban_code) { "GB60BARC20000055779911" }
|
2273
|
+
let(:valid_bank_code) { true }
|
2274
|
+
let(:valid_branch_code) { false }
|
2275
|
+
let(:valid_account_number) { true }
|
2276
|
+
|
2250
2277
|
before { Ibandit.bic_finder = double(call: "BARCGB22XXX") }
|
2251
2278
|
|
2252
2279
|
after { Ibandit.bic_finder = nil }
|
2253
2280
|
|
2254
2281
|
before { iban.valid_local_modulus_check? }
|
2255
2282
|
|
2256
|
-
let(:valid_bank_code) { true }
|
2257
|
-
let(:valid_branch_code) { false }
|
2258
|
-
let(:valid_account_number) { true }
|
2259
|
-
|
2260
2283
|
it "calls valid_branch_code? with an IBAN object" do
|
2261
2284
|
expect(Ibandit.modulus_checker).
|
2262
2285
|
to receive(:valid_branch_code?).
|
@@ -167,6 +167,12 @@ describe Ibandit::LocalDetailsCleaner do
|
|
167
167
|
its([:country_code]) { is_expected.to eq(country_code) }
|
168
168
|
its([:bank_code]) { is_expected.to eq("0036") }
|
169
169
|
its([:branch_code]) { is_expected.to eq("00063") }
|
170
|
+
|
171
|
+
context "with a hyphen" do
|
172
|
+
let(:account_number) { "0123456-789" }
|
173
|
+
|
174
|
+
its([:account_number]) { is_expected.to eq("000123456789") }
|
175
|
+
end
|
170
176
|
end
|
171
177
|
|
172
178
|
context "Cyprus" 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.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GoCardless
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-01 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.17.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.17.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: nokogiri
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -153,6 +153,7 @@ files:
|
|
153
153
|
- Gemfile
|
154
154
|
- LICENSE
|
155
155
|
- README.md
|
156
|
+
- Rakefile
|
156
157
|
- TODO.md
|
157
158
|
- bin/build_german_iban_rules.rb
|
158
159
|
- bin/build_structure_file.rb
|
@@ -223,7 +224,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
223
224
|
- !ruby/object:Gem::Version
|
224
225
|
version: '0'
|
225
226
|
requirements: []
|
226
|
-
rubygems_version: 3.0.
|
227
|
+
rubygems_version: 3.0.1
|
227
228
|
signing_key:
|
228
229
|
specification_version: 4
|
229
230
|
summary: Convert national banking details into IBANs, and vice-versa.
|