banktools-se 3.1.1 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ae26d83c75f488a904bc1dcaffada866c129f7f923a4083ef4c2886c58c4d605
4
- data.tar.gz: 1a52ea7948ea5d90c0df16501455015ff8c870f22f00b64ca7ccf64f050aba83
3
+ metadata.gz: 2171141853a873652da69aa7ccd2c49212b060c34b8438798019178f86717a9e
4
+ data.tar.gz: 53ddab54a570de046d7149e26805670068be40b37549a21c121a62295e4dd15b
5
5
  SHA512:
6
- metadata.gz: 4ea749b95887d14fce1fa99b3f34537f497706ea1670050014cf94064830b6e23a1db8c3a71caeaab0282a559879562ea4305d9507608f1ad01f04c0ffa859fc
7
- data.tar.gz: 3aef88169d2c7be49fcfa7d88148db48db4a2ff2d9f8822cc9898ee03f9fad0cc0b4e7f9197ce0410f1021c3459172b8159d99d49269f20a0f06c98b882f8eb7
6
+ metadata.gz: 8bfd4a36644ed06f78b43b22484b8fa9a3c337c5731fb213f9c744138ad3ff5aaed4718765e6c35586feb38535111b6286c0651b9cf39e5a1d7f9e1e0712fb0f
7
+ data.tar.gz: 823a913eb6e0a644028679331af9bbff728adf86a4f81a3febd122979408a791ea46e244ebbee403ba649dc1f2157ccef6abee5709ce717551ab0ab0f90e8f30
@@ -13,12 +13,15 @@ jobs:
13
13
 
14
14
  strategy:
15
15
  matrix:
16
- ruby-version: ["3.0", "2.7", "2.6", "2.5"]
16
+ ruby-version:
17
+ - 3.1
18
+ - "3.0"
19
+ - 2.7
17
20
 
18
21
  steps:
19
- - uses: actions/checkout@v2
22
+ - uses: actions/checkout@v3
20
23
  - name: Set up Ruby ${{ matrix.ruby-version }}
21
- uses: ruby/setup-ruby@ae9cb3b565e36682a2c6045e4f664388da4c73aa
24
+ uses: ruby/setup-ruby@v1
22
25
  with:
23
26
  ruby-version: ${{ matrix.ruby-version }}
24
27
  bundler-cache: true # runs 'bundle install' and caches installed gems automatically
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.2.0
4
+
5
+ - Add Account#normalize keyword arguments `digits_only`, `clearing_checksum`. [#11](https://github.com/barsoom/banktools-se/pull/11)
6
+
7
+ ## 3.1.1
8
+
9
+ - Require MFA for privileged Rubygems actions.
10
+
3
11
  ## 3.1.0
4
12
 
