blz 0.1.4.20140907.1 → 0.1.4.20140907.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/blz.gemspec +1 -1
- data/lib/blz/bank.rb +19 -0
- data/test/test_bank.rb +10 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dcc624f8a1d94f6442eeca3cc87fc50159bf2915
|
4
|
+
data.tar.gz: 4aaa942082b94a7d76dd6cedd970ae133af8067d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 112044c5a3cd5df8c4a8e26d7d11f76d0e57e8710b6bf51e398d3832904f450eedf0defe2cbb988a525498da8da2a3b6c8a8bb2784eb840ee24dbc972d2b669b
|
7
|
+
data.tar.gz: b68b0f12573d8ae07d755f0b7c0b20fa3dcd837ab82adca8657a61c71193863fae447aa971fe84fb091ed9f7c844eed9dfe9d391fccdf6dc65f3f25f1de2e5ba
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
-
# 0.1.4.
|
1
|
+
# 0.1.4.20140907.2, released 2014-07-25
|
2
|
+
|
3
|
+
* finders return an empty array when given `nil` or a blank string
|
4
|
+
|
5
|
+
# 0.1.4.20140907.1, released 2014-07-11
|
2
6
|
|
3
7
|
* apply update BIC of Sberbank (SEZBDEF1XXX → SEZDDEF1XXX)
|
4
8
|
after Bundesbank ExtraNet notifcation from 2014-07-10
|
data/blz.gemspec
CHANGED
data/lib/blz/bank.rb
CHANGED
@@ -11,6 +11,8 @@ module BLZ
|
|
11
11
|
# exact:: Only return exact matches (false by default)
|
12
12
|
#
|
13
13
|
def find_by_blz(code, options = {})
|
14
|
+
return [] if blank?(code)
|
15
|
+
|
14
16
|
exact = options.fetch(:exact, false)
|
15
17
|
all.select do |bank|
|
16
18
|
bank.blz == code || (!exact && bank.blz.start_with?(code))
|
@@ -19,6 +21,8 @@ module BLZ
|
|
19
21
|
|
20
22
|
# Returns an array of all Banks with a substring of +city+.
|
21
23
|
def find_by_city(substring)
|
24
|
+
return [] if blank?(substring)
|
25
|
+
|
22
26
|
all.select do |bank|
|
23
27
|
bank.city.index(substring)
|
24
28
|
end
|
@@ -29,6 +33,8 @@ module BLZ
|
|
29
33
|
# exact:: Only return exact matches (false by default)
|
30
34
|
#
|
31
35
|
def find_by_bic(bic, options = {})
|
36
|
+
return [] if blank?(bic)
|
37
|
+
|
32
38
|
exact = options.fetch(:exact, false)
|
33
39
|
all.select do |bank|
|
34
40
|
bank.bic == bic || (!exact && (bank.bic || '').start_with?(bic))
|
@@ -51,6 +57,18 @@ module BLZ
|
|
51
57
|
end
|
52
58
|
banks
|
53
59
|
end
|
60
|
+
|
61
|
+
# Checks whether an object is blank (empty Array/Hash/String).
|
62
|
+
#
|
63
|
+
# Does not rely on ActiveSupport, but prefers that implementation.
|
64
|
+
def blank?(obj)
|
65
|
+
return true if obj.nil?
|
66
|
+
return obj.blank? if obj.respond_to?(:blank?)
|
67
|
+
obj = obj.strip if String === obj
|
68
|
+
return obj.empty? if obj.respond_to?(:empty?)
|
69
|
+
|
70
|
+
false
|
71
|
+
end
|
54
72
|
end
|
55
73
|
|
56
74
|
attr_reader :blz, :name, :zip, :city, :short_name, :bic
|
@@ -69,5 +87,6 @@ module BLZ
|
|
69
87
|
def to_s
|
70
88
|
[blz, name, "#{zip} #{city}", bic].compact.reject(&:empty?).join(', ')
|
71
89
|
end
|
90
|
+
|
72
91
|
end
|
73
92
|
end
|
data/test/test_bank.rb
CHANGED
@@ -51,6 +51,16 @@ class TestBank < Test::Unit::TestCase
|
|
51
51
|
assert results.find { |b| b.blz == "70150000" }
|
52
52
|
end
|
53
53
|
|
54
|
+
def test_search_by_empty_bic
|
55
|
+
assert results = BLZ::Bank.find_by_bic('')
|
56
|
+
assert results.size == 0
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_search_by_nil_bic
|
60
|
+
assert results = BLZ::Bank.find_by_bic(nil)
|
61
|
+
assert results.size == 0
|
62
|
+
end
|
63
|
+
|
54
64
|
def test_to_s
|
55
65
|
assert results = BLZ::Bank.find_by_blz("70150000", :exact_only => true)
|
56
66
|
assert_equal 1, results.size
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.4.20140907.
|
4
|
+
version: 0.1.4.20140907.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oliver Eilhard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|