iban-check 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +8 -4
- data/VERSION +1 -1
- data/iban-check.gemspec +1 -1
- data/lib/iban-check/iban.rb +9 -5
- data/spec/iban-check_spec.rb +33 -33
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -5,16 +5,20 @@ Check your IBAN number.
|
|
5
5
|
|
6
6
|
iban = Iban::IbanCheck.new :iban => "PL27 1140 2004 0000 3002 0135 5387"
|
7
7
|
iban.checksum => "27"
|
8
|
-
iban.
|
8
|
+
iban.valid? => true
|
9
|
+
|
10
|
+
iban = Iban::IbanCheck.new :iban => "27 1140 2004 0000 3002 0135 5387", :country => "PL"
|
11
|
+
iban.checksum => "27"
|
12
|
+
iban.valid? => true
|
9
13
|
|
10
14
|
iban = Iban::IbanCheck.new :iban => "GB29 NWBK 6016 1331 9268 19"
|
11
15
|
iban.checksum => "29"
|
12
|
-
iban.
|
16
|
+
iban.valid? => true
|
13
17
|
|
14
18
|
iban = Iban::IbanCheck.new :iban => "IE55 AIBK 9311 5212 3456 78" # should be "IE29 AIBK 9311 5212 3456 78"
|
15
19
|
iban.checksum => "29"
|
16
|
-
iban.
|
17
|
-
|
20
|
+
iban.valid? => false
|
21
|
+
|
18
22
|
== Note on Patches/Pull Requests
|
19
23
|
|
20
24
|
* Fork the project.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/iban-check.gemspec
CHANGED
data/lib/iban-check/iban.rb
CHANGED
@@ -14,7 +14,7 @@ module Iban
|
|
14
14
|
|
15
15
|
def check_branch
|
16
16
|
number = self.branch.split(//)
|
17
|
-
|
17
|
+
number.pop
|
18
18
|
|
19
19
|
result = 0
|
20
20
|
|
@@ -34,10 +34,10 @@ module Iban
|
|
34
34
|
end
|
35
35
|
|
36
36
|
if result.to_s[-1] == 48
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
37
|
+
true
|
38
|
+
else
|
39
|
+
false
|
40
|
+
end
|
41
41
|
end
|
42
42
|
|
43
43
|
def checksum
|
@@ -54,6 +54,10 @@ module Iban
|
|
54
54
|
checksum == iban[0..1]
|
55
55
|
end
|
56
56
|
|
57
|
+
def valid?
|
58
|
+
iban?
|
59
|
+
end
|
60
|
+
|
57
61
|
private
|
58
62
|
|
59
63
|
def prepare_iban
|
data/spec/iban-check_spec.rb
CHANGED
@@ -2,41 +2,41 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
2
|
|
3
3
|
describe "IbanCheck" do
|
4
4
|
it "should create proper checksum from valid IBAN number" do
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
iban = Iban::IbanCheck.new :iban => "PL27 1140 2004 0000 3002 0135 5387"
|
6
|
+
iban.checksum.should == "27"
|
7
|
+
iban.iban?.should == true
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
iban = Iban::IbanCheck.new :iban => "HU42 1177 3016 1111 1018 0000 0000"
|
10
|
+
iban.checksum.should == "42"
|
11
|
+
iban.iban?.should == true
|
12
12
|
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
14
|
+
it "should create proper checksum from invalid IBAN number" do
|
15
|
+
iban = Iban::IbanCheck.new :iban => "PL27 1140 2004 0010 3002 0135 5387"
|
16
|
+
iban.checksum.should == "10"
|
17
|
+
iban.iban?.should == false
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should raise error -- no country" do
|
21
|
+
lambda {Iban::IbanCheck.new(:iban => "27 1140 2004 0010 3002 0135 5387")}.should raise_error
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should recognize country" do
|
25
|
+
iban = Iban::IbanCheck.new :iban => "PL27 1140 2004 0010 3002 0135 5387"
|
26
|
+
iban.country.should == "PL"
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should create proper checksum for branch" do
|
30
|
+
iban = Iban::IbanCheck.new :iban => "PL27 1140 2004 0010 3002 0135 5387"
|
31
|
+
iban.check_branch.should == 4
|
32
|
+
|
33
|
+
iban = Iban::IbanCheck.new :iban => "PL27 1145 2024 0010 3002 0135 5387"
|
34
|
+
iban.check_branch.should_not == 4
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should answer true for proper branch" do
|
38
|
+
iban = Iban::IbanCheck.new :iban => "PL27 1160 2202 0010 3002 0135 5387"
|
39
|
+
iban.branch?.should == true
|
40
|
+
end
|
41
41
|
|
42
42
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iban-check
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Piotr Nie\xC5\x82acny"
|