5
13
  - Add more banks to the range in `BankTools::SE::Account::ClearingNumber`. See [#7]. Thanks, Milen Dimitrov!
data/Gemfile CHANGED
@@ -3,7 +3,11 @@ source "https://rubygems.org"
3
3
  # Specify your gem's dependencies in bank-tools-se.gemspec
4
4
  gemspec
5
5
 
6
- group :development do
7
- gem "barsoom_utils", github: "barsoom/barsoom_utils"
6
+ group :development, :test do
7
+ gem "barsoom_utils"
8
+ gem "guard"
9
+ gem "guard-rspec"
10
+ gem "rake"
11
+ gem "rspec"
8
12
  gem "rubocop"
9
13
  end
data/banktools-se.gemspec CHANGED
@@ -14,9 +14,4 @@ Gem::Specification.new do |s|
14
14
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
15
  s.require_paths = [ "lib" ]
16
16
  s.metadata = { "rubygems_mfa_required" => "true" }
17
-
18
- s.add_development_dependency "rake"
19
- s.add_development_dependency "rspec"
20
- s.add_development_dependency "guard"
21
- s.add_development_dependency "guard-rspec"
22
17
  end
@@ -36,9 +36,16 @@ module BankTools
36
36
  errors
37
37
  end
38
38
 
39
- def normalize
39
+ def normalize(digits_only: false, clearing_checksum: true)
40
40
  if valid?
41
- [ clearing_number, serial_number ].join("-")
41
+ clearing_number_part =
42
+ if clearing_checksum
43
+ clearing_number
44
+ else
45
+ digits[0, 4]
46
+ end
47
+ result = [ clearing_number_part, serial_number ].join("-")
48
+ digits_only ? result.gsub(/\D/, "") : result
42
49
  else
43
50
  number
44
51
  end
@@ -1,5 +1,5 @@
1
1
  module BankTools
2
2
  module SE
3
- VERSION = "3.1.1"
3
+ VERSION = "3.2.0"
4
4
  end
5
5
  end
data/spec/account_spec.rb CHANGED
@@ -1,9 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
- require "spec_helper"
4
3
  require "banktools-se"
5
4
 
6
- describe BankTools::SE::Account do
5
+ RSpec.describe BankTools::SE::Account do
7
6
  it "should initialize" do
8
7
  expect(BankTools::SE::Account.new("foo")).to be_a(BankTools::SE::Account)
9
8
  end
@@ -147,7 +146,7 @@ describe BankTools::SE::Account do
147
146
 
148
147
  describe "#normalize" do
149
148
  it "should normalize to clearing number dash serial number" do
150
- account = expect(BankTools::SE::Account.new("11000000007").normalize).to eq("1100-0000007")
149
+ expect(BankTools::SE::Account.new("11000000007").normalize).to eq("1100-0000007")
151
150
  end
152
151
 
153
152
  it "should keep any Swedbank/Sparbanker clearing checksum" do
@@ -155,12 +154,50 @@ describe BankTools::SE::Account do
155
154
  end
156
155
 
157
156
  it "should not attempt to normalize invalid numbers" do
158
- account = expect(BankTools::SE::Account.new(" 1-2-3 ").normalize).to eq(" 1-2-3 ")
157
+ expect(BankTools::SE::Account.new(" 1-2-3 ").normalize).to eq(" 1-2-3 ")
159
158
  end
160
159
 
161
160
  it "should prepend zeroes to the serial number if necessary" do
162
161
  expect(BankTools::SE::Account.new("8000-2-80000003").normalize).to eq("8000-2-0080000003")
163
162
  expect(BankTools::SE::Account.new("8000-2-8000000003").normalize).to eq("8000-2-8000000003")
164
163
  end
164
+
165
+ context "using digits_only: true" do
166
+ it "normalizes to clearing number then serial number" do
167
+ expect(BankTools::SE::Account.new("11000000007").normalize(digits_only: true)).to eq("11000000007")
168
+ end
169
+
170
+ it "keeps any Swedbank/Sparbanker clearing checksum" do
171
+ expect(BankTools::SE::Account.new("8000-2-0000000000").normalize(digits_only: true)).to eq("800020000000000")
172
+ end
173
+
174
+ it "does not attempt to normalize invalid numbers" do
175
+ expect(BankTools::SE::Account.new(" 1-2-3 ").normalize(digits_only: true)).to eq(" 1-2-3 ")
176
+ end
177
+
178
+ it "prepends zeroes to the serial number if necessary" do
179
+ expect(BankTools::SE::Account.new("8000-2-80000003").normalize(digits_only: true)).to eq("800020080000003")
180
+ expect(BankTools::SE::Account.new("8000-2-8000000003").normalize(digits_only: true)).to eq("800028000000003")
181
+ end
182
+ end
183
+
184
+ context "using clearing_checksum: false" do
185
+ it "normalizes to clearing number then serial number" do
186
+ expect(BankTools::SE::Account.new("1100 0000007").normalize(clearing_checksum: false)).to eq("1100-0000007")
187
+ end
188
+
189
+ it "drops any Swedbank/Sparbanker clearing checksum" do
190
+ expect(BankTools::SE::Account.new("8000-2-0000000000").normalize(clearing_checksum: false)).to eq("8000-0000000000")
191
+ end
192
+
193
+ it "keeps any invalid numbers" do
194
+ expect(BankTools::SE::Account.new(" 1-2-3 ").normalize(clearing_checksum: false)).to eq(" 1-2-3 ")
195
+ end
196
+
197
+ it "prepends zeroes to the serial number if necessary" do
198
+ expect(BankTools::SE::Account.new("8000-2-80000003").normalize(clearing_checksum: false)).to eq("8000-0080000003")
199
+ expect(BankTools::SE::Account.new("8000-2-8000000003").normalize(clearing_checksum: false)).to eq("8000-8000000003")
200
+ end
201
+ end
165
202
  end
166
203
  end
@@ -1,7 +1,6 @@
1
- require "spec_helper"
2
1
  require "banktools-se"
3
2
 
4
- describe BankTools::SE::Bankgiro do
3
+ RSpec.describe BankTools::SE::Bankgiro do
5
4
  it "should initialize" do
6
5
  expect(BankTools::SE::Bankgiro.new("foo")).to be_a(BankTools::SE::Bankgiro)
7
6
  end
data/spec/ocr_spec.rb CHANGED
@@ -1,7 +1,6 @@
1
- require "spec_helper"
2
1
  require "banktools-se"
3
2
 
4
- describe BankTools::SE::OCR do
3
+ RSpec.describe BankTools::SE::OCR do
5
4
  # https://www.bankgirot.se/globalassets/dokument/anvandarmanualer/bankgiroinbetalningar_anvandarmanual_sv_31okt2016.pdf section 5.2
6
5
  describe ".from_number" do
7
6
  it "adds a mod-10 check digit" do
@@ -1,7 +1,6 @@
1
- require "spec_helper"
2
1
  require "banktools-se"
3
2
 
4
- describe BankTools::SE::Plusgiro do
3
+ RSpec.describe BankTools::SE::Plusgiro do
5
4
 
6
5
  it "should initialize" do
7
6
  expect(BankTools::SE::Plusgiro.new("foo")).to be_a(BankTools::SE::Plusgiro)
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  RSpec.configure do |config|
2
2
  config.filter_run focus: true
3
3
  config.run_all_when_everything_filtered = true
4
+ config.disable_monkey_patching!
4
5
  end
data/spec/utils_spec.rb CHANGED
@@ -1,7 +1,6 @@
1
- require "spec_helper"
2
1
  require "banktools-se/utils"
3
2
 
4
- describe BankTools::SE::Utils, "valid_luhn?" do
3
+ RSpec.describe BankTools::SE::Utils, "valid_luhn?" do
5
4
 
6
5
  [
7
6
  "00",
metadata CHANGED
@@ -1,71 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: banktools-se
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henrik Nyh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-19 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: rake
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: rspec
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: guard
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: guard-rspec
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
11
+ date: 2022-06-14 00:00:00.000000000 Z
12
+ dependencies: []
69
13
  description:
70
14
  email:
71
15
  - henrik@barsoom.se
@@ -75,6 +19,7 @@ extra_rdoc_files: []
75
19
  files:
76
20
  - ".github/workflows/ci.yml"
77
21
  - ".gitignore"
22
+ - ".rspec"
78
23
  - ".rubocop.yml"
79
24
  - CHANGELOG.md
80
25
  - Gemfile
@@ -115,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
60
  - !ruby/object:Gem::Version
116
61
  version: '0'
117
62
  requirements: []
118
- rubygems_version: 3.2.28
63
+ rubygems_version: 3.3.11
119
64
  signing_key:
120
65
  specification_version: 4
121
66
  summary: Validate and normalize Swedish bank account numbers, plusgiro and bankgiro.