ibandit 1.4.1 → 1.5.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 133f6b29166009240aa17b2677d876e26e27d53fa268462a71a9213f2ec9acf2
4
- data.tar.gz: 888ea687f4275308936a6e6ca5e9e4e45a47b53be1508a7d8f981cf796c680c7
3
+ metadata.gz: d50cfd65aab41482781d60a6c5741a00ee7a3f2901812ac3930531189c639b71
4
+ data.tar.gz: b7d78e3cb84a455c6cbbd5a7259a2f62461d7ae65a9ca34f2ae76c2728a608c6
5
5
  SHA512:
6
- metadata.gz: 2ec61aebef7327bb3c4fefe1f80aef2d51fe6682838fefa7bb6162df690f6a56d19b03db0567ec9dfd439b2a26c58aa0e4f798a31b687dbd268c1796f9450865
7
- data.tar.gz: '0168d0c3251d46e6986cb6c8cce52425e645b168cc23c1766c9028afe6f43570e080cc5b4ef5299b319eed146adc779653a9eb4b89be8a75fba303cc6c3b35be'
6
+ metadata.gz: 3b56ba928a8cb07dc584ddbb17a31e565ac27a0f744ef02ad15bccb2c7bc476144c29a63a96b7697202112bdb9dac0105eb985584dccf927296dc5ff2e1235cc
7
+ data.tar.gz: fda435511c98d3adc4914b1d39cc1c91be8ca04e94061b5df1eda0dc2007b6f84dea83e362b61ffc918b5520c7ebe60f94aeb1206e43fb6f81e5cde8b37f5cbb
data/.rubocop.yml CHANGED
@@ -5,9 +5,9 @@ inherit_gem:
5
5
  AllCops:
6
6
  TargetRubyVersion: 2.4
7
7
 
8
- # Limit lines to 80 characters.
8
+ # Limit lines to 90 characters.
9
9
  Layout/LineLength:
10
- Max: 80
10
+ Max: 90
11
11
 
12
12
  Metrics/ClassLength:
13
13
  Max: 400
data/CHANGELOG.md CHANGED
@@ -1,8 +1,11 @@
1
+ ## 1.5.0 - March 11, 2021
2
+
3
+ - Fix issue with padding on Canadian and USA pseudo IBANs #198
4
+
1
5
  ## 1.4.1 - March 3, 2021
2
6
 
3
7
  - Update BLZ data - BLZVZ FTSEX MD 652
4
8
 
5
-
6
9
  ## 1.4.0 - February 22, 2021
7
10
 
8
11
  - [Breaking] Correct `swift_national_id` for Canadian Psudo Ibans. Before `swift_national_id`
data/README.md CHANGED
@@ -575,7 +575,7 @@ iban.iban # => nil
575
575
  iban = Ibandit::IBAN.new('USZZ026073150_______2715500356')
576
576
  iban.country_code # => "US"
577
577
  iban.bank_code # => "026073150"
578
- iban.account_number # => "_______2715500356"
578
+ iban.account_number # => "2715500356"
579
579
  iban.iban # => nil
