ibandit 0.11.18 → 0.11.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +1 -0
- data/data/structures.yml +10 -0
- data/lib/ibandit/constants.rb +2 -1
- data/lib/ibandit/local_details_cleaner.rb +4 -0
- data/lib/ibandit/version.rb +1 -1
- data/spec/ibandit/iban_spec.rb +90 -0
- data/spec/ibandit/pseudo_iban_assembler_spec.rb +51 -0
- data/spec/ibandit/pseudo_iban_splitter_spec.rb +27 -0
- metadata +25 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 917798c3e0f8eefb8cafc1a8f186929df14f86b3
|
4
|
+
data.tar.gz: c93a617949e9e5e416346f06f42ddda5aeb598af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78bb3acc74a5b854d26f58fc137d5153a03ae12b566d6a12786c218175eb2f57a54e0b3a0cdd681703408b2e79a022988040494c2ce6fc9343cc562d9eb8c327
|
7
|
+
data.tar.gz: c5c18c90d395431e0d553f5ca7e6aa6d7af1eef20ee28755ada3135bed83183ed1085d1f88efd8797737a05979ceff7e44d4de7f56ce02cdd250c93c1591d22b
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -27,6 +27,7 @@ For example:
|
|
27
27
|
| Belgium | :white_check_mark: | :white_check_mark: | |
|
28
28
|
| Bulgaria | :white_check_mark: | :white_check_mark: | |
|
29
29
|
| Croatia | :white_check_mark: | :white_check_mark: | |
|
30
|
+
| Canada | | | :white_check_mark: |
|
30
31
|
| Cyprus | :white_check_mark: | :white_check_mark: | |
|
31
32
|
| Czech Republic | :white_check_mark: | :white_check_mark: | |
|
32
33
|
| Denmark | :white_check_mark: | :white_check_mark: | |
|
data/data/structures.yml
CHANGED
@@ -886,3 +886,13 @@ TL:
|
|
886
886
|
:bban_format: "\\d{3}\\d{14}\\d{2}"
|
887
887
|
:bank_code_format: "\\d{3}"
|
888
888
|
:account_number_format: " \\d{14} \\d{2}"
|
889
|
+
CA:
|
890
|
+
:bank_code_length: 4
|
891
|
+
:branch_code_length: 5
|
892
|
+
:account_number_length: 12
|
893
|
+
:bank_code_format: "\\d{4}"
|
894
|
+
:branch_code_format: "\\d{5}"
|
895
|
+
:account_number_format: "\\d{7,12}"
|
896
|
+
:pseudo_iban_bank_code_length: 4
|
897
|
+
:pseudo_iban_branch_code_length: 5
|
898
|
+
:pseudo_iban_account_number_length: 12
|
data/lib/ibandit/constants.rb
CHANGED
@@ -4,7 +4,7 @@ module Ibandit
|
|
4
4
|
HR HU IE IS IT LT LU LV MC MT NL NO PL
|
5
5
|
PT RO SE SI SK SM].freeze
|
6
6
|
|
7
|
-
PSEUDO_IBAN_COUNTRY_CODES = %w[AU SE NZ].freeze
|
7
|
+
PSEUDO_IBAN_COUNTRY_CODES = %w[AU SE NZ CA].freeze
|
8
8
|
DECONSTRUCTABLE_IBAN_COUNTRY_CODES =
|
9
9
|
CONSTRUCTABLE_IBAN_COUNTRY_CODES - PSEUDO_IBAN_COUNTRY_CODES
|
10
10
|
|
@@ -14,6 +14,7 @@ module Ibandit
|
|
14
14
|
"SE" => "X", # Using X for backwards compatibility
|
15
15
|
"AU" => "_", # Using _ because AU account numbers are alphanumeric
|
16
16
|
"NZ" => "_",
|
17
|
+
"CA" => "_",
|
17
18
|
}.freeze
|
18
19
|
|
19
20
|
SUPPORTED_COUNTRY_CODES = (
|
data/lib/ibandit/version.rb
CHANGED
data/spec/ibandit/iban_spec.rb
CHANGED
@@ -358,6 +358,96 @@ describe Ibandit::IBAN do
|
|
358
358
|
end
|
359
359
|
end
|
360
360
|
|
361
|
+
context "when the IBAN was created with local details for Canada" do
|
362
|
+
let(:arg) do
|
363
|
+
{
|
364
|
+
country_code: "CA",
|
365
|
+
bank_code: "0036",
|
366
|
+
branch_code: "00063",
|
367
|
+
account_number: account_number,
|
368
|
+
}
|
369
|
+
end
|
370
|
+
|
371
|
+
context "and a 7 digit account number" do
|
372
|
+
let(:account_number) { "0123456" }
|
373
|
+
|
374
|
+
its(:country_code) { is_expected.to eq("CA") }
|
375
|
+
its(:bank_code) { is_expected.to eq("0036") }
|
376
|
+
its(:branch_code) { is_expected.to eq("00063") }
|
377
|
+
its(:account_number) { is_expected.to eq("0123456") }
|
378
|
+
its(:swift_bank_code) { is_expected.to eq("0036") }
|
379
|
+
its(:swift_branch_code) { is_expected.to eq("00063") }
|
380
|
+
its(:swift_account_number) { is_expected.to eq("0123456") }
|
381
|
+
its(:pseudo_iban) { is_expected.to eq("CAZZ003600063_____0123456") }
|
382
|
+
|
383
|
+
# ibandit account number length validation can check for maximum
|
384
|
+
# length but not against a range, say, 7 to 12 digits, allowed in CA.
|
385
|
+
#
|
386
|
+
# given we are only going to deal with pseudo-IBANs in CA, choosing to
|
387
|
+
# not complete IBAN validation unless we need it.
|
388
|
+
#
|
389
|
+
its(:iban) { is_expected.to be_nil }
|
390
|
+
its(:valid?) { is_expected.to eq(false) }
|
391
|
+
its(:to_s) { is_expected.to eq("") }
|
392
|
+
end
|
393
|
+
|
394
|
+
context "and a 12 digit account number" do
|
395
|
+
let(:account_number) { "012345678900" }
|
396
|
+
|
397
|
+
its(:country_code) { is_expected.to eq("CA") }
|
398
|
+
its(:bank_code) { is_expected.to eq("0036") }
|
399
|
+
its(:branch_code) { is_expected.to eq("00063") }
|
400
|
+
its(:account_number) { is_expected.to eq("012345678900") }
|
401
|
+
its(:swift_bank_code) { is_expected.to eq("0036") }
|
402
|
+
its(:swift_branch_code) { is_expected.to eq("00063") }
|
403
|
+
its(:swift_account_number) { is_expected.to eq("012345678900") }
|
404
|
+
its(:pseudo_iban) { is_expected.to eq("CAZZ003600063012345678900") }
|
405
|
+
|
406
|
+
# ibandit account number length validation can check for maximum
|
407
|
+
# length but not against a range, say, 7 to 12 digits, allowed in CA.
|
408
|
+
#
|
409
|
+
# given we are only going to deal with pseudo-IBANs in CA, choosing to
|
410
|
+
# not complete IBAN validation unless we need it.
|
411
|
+
#
|
412
|
+
its(:iban) { is_expected.to be_nil }
|
413
|
+
its(:valid?) { is_expected.to eq(true) }
|
414
|
+
its(:to_s) { is_expected.to eq("") }
|
415
|
+
end
|
416
|
+
end
|
417
|
+
|
418
|
+
context "when the IBAN was created from an Canadian pseudo-IBAN" do
|
419
|
+
let(:arg) { "CAZZ0036000630123456" }
|
420
|
+
|
421
|
+
its(:country_code) { is_expected.to eq("CA") }
|
422
|
+
its(:bank_code) { is_expected.to eq("0036") }
|
423
|
+
its(:branch_code) { is_expected.to eq("00063") }
|
424
|
+
its(:account_number) { is_expected.to eq("0123456") }
|
425
|
+
its(:swift_bank_code) { is_expected.to eq("0036") }
|
426
|
+
its(:swift_branch_code) { is_expected.to eq("00063") }
|
427
|
+
its(:swift_account_number) { is_expected.to eq("0123456") }
|
428
|
+
its(:pseudo_iban) { is_expected.to eq("CAZZ003600063_____0123456") }
|
429
|
+
|
430
|
+
# ibandit account number length validation can check for maximum
|
431
|
+
# length but not against a range, say, 7 to 12 digits, allowed in CA.
|
432
|
+
#
|
433
|
+
# given we are only going to deal with pseudo-IBANs in CA, choosing to
|
434
|
+
# not complete IBAN validation unless we need it.
|
435
|
+
#
|
436
|
+
its(:iban) { is_expected.to be_nil }
|
437
|
+
its(:valid?) { is_expected.to eq(false) }
|
438
|
+
its(:to_s) { is_expected.to eq("") }
|
439
|
+
end
|
440
|
+
|
441
|
+
context "when the input is an invalid Canadan pseudo-IBAN" do
|
442
|
+
let(:arg) { "CAZZ00360006301234" }
|
443
|
+
|
444
|
+
it "is invalid and has the correct errors" do
|
445
|
+
expect(subject.valid?).to eq(false)
|
446
|
+
expect(subject.errors).
|
447
|
+
to eq(account_number: "is the wrong length (should be 12 characters)")
|
448
|
+
end
|
449
|
+
end
|
450
|
+
|
361
451
|
context "when the IBAN was created with local details for New Zealand" do
|
362
452
|
let(:arg) do
|
363
453
|
{
|
@@ -138,6 +138,57 @@ describe Ibandit::PseudoIBANAssembler do
|
|
138
138
|
end
|
139
139
|
end
|
140
140
|
|
141
|
+
context "for Canada" do
|
142
|
+
context "with valid parameters" do
|
143
|
+
let(:local_details) do
|
144
|
+
{
|
145
|
+
country_code: "CA",
|
146
|
+
bank_code: "0036",
|
147
|
+
branch_code: "00063",
|
148
|
+
account_number: "0123456",
|
149
|
+
}
|
150
|
+
end
|
151
|
+
|
152
|
+
it { is_expected.to eq("CAZZ003600063_____0123456") }
|
153
|
+
end
|
154
|
+
|
155
|
+
context "without a bank_code" do
|
156
|
+
let(:local_details) do
|
157
|
+
{
|
158
|
+
country_code: "CA",
|
159
|
+
branch_code: "00063",
|
160
|
+
account_number: "0123456",
|
161
|
+
}
|
162
|
+
end
|
163
|
+
|
164
|
+
it { is_expected.to be_nil }
|
165
|
+
end
|
166
|
+
|
167
|
+
context "without a branch code" do
|
168
|
+
let(:local_details) do
|
169
|
+
{
|
170
|
+
country_code: "CA",
|
171
|
+
bank_code: "0036",
|
172
|
+
account_number: "0123456",
|
173
|
+
}
|
174
|
+
end
|
175
|
+
|
176
|
+
it { is_expected.to be_nil }
|
177
|
+
end
|
178
|
+
|
179
|
+
context "without an account number" do
|
180
|
+
let(:local_details) do
|
181
|
+
{
|
182
|
+
country_code: "CA",
|
183
|
+
bank_code: "0036",
|
184
|
+
branch_code: "00063",
|
185
|
+
}
|
186
|
+
end
|
187
|
+
|
188
|
+
it { is_expected.to be_nil }
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
141
192
|
context "for a country that does not have pseudo-IBANs" do
|
142
193
|
let(:local_details) do
|
143
194
|
{
|
@@ -68,5 +68,32 @@ describe Ibandit::PseudoIBANSplitter do
|
|
68
68
|
its([:branch_code]) { is_expected.to eq("123456") }
|
69
69
|
its([:account_number]) { is_expected.to eq("X123456789") }
|
70
70
|
end
|
71
|
+
|
72
|
+
context "for a canadian pseudo-IBAN without padding" do
|
73
|
+
let(:pseudo_iban) { "CAZZ0036000630123456" }
|
74
|
+
|
75
|
+
its([:country_code]) { is_expected.to eq("CA") }
|
76
|
+
its([:bank_code]) { is_expected.to eq("0036") }
|
77
|
+
its([:branch_code]) { is_expected.to eq("00063") }
|
78
|
+
its([:account_number]) { is_expected.to eq("0123456") }
|
79
|
+
end
|
80
|
+
|
81
|
+
context "for a canadian pseudo-IBAN with padding" do
|
82
|
+
let(:pseudo_iban) { "CAZZ003600063_____0123456" }
|
83
|
+
|
84
|
+
its([:country_code]) { is_expected.to eq("CA") }
|
85
|
+
its([:bank_code]) { is_expected.to eq("0036") }
|
86
|
+
its([:branch_code]) { is_expected.to eq("00063") }
|
87
|
+
its([:account_number]) { is_expected.to eq("0123456") }
|
88
|
+
end
|
89
|
+
|
90
|
+
context "for a canadian pseudo-IBAN with a 12-digit account number" do
|
91
|
+
let(:pseudo_iban) { "CAZZ003600063012345678900" }
|
92
|
+
|
93
|
+
its([:country_code]) { is_expected.to eq("CA") }
|
94
|
+
its([:bank_code]) { is_expected.to eq("0036") }
|
95
|
+
its([:branch_code]) { is_expected.to eq("00063") }
|
96
|
+
its([:account_number]) { is_expected.to eq("012345678900") }
|
97
|
+
end
|
71
98
|
end
|
72
99
|
end
|
metadata
CHANGED
@@ -1,125 +1,125 @@
|
|
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.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GoCardless
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.6'
|
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
26
|
version: '1.6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: pry
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0.10'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0.10'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: pry-nav
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0.2'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0.2'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '3.3'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '3.3'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec-its
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ~>
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '1.2'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ~>
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '1.2'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rubocop
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ~>
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: 0.52.0
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ~>
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 0.52.0
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: sax-machine
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ~>
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '1.3'
|
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
110
|
version: '1.3'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: i18n
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - '>='
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - '>='
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
description: Ibandit is a Ruby library for manipulating and validating IBANs. It allows
|
@@ -131,10 +131,10 @@ executables: []
|
|
131
131
|
extensions: []
|
132
132
|
extra_rdoc_files: []
|
133
133
|
files:
|
134
|
-
-
|
135
|
-
-
|
136
|
-
-
|
137
|
-
-
|
134
|
+
- .gitignore
|
135
|
+
- .rubocop.yml
|
136
|
+
- .rubocop_todo.yml
|
137
|
+
- .travis.yml
|
138
138
|
- CHANGELOG.md
|
139
139
|
- Gemfile
|
140
140
|
- LICENSE
|
@@ -200,17 +200,17 @@ require_paths:
|
|
200
200
|
- lib
|
201
201
|
required_ruby_version: !ruby/object:Gem::Requirement
|
202
202
|
requirements:
|
203
|
-
- -
|
203
|
+
- - '>='
|
204
204
|
- !ruby/object:Gem::Version
|
205
205
|
version: '0'
|
206
206
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
207
207
|
requirements:
|
208
|
-
- -
|
208
|
+
- - '>='
|
209
209
|
- !ruby/object:Gem::Version
|
210
210
|
version: '0'
|
211
211
|
requirements: []
|
212
212
|
rubyforge_project:
|
213
|
-
rubygems_version: 2.
|
213
|
+
rubygems_version: 2.0.14.1
|
214
214
|
signing_key:
|
215
215
|
specification_version: 4
|
216
216
|
summary: Convert national banking details into IBANs, and vice-versa.
|