banktools-se 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/banktools-se/account.rb +1 -1
- data/lib/banktools-se/version.rb +1 -1
- data/spec/account_spec.rb +3 -12
- data/spec/bankgiro_spec.rb +0 -9
- metadata +13 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b633dbca824e82f87a2231925c8d70eceefba6a
|
4
|
+
data.tar.gz: 52d741928c20bdd104ef5485d63e98c2fc6a95a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5bb3d5baccd5d08d4c8a6151014d9790b507d87043061abc81f98036c932b84109cbdc8da1ee3d6fe30bb7a6f55ed9ef40fdea5673b3b4dd41ad43421551489
|
7
|
+
data.tar.gz: 47f8212e2a74a177af8c4306a4369a54c677e1aaa9ae7a9dae13fa0aab63fe1292a1c5bdbe4c0d3270cec87a87b868519dfcfbae64c8b2fcfc72a47ed42520a3
|
data/lib/banktools-se/account.rb
CHANGED
@@ -99,7 +99,7 @@ module BankTools
|
|
99
99
|
|
100
100
|
def serial_number
|
101
101
|
number = digits.slice(clearing_number_length..-1) || ""
|
102
|
-
zerofill? ? "%.#{bank_data[:serial_number_length]}d" % number : number
|
102
|
+
zerofill? ? "%.#{bank_data[:serial_number_length]}d" % number.to_i(10) : number
|
103
103
|
end
|
104
104
|
|
105
105
|
private
|
data/lib/banktools-se/version.rb
CHANGED
data/spec/account_spec.rb
CHANGED
@@ -4,13 +4,11 @@ require "spec_helper"
|
|
4
4
|
require "banktools-se"
|
5
5
|
|
6
6
|
describe BankTools::SE::Account do
|
7
|
-
|
8
7
|
it "should initialize" do
|
9
8
|
BankTools::SE::Account.new("foo").should be_a(BankTools::SE::Account)
|
10
9
|
end
|
11
10
|
|
12
11
|
describe "#valid?" do
|
13
|
-
|
14
12
|
it "should be true with no errors" do
|
15
13
|
account = BankTools::SE::Account.new("foo")
|
16
14
|
account.stub(:errors).and_return([])
|
@@ -22,7 +20,6 @@ describe BankTools::SE::Account do
|
|
22
20
|
account.stub(:errors).and_return([:error])
|
23
21
|
account.should_not be_valid
|
24
22
|
end
|
25
|
-
|
26
23
|
end
|
27
24
|
|
28
25
|
describe "#errors" do
|
@@ -107,11 +104,9 @@ describe BankTools::SE::Account do
|
|
107
104
|
BankTools::SE::Account.new("10000000009").errors.should include(BankTools::SE::Errors::UNKNOWN_CLEARING_NUMBER)
|
108
105
|
BankTools::SE::Account.new("11000000007").errors.should_not include(BankTools::SE::Errors::UNKNOWN_CLEARING_NUMBER)
|
109
106
|
end
|
110
|
-
|
111
107
|
end
|
112
108
|
|
113
109
|
describe "#bank" do
|
114
|
-
|
115
110
|
it "should return the bank for the current clearing number" do
|
116
111
|
BankTools::SE::Account.new("11000000007").bank.should == "Nordea"
|
117
112
|
BankTools::SE::Account.new("11550000001").bank.should == "Nordea"
|
@@ -122,11 +117,9 @@ describe BankTools::SE::Account do
|
|
122
117
|
it "should return nil for unknown clearing numbers" do
|
123
118
|
BankTools::SE::Account.new("10000000009").bank.should be_nil
|
124
119
|
end
|
125
|
-
|
126
120
|
end
|
127
121
|
|
128
122
|
describe "#clearing_number" do
|
129
|
-
|
130
123
|
it "should be the first four digits" do
|
131
124
|
BankTools::SE::Account.new("12345678").clearing_number.should == "1234"
|
132
125
|
end
|
@@ -134,11 +127,9 @@ describe BankTools::SE::Account do
|
|
134
127
|
it "should be the first five digits if there is a clearing number checksum" do
|
135
128
|
BankTools::SE::Account.new("8000-2-0000000000").clearing_number.should == "8000-2"
|
136
129
|
end
|
137
|
-
|
138
130
|
end
|
139
131
|
|
140
132
|
describe "#serial_number" do
|
141
|
-
|
142
133
|
it "should be the digits after the first four digits" do
|
143
134
|
BankTools::SE::Account.new("12345678").serial_number.should == "5678"
|
144
135
|
end
|
@@ -151,10 +142,12 @@ describe BankTools::SE::Account do
|
|
151
142
|
BankTools::SE::Account.new("12").serial_number.should == ""
|
152
143
|
end
|
153
144
|
|
145
|
+
it "should manage pre-zerofilled account numbers" do
|
146
|
+
BankTools::SE::Account.new("8000-2-0800000002").should be_valid
|
147
|
+
end
|
154
148
|
end
|
155
149
|
|
156
150
|
describe "#normalize" do
|
157
|
-
|
158
151
|
it "should normalize to clearing number dash serial number" do
|
159
152
|
account = BankTools::SE::Account.new("11000000007").normalize.should == "1100-0000007"
|
160
153
|
end
|
@@ -171,7 +164,5 @@ describe BankTools::SE::Account do
|
|
171
164
|
BankTools::SE::Account.new("8000-2-80000003").normalize.should == "8000-2-0080000003"
|
172
165
|
BankTools::SE::Account.new("8000-2-8000000003").normalize.should == "8000-2-8000000003"
|
173
166
|
end
|
174
|
-
|
175
167
|
end
|
176
|
-
|
177
168
|
end
|
data/spec/bankgiro_spec.rb
CHANGED
@@ -2,13 +2,11 @@ require "spec_helper"
|
|
2
2
|
require "banktools-se"
|
3
3
|
|
4
4
|
describe BankTools::SE::Bankgiro do
|
5
|
-
|
6
5
|
it "should initialize" do
|
7
6
|
BankTools::SE::Bankgiro.new("foo").should be_a(BankTools::SE::Bankgiro)
|
8
7
|
end
|
9
8
|
|
10
9
|
describe "#valid?" do
|
11
|
-
|
12
10
|
it "should be true with no errors" do
|
13
11
|
account = BankTools::SE::Bankgiro.new("foo")
|
14
12
|
account.stub(:errors).and_return([])
|
@@ -20,7 +18,6 @@ describe BankTools::SE::Bankgiro do
|
|
20
18
|
account.stub(:errors).and_return([:error])
|
21
19
|
account.should_not be_valid
|
22
20
|
end
|
23
|
-
|
24
21
|
end
|
25
22
|
|
26
23
|
describe "#errors" do
|
@@ -54,11 +51,9 @@ describe BankTools::SE::Bankgiro do
|
|
54
51
|
it "should include :bad_checksum if the Luhn/mod 10 checksum is incorrect" do
|
55
52
|
BankTools::SE::Bankgiro.new("5402-9682").errors.should include(BankTools::SE::Errors::BAD_CHECKSUM)
|
56
53
|
end
|
57
|
-
|
58
54
|
end
|
59
55
|
|
60
56
|
describe "#normalize" do
|
61
|
-
|
62
57
|
it "should normalize 7-digit numbers to NNN-NNNN" do
|
63
58
|
account = BankTools::SE::Bankgiro.new(" 6-40 - 5070")
|
64
59
|
account.normalize.should == "640-5070"
|
@@ -73,11 +68,9 @@ describe BankTools::SE::Bankgiro do
|
|
73
68
|
account = BankTools::SE::Bankgiro.new(" 1-2-3 ")
|
74
69
|
account.normalize.should == " 1-2-3 "
|
75
70
|
end
|
76
|
-
|
77
71
|
end
|
78
72
|
|
79
73
|
describe "#fundraising? (90-konto)" do
|
80
|
-
|
81
74
|
it "should be true for the number series 900-nnnn to 904-nnnn" do
|
82
75
|
BankTools::SE::Bankgiro.new("902-0033").should be_fundraising
|
83
76
|
end
|
@@ -89,7 +82,5 @@ describe BankTools::SE::Bankgiro do
|
|
89
82
|
it "should be false for numbers outside the right series" do
|
90
83
|
BankTools::SE::Bankgiro.new("5402-9681").should_not be_fundraising
|
91
84
|
end
|
92
|
-
|
93
85
|
end
|
94
|
-
|
95
86
|
end
|
metadata
CHANGED
@@ -1,69 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: banktools-se
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.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:
|
11
|
+
date: 2014-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: guard
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: guard-rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
description:
|
@@ -101,17 +101,17 @@ require_paths:
|
|
101
101
|
- lib
|
102
102
|
required_ruby_version: !ruby/object:Gem::Requirement
|
103
103
|
requirements:
|
104
|
-
- -
|
104
|
+
- - '>='
|
105
105
|
- !ruby/object:Gem::Version
|
106
106
|
version: '0'
|
107
107
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
|
-
- -
|
109
|
+
- - '>='
|
110
110
|
- !ruby/object:Gem::Version
|
111
111
|
version: '0'
|
112
112
|
requirements: []
|
113
113
|
rubyforge_project: banktools-se
|
114
|
-
rubygems_version: 2.0
|
114
|
+
rubygems_version: 2.2.0
|
115
115
|
signing_key:
|
116
116
|
specification_version: 4
|
117
117
|
summary: Validate and normalize Swedish bank account numbers, plusgiro and bankgiro.
|
@@ -121,4 +121,3 @@ test_files:
|
|
121
121
|
- spec/plusgiro_spec.rb
|
122
122
|
- spec/spec_helper.rb
|
123
123
|
- spec/utils_spec.rb
|
124
|
-
has_rdoc:
|