iban-check 0.1.0 → 0.1.1

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.
@@ -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.iban? => true
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.iban? => true
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.iban? => false
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.0
1
+ 0.1.1
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{iban-check}
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Piotr Nie\305\202acny"]
@@ -14,7 +14,7 @@ module Iban
14
14
 
15
15
  def check_branch
16
16
  number = self.branch.split(//)
17
- number.pop
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
- true
38
- else
39
- false
40
- end
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
@@ -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
- iban = Iban::IbanCheck.new :iban => "PL27 1140 2004 0000 3002 0135 5387"
6
- iban.checksum.should == "27"
7
- iban.iban?.should == true
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
- iban = Iban::IbanCheck.new :iban => "HU42 1177 3016 1111 1018 0000 0000"
10
- iban.checksum.should == "42"
11
- iban.iban?.should == true
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
- 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
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: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Piotr Nie\xC5\x82acny"