ibandit 1.13.0 → 1.14.0

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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Ibandit
4
4
  module Constants
5
- CONSTRUCTABLE_IBAN_COUNTRY_CODES = %w[AT BE BG CY CZ DE DK EE ES FI FR GB GR
5
+ CONSTRUCTABLE_IBAN_COUNTRY_CODES = %w[AT BE BG CY CZ DE DK EE ES FI FO FR GB GL GR
6
6
  HR HU IE IS IT LT LU LV MC MT NL NO PL
7
7
  PT RO SE SI SK SM].freeze
8
8
 
data/lib/ibandit/iban.rb CHANGED
@@ -64,7 +64,7 @@ module Ibandit
64
64
  def account_number_suffix
65
65
  return nil unless country_code == "NZ"
66
66
 
67
- @account_number[7..-1]
67
+ @account_number[7..]
68
68
  end
69
69
 
70
70
  def local_check_digits
@@ -77,7 +77,7 @@ module Ibandit
77
77
  end
78
78
 
79
79
  def bban
80
- iban[4..-1] unless iban.nil?
80
+ iban[4..] unless iban.nil?
81
81
  end
82
82
 
83
83
  def pseudo_iban
@@ -89,7 +89,7 @@ module Ibandit
89
89
 
90
90
  def self.required_fields(country_code)
91
91
  case country_code
92
- when "AT", "CY", "CZ", "DE", "DK", "EE", "FI", "HR", "IS", "LT", "LU",
92
+ when "AT", "CY", "CZ", "DE", "DK", "EE", "FO", "FI", "GL", "HR", "IS", "LT", "LU",
93
93
  "LV", "NL", "NO", "PL", "RO", "SE", "SI", "SK"
94
94
  %i[bank_code account_number]
95
95
  when "BE"
@@ -132,7 +132,7 @@ module Ibandit
132
132
  if local_details[:branch_code]
133
133
  local_details[:branch_code]
134
134
  elsif cleaned_bank_code.length > 3
135
- cleaned_bank_code[3..-1]
135
+ cleaned_bank_code[3..]
136
136
  end
137
137
  account_number =
138
138
  if local_details[:account_number].length >= 7
@@ -247,7 +247,7 @@ module Ibandit
247
247
 
248
248
  bank_code = cleaned_account_number.slice(0, 4)
249
249
  branch_code = cleaned_account_number.slice(4, 4)
250
- account_number = cleaned_account_number[8..-1]
250
+ account_number = cleaned_account_number[8..]
251
251
  end
252
252
 
253
253
  {
@@ -265,7 +265,7 @@ module Ibandit
265
265
  if %w[4 5 6].include?(local_details[:bank_code][0])
266
266
  [
267
267
  local_details[:account_number][0],
268
- local_details[:account_number][1..-1].rjust(7, "0"),
268
+ local_details[:account_number][1..].rjust(7, "0"),
269
269
  ].join
270
270
  else
271
271
  local_details[:account_number].rjust(8, "0")
@@ -380,7 +380,7 @@ module Ibandit
380
380
  bank_code, *parts = local_details[:account_number].split("-")
381
381
  else
382
382
  bank_code = local_details[:account_number].slice(0, 4)
383
- parts = Array(local_details[:account_number][4..-1])
383
+ parts = Array(local_details[:account_number][4..])
384
384
  end
385
385
 
386
386
  {
@@ -457,7 +457,7 @@ module Ibandit
457
457
  cleaned_acct_number = local_details[:account_number].gsub(/[-.\s]/, "")
458
458
 
459
459
  bank_code = cleaned_acct_number.slice(0, 4)
460
- account_number = cleaned_acct_number[4..-1]
460
+ account_number = cleaned_acct_number[4..]
461
461
  end
462
462
 
463
463
  {
@@ -483,7 +483,7 @@ module Ibandit
483
483
  cleaned_account_number = local_details[:account_number].tr("-", "")
484
484
  bank_code = cleaned_account_number.slice(0, 2)
485
485
  branch_code = cleaned_account_number.slice(2, 4)
486
- account_number = cleaned_account_number[6..-1]
486
+ account_number = cleaned_account_number[6..]
487
487
  end
488
488
 
489
489
  if account_number && account_number.length == 9
@@ -515,7 +515,7 @@ module Ibandit
515
515
  cleaned_acct_number = local_details[:account_number].gsub(/\s/, "")
516
516
 
517
517
  bank_code = cleaned_acct_number.slice(2, 8)
518
- account_number = cleaned_acct_number[10..-1]
518
+ account_number = cleaned_acct_number[10..]
519
519
  end
520
520
 
521
521
  {
@@ -73,7 +73,7 @@ module Ibandit
73
73
 
74
74
  def serial_number
75
75
  serial_number = if @branch_code.nil?
76
- cleaned_account_number[clearing_code_length..-1]
76
+ cleaned_account_number[clearing_code_length..]
77
77
  else
78
78
  cleaned_account_number
79
79
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ibandit
4
- VERSION = "1.13.0"
4
+ VERSION = "1.14.0"
5
5
  end
@@ -210,6 +210,54 @@ describe Ibandit::IBANAssembler do
210
210
  end
211
211
  end
212
212
 
213
+ context "with FO as the country_code" do
214
+ let(:args) do
215
+ { country_code: "FO",
216
+ bank_code: "1199",
217
+ account_number: "0003179680" }
218
+ end
219
+
220
+ it { is_expected.to eq("FO9111990003179680") }
221
+
222
+ it_behaves_like "allows round trips", "FO91 1199 0003 1796 80"
223
+
224
+ context "without a bank_code" do
225
+ before { args.delete(:bank_code) }
226
+
227
+ it { is_expected.to be_nil }
228
+ end
229
+
230
+ context "without an account_number" do
231
+ before { args.delete(:account_number) }
232
+
233
+ it { is_expected.to be_nil }
234
+ end
235
+ end
236
+
237
+ context "with GL as the country_code" do
238
+ let(:args) do
239
+ { country_code: "GL",
240
+ bank_code: "1199",
241
+ account_number: "0003179680" }
242
+ end
243
+
244
+ it { is_expected.to eq("GL9111990003179680") }
245
+
246
+ it_behaves_like "allows round trips", "GL91 1199 0003 1796 80"
247
+
248
+ context "without a bank_code" do
249
+ before { args.delete(:bank_code) }
250
+
251
+ it { is_expected.to be_nil }
252
+ end
253
+
254
+ context "without an account_number" do
255
+ before { args.delete(:account_number) }
256
+
257
+ it { is_expected.to be_nil }
258
+ end
259
+ end
260
+
213
261
  context "with EE as the country_code" do
214
262
  let(:args) do
215
263
  {
@@ -3396,7 +3396,7 @@ describe Ibandit::IBAN do
3396
3396
  end
3397
3397
 
3398
3398
  context "for a valid Italian IBAN" do
3399
- let(:iban_code) { "IT40 S054 2811 1010 0000 0123 456" }
3399
+ let(:iban_code) { "IT60 X054 2811 1010 0000 0123 456" }
3400
3400
 
3401
3401
  it { is_expected.to be_valid }
3402
3402
  end
@@ -3946,6 +3946,66 @@ describe Ibandit::IBAN do
3946
3946
 
3947
3947
  it { is_expected.to_not be_valid }
3948
3948
  end
3949
+
3950
+ context "with a valid LY iban" do
3951
+ let(:iban_code) { "LY83002048000020100120361" }
3952
+
3953
+ it { is_expected.to be_valid }
3954
+ end
3955
+
3956
+ context "with an invalid LY iban" do
3957
+ let(:iban_code) { "LY830020480000120361" }
3958
+
3959
+ it { is_expected.to_not be_valid }
3960
+ end
3961
+
3962
+ context "with a valid SD iban" do
3963
+ let(:iban_code) { "SD2129010501234001" }
3964
+
3965
+ it { is_expected.to be_valid }
3966
+ end
3967
+
3968
+ context "with an invalid SD iban" do
3969
+ let(:iban_code) { "SD21290104001" }
3970
+
3971
+ it { is_expected.to_not be_valid }
3972
+ end
3973
+
3974
+ context "with a valid BI iban" do
3975
+ let(:iban_code) { "BI4210000100010000332045181" }
3976
+
3977
+ it { is_expected.to be_valid }
3978
+ end
3979
+
3980
+ context "with an invalid BI iban" do
3981
+ let(:iban_code) { "BI4210000100000332045181" }
3982
+
3983
+ it { is_expected.to_not be_valid }
3984
+ end
3985
+
3986
+ context "with a valid DJ iban" do
3987
+ let(:iban_code) { "DJ2100010000000154000100186" }
3988
+
3989
+ it { is_expected.to be_valid }
3990
+ end
3991
+
3992
+ context "with an invalid DJ iban" do
3993
+ let(:iban_code) { "DJ2100010000000000100186" }
3994
+
3995
+ it { is_expected.to_not be_valid }
3996
+ end
3997
+
3998
+ context "with a valid RU iban" do
3999
+ let(:iban_code) { "RU0204452560040702810412345678901" }
4000
+
4001
+ it { is_expected.to be_valid }
4002
+ end
4003
+
4004
+ context "with an invalid RU iban" do
4005
+ let(:iban_code) { "RU1704452522540817810538091310419" }
4006
+
4007
+ it { is_expected.to_not be_valid }
4008
+ end
3949
4009
  end
3950
4010
 
3951
4011
  describe "#local_check_digits" 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.13.0
4
+ version: 1.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GoCardless
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-07 00:00:00.000000000 Z
11
+ date: 2023-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gc_ruboconfig
@@ -174,6 +174,7 @@ files:
174
174
  - data/raw/BLZ2.txt
175
175
  - data/raw/IBANSTRUCTURE.xml
176
176
  - data/raw/IBAN_Registry.txt
177
+ - data/raw/pseudo_ibans.yml
177
178
  - data/raw/structure_additions.yml
178
179
  - data/raw/swedish_bank_lookup.yml
179
180
  - data/structures.yml