580
580
  ```
581
581
 
data/data/structures.yml CHANGED
@@ -993,7 +993,10 @@ AU:
993
993
  CA:
994
994
  :bank_code_length: 4
995
995
  :branch_code_length: 5
996
- :account_number_length: 12
996
+ :account_number_length: !ruby/range
997
+ begin: 7
998
+ end: 12
999
+ excl: false
997
1000
  :bank_code_format: "\\d{4}"
998
1001
  :branch_code_format: "\\d{5}"
999
1002
  :account_number_format: "\\d{7,12}"
@@ -1015,7 +1018,10 @@ NZ:
1015
1018
  US:
1016
1019
  :bank_code_length: 9
1017
1020
  :branch_code_length: 0
1018
- :account_number_length: 17
1021
+ :account_number_length: !ruby/range
1022
+ begin: 1
1023
+ end: 17
1024
+ excl: false
1019
1025
  :bank_code_format: "\\d{9}"
1020
1026
  :account_number_format: "_*\\d{1,17}"
1021
1027
  :national_id_length: 9
data/ibandit.gemspec CHANGED
@@ -5,8 +5,8 @@ require File.expand_path("lib/ibandit/version", __dir__)
5
5
  Gem::Specification.new do |gem|
6
6
  gem.add_development_dependency "gc_ruboconfig", "~> 2.24.0"
7
7
  gem.add_development_dependency "nokogiri", "~> 1.6"
8
- gem.add_development_dependency "pry", "~> 0.10"
9
- gem.add_development_dependency "pry-nav", "~> 0.2"
8
+ gem.add_development_dependency "pry", "~> 0.13"
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
12
  gem.add_development_dependency "rspec_junit_formatter", "~> 0.4.1"
data/lib/ibandit/iban.rb CHANGED
@@ -174,9 +174,7 @@ module Ibandit
174
174
 
175
175
  def valid_branch_code_length?
176
176
  return unless valid_country_code?
177
- if swift_branch_code.to_s.length == structure[:branch_code_length]
178
- return true
179
- end
177
+ return true if swift_branch_code.to_s.length == structure[:branch_code_length]
180
178
 
181
179
  if structure[:branch_code_length]&.zero?
182
180
  @errors[:branch_code] = Ibandit.translate(:not_used_in_country,
@@ -199,8 +197,13 @@ module Ibandit
199
197
  return false
200
198
  end
201
199
 
202
- if swift_account_number.length == structure[:account_number_length]
203
- return true
200
+ case structure[:account_number_length]
201
+ when Range
202
+ if structure[:account_number_length].include?(swift_account_number.length)
203
+ return true
204
+ end
205
+ else
206
+ return true if swift_account_number.length == structure[:account_number_length]
204
207
  end
205
208
 
206
209
  @errors[:account_number] =
@@ -91,7 +91,7 @@ module Ibandit
91
91
  def self.clean_ca_details(local_details)
92
92
  account_number = local_details[:account_number].tr("-", "")
93
93
 
94
- return {} if account_number.length < 7 # minimum length
94
+ return {} unless (7..12).cover?(account_number.length)
95
95
 
96
96
  bank_code = if local_details[:bank_code].length == 3
97
97
  local_details[:bank_code].rjust(4, "0")
@@ -100,7 +100,7 @@ module Ibandit
100
100
  end
101
101
 
102
102
  {
103
- account_number: account_number.rjust(12, "0"),
103
+ account_number: account_number,
104
104
  bank_code: bank_code,
105
105
  }
106
106
  end
@@ -113,7 +113,7 @@ module Ibandit
113
113
 
114
114
  {
115
115
  bank_code: local_details[:bank_code],
116
- account_number: account_number.rjust(17, "_"),
116
+ account_number: account_number,
117
117
  }
118
118
  end
119
119
 
@@ -330,9 +330,7 @@ module Ibandit
330
330
  def self.clean_hu_details(local_details)
331
331
  # This method supports being passed the component IBAN parts, as defined
332
332
  # by SWIFT, or a single 16 or 24 digit string.
333
- if local_details[:bank_code] || local_details[:branch_code]
334
- return local_details
335
- end
333
+ return local_details if local_details[:bank_code] || local_details[:branch_code]
336
334
 
337
335
  cleaned_acct_number = local_details[:account_number].gsub(/[-\s]/, "")
338
336
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ibandit
4
- VERSION = "1.4.1"
4
+ VERSION = "1.5.0"
5
5
  end
@@ -418,12 +418,12 @@ describe Ibandit::IBAN do
418
418
  its(:country_code) { is_expected.to eq("CA") }
419
419
  its(:bank_code) { is_expected.to eq("0036") }
420
420
  its(:branch_code) { is_expected.to eq("00063") }
421
- its(:account_number) { is_expected.to eq("000000123456") }
421
+ its(:account_number) { is_expected.to eq("0123456") }
422
422
  its(:swift_bank_code) { is_expected.to eq("0036") }
423
423
  its(:swift_branch_code) { is_expected.to eq("00063") }
424
- its(:swift_account_number) { is_expected.to eq("000000123456") }
424
+ its(:swift_account_number) { is_expected.to eq("0123456") }
425
425
  its(:swift_national_id) { is_expected.to eq("003600063") }
426
- its(:pseudo_iban) { is_expected.to eq("CAZZ003600063000000123456") }
426
+ its(:pseudo_iban) { is_expected.to eq("CAZZ003600063_____0123456") }
427
427
 
428
428
  its(:iban) { is_expected.to be_nil }
429
429
  its(:valid?) { is_expected.to eq(true) }
@@ -437,12 +437,12 @@ describe Ibandit::IBAN do
437
437
  its(:country_code) { is_expected.to eq("CA") }
438
438
  its(:bank_code) { is_expected.to eq("36") }
439
439
  its(:branch_code) { is_expected.to eq("00063") }
440
- its(:account_number) { is_expected.to eq("000000123456") }
440
+ its(:account_number) { is_expected.to eq("0123456") }
441
441
  its(:swift_bank_code) { is_expected.to eq("36") }
442
442
  its(:swift_branch_code) { is_expected.to eq("00063") }
443
- its(:swift_account_number) { is_expected.to eq("000000123456") }
443
+ its(:swift_account_number) { is_expected.to eq("0123456") }
444
444
  its(:swift_national_id) { is_expected.to eq("3600063") }
445
- its(:pseudo_iban) { is_expected.to eq("CAZZ__3600063000000123456") }
445
+ its(:pseudo_iban) { is_expected.to eq("CAZZ__3600063_____0123456") }
446
446
 
447
447
  its(:iban) { is_expected.to be_nil }
448
448
  its(:valid?) { is_expected.to eq(false) }
@@ -456,12 +456,12 @@ describe Ibandit::IBAN do
456
456
  its(:country_code) { is_expected.to eq("CA") }
457
457
  its(:bank_code) { is_expected.to eq("0036") }
458
458
  its(:branch_code) { is_expected.to eq("00063") }
459
- its(:account_number) { is_expected.to eq("000000123456") }
459
+ its(:account_number) { is_expected.to eq("0123456") }
460
460
  its(:swift_bank_code) { is_expected.to eq("0036") }
461
461
  its(:swift_branch_code) { is_expected.to eq("00063") }
462
- its(:swift_account_number) { is_expected.to eq("000000123456") }
462
+ its(:swift_account_number) { is_expected.to eq("0123456") }
463
463
  its(:swift_national_id) { is_expected.to eq("003600063") }
464
- its(:pseudo_iban) { is_expected.to eq("CAZZ003600063000000123456") }
464
+ its(:pseudo_iban) { is_expected.to eq("CAZZ003600063_____0123456") }
465
465
 
466
466
  its(:iban) { is_expected.to be_nil }
467
467
  its(:valid?) { is_expected.to eq(true) }
@@ -501,11 +501,11 @@ describe Ibandit::IBAN do
501
501
  its(:country_code) { is_expected.to eq("CA") }
502
502
  its(:bank_code) { is_expected.to eq("0036") }
503
503
  its(:branch_code) { is_expected.to eq("00063") }
504
- its(:account_number) { is_expected.to eq("000000123456") }
504
+ its(:account_number) { is_expected.to eq("0123456") }
505
505
  its(:swift_bank_code) { is_expected.to eq("0036") }
506
506
  its(:swift_branch_code) { is_expected.to eq("00063") }
507
- its(:swift_account_number) { is_expected.to eq("000000123456") }
508
- its(:pseudo_iban) { is_expected.to eq("CAZZ003600063000000123456") }
507
+ its(:swift_account_number) { is_expected.to eq("0123456") }
508
+ its(:pseudo_iban) { is_expected.to eq("CAZZ003600063_____0123456") }
509
509
 
510
510
  its(:iban) { is_expected.to be_nil }
511
511
  its(:valid?) { is_expected.to be true }
@@ -518,7 +518,7 @@ describe Ibandit::IBAN do
518
518
  it "is invalid and has the correct errors" do
519
519
  expect(subject.valid?).to eq(false)
520
520
  expect(subject.errors).
521
- to eq(account_number: "is the wrong length (should be 12 characters)")
521
+ to eq(account_number: "is the wrong length (should be 7..12 characters)")
522
522
  end
523
523
  end
524
524
 
@@ -709,10 +709,10 @@ describe Ibandit::IBAN do
709
709
 
710
710
  its(:country_code) { is_expected.to eq("US") }
711
711
  its(:bank_code) { is_expected.to eq(bank_code) }
712
- its(:account_number) { is_expected.to eq("__________0123456") }
712
+ its(:account_number) { is_expected.to eq("0123456") }
713
713
  its(:swift_bank_code) { is_expected.to eq(bank_code) }
714
714
  its(:swift_branch_code) { is_expected.to eq(nil) }
715
- its(:swift_account_number) { is_expected.to eq("__________0123456") }
715
+ its(:swift_account_number) { is_expected.to eq("0123456") }
716
716
  its(:swift_national_id) { is_expected.to eq(bank_code) }
717
717
 
718
718
  its(:pseudo_iban) do
@@ -163,7 +163,7 @@ describe Ibandit::LocalDetailsCleaner do
163
163
  let(:bank_code) { "0036" }
164
164
  let(:branch_code) { "00063" }
165
165
 
166
- its([:account_number]) { is_expected.to eq("000000123456") }
166
+ its([:account_number]) { is_expected.to eq("0123456") }
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") }
@@ -171,7 +171,7 @@ describe Ibandit::LocalDetailsCleaner do
171
171
  context "with a hyphen" do
172
172
  let(:account_number) { "0123456-789" }
173
173
 
174
- its([:account_number]) { is_expected.to eq("000123456789") }
174
+ its([:account_number]) { is_expected.to eq("0123456789") }
175
175
  end
176
176
  end
177
177
 
@@ -1311,7 +1311,7 @@ describe Ibandit::LocalDetailsCleaner do
1311
1311
  let(:account_number) { "0123456789" }
1312
1312
 
1313
1313
  its([:bank_code]) { is_expected.to eq(bank_code) }
1314
- its([:account_number]) { is_expected.to eq("_______0123456789") }
1314
+ its([:account_number]) { is_expected.to eq("0123456789") }
1315
1315
  end
1316
1316
  end
1317
1317
  end
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.1
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GoCardless
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-03 00:00:00.000000000 Z
11
+ date: 2021-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gc_ruboconfig
@@ -44,28 +44,28 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0.10'
47
+ version: '0.13'
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
- version: '0.10'
54
+ version: '0.13'
55
55
  - !ruby/object:Gem::Dependency
56
- name: pry-nav
56
+ name: pry-byebug
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0.2'
61
+ version: '3.9'
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
- version: '0.2'
68
+ version: '3.9'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement