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 +4 -4
- data/.github/workflows/ci.yml +6 -3
- data/.rspec +1 -0
- data/CHANGELOG.md +8 -0
- data/Gemfile +6 -2
- data/banktools-se.gemspec +0 -5
- data/lib/banktools-se/account.rb +9 -2
- data/lib/banktools-se/version.rb +1 -1
- data/spec/account_spec.rb +41 -4
- data/spec/bankgiro_spec.rb +1 -2
- data/spec/ocr_spec.rb +1 -2
- data/spec/plusgiro_spec.rb +1 -2
- data/spec/spec_helper.rb +1 -0
- data/spec/utils_spec.rb +1 -2
- metadata +5 -60
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2171141853a873652da69aa7ccd2c49212b060c34b8438798019178f86717a9e
|
4
|
+
data.tar.gz: 53ddab54a570de046d7149e26805670068be40b37549a21c121a62295e4dd15b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bfd4a36644ed06f78b43b22484b8fa9a3c337c5731fb213f9c744138ad3ff5aaed4718765e6c35586feb38535111b6286c0651b9cf39e5a1d7f9e1e0712fb0f
|
7
|
+
data.tar.gz: 823a913eb6e0a644028679331af9bbff728adf86a4f81a3febd122979408a791ea46e244ebbee403ba649dc1f2157ccef6abee5709ce717551ab0ab0f90e8f30
|
data/.github/workflows/ci.yml
CHANGED
@@ -13,12 +13,15 @@ jobs:
|
|
13
13
|
|
14
14
|
strategy:
|
15
15
|
matrix:
|
16
|
-
ruby-version:
|
16
|
+
ruby-version:
|
17
|
+
- 3.1
|
18
|
+
- "3.0"
|
19
|
+
- 2.7
|
17
20
|
|
18
21
|
steps:
|
19
|
-
- uses: actions/checkout@
|
22
|
+
- uses: actions/checkout@v3
|
20
23
|
- name: Set up Ruby ${{ matrix.ruby-version }}
|
21
|
-
uses: ruby/setup-ruby@
|
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"
|
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
|
data/lib/banktools-se/account.rb
CHANGED
@@ -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
|
-
|
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
|
data/lib/banktools-se/version.rb
CHANGED
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
|
-
|
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
|
-
|
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
|
data/spec/bankgiro_spec.rb
CHANGED
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
|
data/spec/plusgiro_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
data/spec/utils_spec.rb
CHANGED
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.
|
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:
|
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.
|
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.
|