banktools-de 0.0.5 → 0.0.6

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
  SHA1:
3
- metadata.gz: 980f50e63ec1df638d17eb3a714882f5bc8b726b
4
- data.tar.gz: 50d8371a2e358e81803b62a69e8e4489c06b22e8
3
+ metadata.gz: 52950f7fe73d77a9ff04ebac2e51f0c796cc440d
4
+ data.tar.gz: 8a3cbb75535461c2b59d9ae73099d96c462ff23d
5
5
  SHA512:
6
- metadata.gz: 9e24fbda49c753f995a5f1e31223e1661d7cd1818d53fdb1ce40b74cb4fef7b43cff13a9f2055dafb94e8853b4fdaabe0a73b2bc8f8d59c3970b2e4531ad3a4c
7
- data.tar.gz: bdd45c2c83ca819a129fc4ea7817e14454196fa4b66da52e0dd0de4f2319aeb49283edbb0ddc1eacddd671628b0d78d732e41d43f5cf853631e3c8ba045c8cc6
6
+ metadata.gz: 873d235ac161487915dff8416ef6838323990bc9a2b510f3a295454dda7f8a5d8e0aac7a7558c8e7400ac50cc4ea15fb28c321c056e0de27dd955ffc1bd7ff1a
7
+ data.tar.gz: cd4f307835992c85d3e3b9e064ee754e656fda1bf6d5efc4f381408643b074b4540ba5a81c60519c55e212549ee9fd9901f5495d4765690dba5450cb0f7f854f
data/README.md CHANGED
@@ -16,11 +16,12 @@ If we got anything wrong, please file an issue or contribute a fix yourself.
16
16
  blz.valid? # => true
17
17
  blz.errors # => []
18
18
  blz.bank_name # => "Deutsche Bank PGK Berlin"
19
+ BankTools::DE::BLZ.blz_to_bank_name # => { "10070024" => "Deutsche Bank PGK Berlin", … }
19
20
 
20
21
  bad_blz = BankTools::DE::BLZ.new("1X")
21
22
  bad_blz.normalize # => "1X"
22
23
  bad_blz.valid? # => false
23
- bad_blz.errors # => [ :too_short, :invalid_characters ]
24
+ bad_blz.errors # => [:too_short, :invalid_characters]
24
25
  blz.bank_name # => nil
25
26
 
26
27
  # Account
@@ -33,14 +34,13 @@ If we got anything wrong, please file an issue or contribute a fix yourself.
33
34
  bad_account = BankTools::DE::Account.new("1")
34
35
  bad_account.normalize # => "1"
35
36
  bad_account.valid? # => false
36
- bad_account.errors # => [ :too_short ]
37
+ bad_account.errors # => [:too_short]
37
38
 
38
39
 
39
40
  ## Tests
40
41
 
41
42
  bundle
42
- rspec
43
- # or: rake
43
+ rspec # or: rake
44
44
 
45
45
 
46
46
  ## Update BLZ data
@@ -58,7 +58,7 @@ providing a URL for the latest unpacked XLSX version of the data.
58
58
 
59
59
  You can provide a local path if you want.
60
60
 
61
- This will overwrite the local data file, which should ship with the gem.
61
+ This will overwrite the data file in the code repository.
62
62
 
63
63
  Updates appear to ship for periods of 3 months, provided the month before a period starts. We've seen these periods:
64
64
  * 2013-09-09 - 2013-12-08
@@ -80,10 +80,16 @@ Or install it yourself as:
80
80
  $ gem install banktools-de
81
81
 
82
82
 
83
+ ## TODO
84
+
85
+ * [Checksum validation](http://www.bundesbank.de/Navigation/DE/Kerngeschaeftsfelder/Unbarer_Zahlungsverkehr/Pruefzifferberechnung/pruefzifferberechnung.html)
86
+
87
+
83
88
  ## Also see
84
89
 
85
90
  * [BankTools::SE (Swedish)](https://github.com/barsoom/banktools-se)
86
91
  * [iban-tools](https://github.com/iulianu/iban-tools)
92
+ * [Konto API online service](https://www.kontoapi.de)
87
93
 
88
94
 
89
95
  ## Credits and license
@@ -10,11 +10,15 @@ require "yaml"
10
10
  module BankTools
11
11
  module DE
12
12
  class BLZ
13
- MIN_LENGTH = MAX_LENGTH = 8
14
- BLZ_TO_NAME_PATH = File.join(BankTools::DE.data_dir, "blz_to_name.yml")
13
+ LENGTH = 8
14
+ BLZ_TO_BANK_NAME_PATH = File.join(BankTools::DE.data_dir, "blz_to_name.yml")
15
15
 
16
16
  pattr_initialize :original_value
17
17
 
18
+ def self.blz_to_bank_name
19
+ @blz_to_bank_name ||= YAML.load_file(BLZ_TO_BANK_NAME_PATH).fetch(:data)
20
+ end
21
+
18
22
  def normalize
19
23
  if compacted_value.match(/\A(\d{3})(\d{3})(\d{2})\z/)
20
24
  "#$1 #$2 #$3"
@@ -29,20 +33,20 @@ module BankTools
29
33
 
30
34
  def errors
31
35
  errors = []
32
- errors << Errors::TOO_SHORT if compacted_value.length < MIN_LENGTH
33
- errors << Errors::TOO_LONG if compacted_value.length > MAX_LENGTH
36
+ errors << Errors::TOO_SHORT if compacted_value.length < LENGTH
37
+ errors << Errors::TOO_LONG if compacted_value.length > LENGTH
34
38
  errors << Errors::INVALID_CHARACTERS if compacted_value.match(/\D/)
35
39
  errors
36
40
  end
37
41
 
38
42
  def bank_name
39
- blz_to_name.fetch(compacted_value, nil)
43
+ blz_to_bank_name.fetch(compacted_value, nil)
40
44
  end
41
45
 
42
46
  private
43
47
 
44
- def blz_to_name
45
- @blz_to_name ||= YAML.load_file(BLZ_TO_NAME_PATH).fetch(:data)
48
+ def blz_to_bank_name
49
+ self.class.blz_to_bank_name
46
50
  end
47
51
 
48
52
  def compacted_value
@@ -1,5 +1,5 @@
1
1
  module BankTools
2
2
  module DE
3
- VERSION = "0.0.5"
3
+ VERSION = "0.0.6"
4
4
  end
5
5
  end
data/spec/blz_spec.rb CHANGED
@@ -56,3 +56,11 @@ describe BankTools::DE::BLZ, "#bank_name" do
56
56
  expect(BankTools::DE::BLZ.new("X").bank_name).to be_nil
57
57
  end
58
58
  end
59
+
60
+ describe BankTools::DE::BLZ, ".blz_to_bank_name" do
61
+ it "returns a hash mapping BLZs to bank names" do
62
+ actual = BankTools::DE::BLZ.blz_to_bank_name
63
+ expect(actual).to be_a(Hash)
64
+ expect(actual["10000000"]).to eq "BBk Berlin"
65
+ end
66
+ 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: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henrik Nyh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-16 00:00:00.000000000 Z
11
+ date: 2014-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: attr_extras