banktools-de 2.0.0 → 2.1.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 +4 -4
- data/banktools-de.gemspec +2 -1
- data/lib/banktools-de/iban_bic.rb +22 -19
- data/lib/banktools-de/version.rb +1 -1
- data/spec/account_spec.rb +2 -2
- data/spec/blz_spec.rb +2 -2
- data/spec/iban_bic_spec.rb +12 -20
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f345d2155801661ec0ff314f20becde6475fd980
|
4
|
+
data.tar.gz: bc5c1b608d90a7d945ef8f7ec3327b39a74f4a16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95edc5332504a760fa042731c15291d89e17c0573f8fa79b626a9996037c24faad2000aa1bfc6810acc79af4ee19d03f5ac61a5da4686e34d9ea1dc204539fa1
|
7
|
+
data.tar.gz: 5564d54c3a56a31fc52eb0b472e0a1824eebc2a1a9f5fa467f65e6a4c8d5f610a0aeabdef7b4a9d023222efbcd045623c34088bfab7f6f39b33907514dd732fa
|
data/banktools-de.gemspec
CHANGED
@@ -18,7 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
20
|
spec.add_dependency "attr_extras", ">= 4"
|
21
|
-
spec.add_dependency "
|
21
|
+
spec.add_dependency "memoit"
|
22
|
+
spec.add_dependency "ibanizator" # Convert BLZ to IBAN and lookup BIC from IBAN
|
22
23
|
spec.add_development_dependency "bundler", "~> 1.5"
|
23
24
|
spec.add_development_dependency "rake"
|
24
25
|
spec.add_development_dependency "rspec"
|
@@ -1,12 +1,12 @@
|
|
1
|
-
require "
|
1
|
+
require "memoit"
|
2
|
+
require "ibanizator"
|
2
3
|
require "attr_extras/explicit"
|
3
4
|
|
4
5
|
class BankTools::DE::IbanBicConverter
|
5
6
|
extend AttrExtras.mixin
|
6
7
|
|
7
|
-
class
|
8
|
-
class
|
9
|
-
class UnknownError < StandardError; end
|
8
|
+
class CouldNotConvertIbanError < StandardError; end
|
9
|
+
class CouldNotFindBicError < StandardError; end
|
10
10
|
|
11
11
|
class IbanBic
|
12
12
|
extend AttrExtras.mixin
|
@@ -16,27 +16,30 @@ class BankTools::DE::IbanBicConverter
|
|
16
16
|
method_object [ :blz!, :account! ]
|
17
17
|
|
18
18
|
def call
|
19
|
-
|
20
|
-
build_result(account_data)
|
19
|
+
IbanBic.new(iban, bic)
|
21
20
|
end
|
22
21
|
|
23
22
|
private
|
24
23
|
|
25
|
-
def
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
24
|
+
def iban
|
25
|
+
iban_object.iban_string
|
26
|
+
end
|
27
|
+
|
28
|
+
def bic
|
29
|
+
iban_object.extended_data.bic
|
30
|
+
rescue Ibanizator::BankDb::BankNotFoundError => e
|
31
|
+
raise CouldNotFindBicError.new(e.message)
|
31
32
|
end
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
34
|
+
memoize \
|
35
|
+
def iban_object
|
36
|
+
iban_string = Ibanizator.new.calculate_iban(country_code: :de, bank_code: blz, account_number: account)
|
37
|
+
iban = Ibanizator.iban_from_string(iban_string)
|
37
38
|
|
38
|
-
|
39
|
-
|
40
|
-
|
39
|
+
if Ibanizator.iban_from_string(iban).valid?
|
40
|
+
iban
|
41
|
+
else
|
42
|
+
raise CouldNotConvertIbanError.new("Invalid IBAN: #{iban.iban_string}")
|
43
|
+
end
|
41
44
|
end
|
42
45
|
end
|
data/lib/banktools-de/version.rb
CHANGED
data/spec/account_spec.rb
CHANGED
@@ -28,11 +28,11 @@ end
|
|
28
28
|
|
29
29
|
describe BankTools::DE::Account, "#valid?" do
|
30
30
|
it "is true with no errors" do
|
31
|
-
expect(BankTools::DE::Account.new("12").valid?).to
|
31
|
+
expect(BankTools::DE::Account.new("12").valid?).to be_truthy
|
32
32
|
end
|
33
33
|
|
34
34
|
it "is false with errors" do
|
35
|
-
expect(BankTools::DE::Account.new("1").valid?).to
|
35
|
+
expect(BankTools::DE::Account.new("1").valid?).to be_falsy
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
data/spec/blz_spec.rb
CHANGED
@@ -19,11 +19,11 @@ end
|
|
19
19
|
|
20
20
|
describe BankTools::DE::BLZ, "#valid?" do
|
21
21
|
it "is true with no errors" do
|
22
|
-
expect(BankTools::DE::BLZ.new("123 456 78").valid?).to
|
22
|
+
expect(BankTools::DE::BLZ.new("123 456 78").valid?).to be_truthy
|
23
23
|
end
|
24
24
|
|
25
25
|
it "is false with errors" do
|
26
|
-
expect(BankTools::DE::BLZ.new("1").valid?).to
|
26
|
+
expect(BankTools::DE::BLZ.new("1").valid?).to be_falsy
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
data/spec/iban_bic_spec.rb
CHANGED
@@ -2,39 +2,31 @@ require "spec_helper"
|
|
2
2
|
require "banktools-de/iban_bic"
|
3
3
|
|
4
4
|
describe BankTools::DE::IbanBicConverter, ".call" do
|
5
|
-
let(:blz) { "abc" }
|
6
|
-
let(:account) { "def" }
|
7
|
-
|
8
5
|
it "returns the BIC and IBAN" do
|
9
|
-
|
6
|
+
blz = "25050180"
|
7
|
+
account = "39370089"
|
10
8
|
|
11
9
|
actual = BankTools::DE::IbanBicConverter.call(blz: blz, account: account)
|
12
10
|
|
13
|
-
expect(actual.iban).to eq("
|
14
|
-
expect(actual.bic).to eq("
|
15
|
-
end
|
16
|
-
|
17
|
-
it "raises CouldNotConvertError on conversion errors" do
|
18
|
-
allow(Ibanomat).to receive(:find).and_return(return_code: "1")
|
19
|
-
|
20
|
-
expect {
|
21
|
-
BankTools::DE::IbanBicConverter.call(blz: blz, account: account)
|
22
|
-
}.to raise_error(BankTools::DE::IbanBicConverter::CouldNotConvertError)
|
11
|
+
expect(actual.iban).to eq("DE53250501800039370089")
|
12
|
+
expect(actual.bic).to eq("SPKHDE2HXXX")
|
23
13
|
end
|
24
14
|
|
25
|
-
it "raises
|
26
|
-
|
15
|
+
it "raises CouldNotConvertIbanError on IBAN conversion errors" do
|
16
|
+
blz = "abc"
|
17
|
+
account = "def"
|
27
18
|
|
28
19
|
expect {
|
29
20
|
BankTools::DE::IbanBicConverter.call(blz: blz, account: account)
|
30
|
-
}.to raise_error(BankTools::DE::IbanBicConverter::
|
21
|
+
}.to raise_error(BankTools::DE::IbanBicConverter::CouldNotConvertIbanError)
|
31
22
|
end
|
32
23
|
|
33
|
-
it "raises
|
34
|
-
|
24
|
+
it "raises CouldNotFindBicError on find BIC errors" do
|
25
|
+
blz = "21050171"
|
26
|
+
account = "12345678"
|
35
27
|
|
36
28
|
expect {
|
37
29
|
BankTools::DE::IbanBicConverter.call(blz: blz, account: account)
|
38
|
-
}.to raise_error(BankTools::DE::IbanBicConverter::
|
30
|
+
}.to raise_error(BankTools::DE::IbanBicConverter::CouldNotFindBicError)
|
39
31
|
end
|
40
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: banktools-de
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.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: 2015-
|
11
|
+
date: 2015-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: attr_extras
|
@@ -25,7 +25,21 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '4'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: memoit
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
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: ibanizator
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
45
|
- - ">="
|
@@ -139,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
153
|
version: '0'
|
140
154
|
requirements: []
|
141
155
|
rubyforge_project:
|
142
|
-
rubygems_version: 2.
|
156
|
+
rubygems_version: 2.4.8
|
143
157
|
signing_key:
|
144
158
|
specification_version: 4
|
145
159
|
summary: Validate and normalize German Bankleitzahl (BLZ) and bank account numbers.
|