bank-contact 0.0.2
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.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +94 -0
- data/Rakefile +19 -0
- data/bank.gemspec +25 -0
- data/data/iban.yml +406 -0
- data/lib/bank.rb +9 -0
- data/lib/bank/bban.rb +40 -0
- data/lib/bank/bic.rb +67 -0
- data/lib/bank/contact.rb +33 -0
- data/lib/bank/iban.rb +46 -0
- data/lib/bank/validators/bic_validator.rb +7 -0
- data/lib/bank/validators/iban_validator.rb +7 -0
- data/lib/bank/version.rb +3 -0
- data/spec/activemodel_spec.rb +52 -0
- data/spec/contact_spec.rb +29 -0
- data/spec/iban_spec.rb +150 -0
- data/spec/spec_helper.rb +10 -0
- metadata +124 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 35f525516d204bf07672f0e9eb8272fba286e433
|
4
|
+
data.tar.gz: c93cde9f372cb0d01562c612db3c23c56a81c26a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cb32dba59a577154600af67926b5e93cd461c9b9158bf609b56679a4bcbdf128f3740d5a4d36480480d022b852fd23ee531639c56af7f89d08ea20513e0098b0
|
7
|
+
data.tar.gz: da4bad5cc7555c3d9fa4f73a2ab355c1220ba198f52ae10ea07b7dfea71dbf5fec03d14a06291597dd9468cf26b529be42774c24ee42e8abcecfdf8dc873b4b6
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Kevin
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
# Bank
|
2
|
+
|
3
|
+
IBAN & BIC information, validation and formatting. Ships with ActiveModel validators.
|
4
|
+
|
5
|
+
[](http://badge.fury.io/gh/max-power%2Fbank)
|
6
|
+
[](https://travis-ci.org/max-power/bank)
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
gem 'bank-contact'
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install bank-contact
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
### Bank:::IBAN
|
25
|
+
|
26
|
+
require 'bank/iban'
|
27
|
+
|
28
|
+
iban = IBAN.new("DE89 3704 0044 0532 0130 00")
|
29
|
+
|
30
|
+
iban.country_code # "DE"
|
31
|
+
iban.check_digits # "89"
|
32
|
+
iban.bban # "370400440532013000"
|
33
|
+
iban.account_number # "0532013000"
|
34
|
+
iban.bank_identifier # "37040044"
|
35
|
+
|
36
|
+
iban.valid? # true
|
37
|
+
|
38
|
+
iban.to_s # "DE89370400440532013000"
|
39
|
+
iban.to_s(true) # "DE89 3704 0044 0532 0130 00"
|
40
|
+
|
41
|
+
iban.to_i # 370400440532013000131489
|
42
|
+
|
43
|
+
# or
|
44
|
+
|
45
|
+
IBAN.valid? "DE89 3704 0044 0532 0130 00" # true
|
46
|
+
|
47
|
+
or as ActiveModel Validator (make sure you have 'active_model' in your Gemfile)
|
48
|
+
|
49
|
+
class Company
|
50
|
+
include ActiveModel::Model
|
51
|
+
attr_accessor :iban
|
52
|
+
validates :iban, iban: true
|
53
|
+
end
|
54
|
+
|
55
|
+
### Bank::BIC
|
56
|
+
|
57
|
+
require 'bank/bic'
|
58
|
+
|
59
|
+
bic = Bank::BIC.new('BYLADEM1203')
|
60
|
+
bic.bank_code
|
61
|
+
bic.country_code
|
62
|
+
bic.location_code
|
63
|
+
bic.branch_code
|
64
|
+
bic.to_s
|
65
|
+
bic.valid?
|
66
|
+
|
67
|
+
or as ActiveModel Validator (make sure you have 'active_model' in your Gemfile)
|
68
|
+
|
69
|
+
class Company
|
70
|
+
include ActiveModel::Model
|
71
|
+
attr_accessor :bic
|
72
|
+
validates :bic, bic: true
|
73
|
+
end
|
74
|
+
|
75
|
+
### Bank::Contact
|
76
|
+
|
77
|
+
require 'bank/contact' # this requires 'iban' and 'bic'
|
78
|
+
|
79
|
+
# paramters: IBAN, BIC
|
80
|
+
contact = Bank::Contact.new("DE89 3704 0044 0532 0130 00", "BYLADEM1203")
|
81
|
+
contact.iban
|
82
|
+
contact.bic
|
83
|
+
contact.to_h
|
84
|
+
contact.to_a
|
85
|
+
contact.valid?
|
86
|
+
|
87
|
+
|
88
|
+
## Contributing
|
89
|
+
|
90
|
+
1. Fork it ( http://github.com/max-power/bank/fork )
|
91
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
92
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
93
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
94
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rake/testtask"
|
3
|
+
|
4
|
+
Rake::TestTask.new do |t|
|
5
|
+
t.pattern = 'spec/**/*_spec.rb'
|
6
|
+
t.libs << 'spec'
|
7
|
+
end
|
8
|
+
|
9
|
+
desc "Run tests"
|
10
|
+
task :default => :test
|
11
|
+
|
12
|
+
desc "Run console"
|
13
|
+
task :console do
|
14
|
+
require 'irb'
|
15
|
+
require 'irb/completion'
|
16
|
+
require 'bank/contact'
|
17
|
+
ARGV.clear
|
18
|
+
IRB.start
|
19
|
+
end
|
data/bank.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'bank/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "bank-contact"
|
8
|
+
spec.version = Bank::VERSION
|
9
|
+
spec.authors = ["Kevin"]
|
10
|
+
spec.email = ["kevin.melchert@gmail.com"]
|
11
|
+
spec.summary = %q{IBAN + SWIFT/BIC}
|
12
|
+
spec.description = %q{IBAN + SWIFT/BIC: Information, Validation and Formatting.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "minitest", "~> 4.2"
|
24
|
+
spec.add_development_dependency 'activemodel', "~> 4.0.0"
|
25
|
+
end
|
data/data/iban.yml
ADDED
@@ -0,0 +1,406 @@
|
|
1
|
+
# http://en.wikipedia.org/wiki/International_Bank_Account_Number#IBAN_formats_by_country
|
2
|
+
# http://www.swift.com/dsp/resources/documents/IBAN_Registry.pdf
|
3
|
+
|
4
|
+
al: # Albania
|
5
|
+
length: 28
|
6
|
+
# regexp: '\d{8}[A-Z0-9]{16}'
|
7
|
+
regexp: '(?<bank_identifier>\d{8})(?<account_number>[A-Z0-9]{16})'
|
8
|
+
|
9
|
+
ad: # Andorra
|
10
|
+
length: 24
|
11
|
+
# regexp: '\d{8}[A-Z0-9]{12}'
|
12
|
+
regexp: '(?<bank_identifier>\d{4})(?<branch_identifier>\d{4})(?<account_number>[A-Z0-9]{12})'
|
13
|
+
|
14
|
+
at: # Austria
|
15
|
+
length: 20
|
16
|
+
# regexp: '\d{16}'
|
17
|
+
regexp: '(?<bank_identifier>\d{5})(?<account_number>\d{11})'
|
18
|
+
|
19
|
+
az: # Azerbaijan
|
20
|
+
length: 28
|
21
|
+
# regexp: '[A-Z0-9]{4}\d{20}'
|
22
|
+
regexp: '(?<bank_identifier>[A-Z0-9]{4})(?<account_number>\d{20})'
|
23
|
+
|
24
|
+
bh: # Bahrain
|
25
|
+
length: 22
|
26
|
+
# regexp: '[A-Z]{4}[A-Z0-9]{14}'
|
27
|
+
regexp: '(?<bank_identifier>[A-Z]{4})(?<account_number>[A-Z0-9]{14})'
|
28
|
+
|
29
|
+
be: # Belgium
|
30
|
+
length: 16
|
31
|
+
# regexp: '\d{12}'
|
32
|
+
regexp: '(?<bank_identifier>\d{3})(?<account_number>\d{7})(?<national_check_digits>\d{2})'
|
33
|
+
|
34
|
+
ba: # Bosnia and Herzegovina
|
35
|
+
length: 20
|
36
|
+
# regexp: '\d{16}'
|
37
|
+
regexp: '(?<bank_identifier>\d{3})(?<branch_identifier>\d{3})(?<account_number>\d{8})(?<national_check_digits>\d{2})'
|
38
|
+
|
39
|
+
br: # Brazil
|
40
|
+
length: 29
|
41
|
+
# regexp: '\d{23}[A-Z][A-Z0-9]'
|
42
|
+
regexp: '(?<bank_identifier>\d{8})(?<branch_identifier>\d{5})(?<account_number>\d{10})(?<account_type>[A-Z])(?<account_owner>[A-Z0-9])'
|
43
|
+
|
44
|
+
bg: # Bulgaria
|
45
|
+
length: 22
|
46
|
+
# regexp: '[A-Z]{4}\d{6}[A-Z0-9]{8}'
|
47
|
+
regexp: '(?<bank_identifier>[A-Z]{4})(?<branch_identifier>\d{4})(?<account_type>\d{2})(?<account_number>[A-Z0-9]{8})'
|
48
|
+
|
49
|
+
cr: # Costa Rica
|
50
|
+
length: 21
|
51
|
+
# regexp: '\d{17}'
|
52
|
+
regexp: '(?<bank_identifier>\d{3})(?<account_number>\d{14})'
|
53
|
+
|
54
|
+
hr: # Croatia
|
55
|
+
length: 21
|
56
|
+
# regexp: '\d{17}'
|
57
|
+
regexp: '(?<bank_identifier>\d{7})(?<account_number>\d{10})'
|
58
|
+
|
59
|
+
cy: # Cyprus
|
60
|
+
length: 28
|
61
|
+
# regexp: '\d{8}[A-Z0-9]{16}'
|
62
|
+
regexp: '(?<bank_identifier>\d{3})(?<branch_identifier>\d{5})(?<account_number>[A-Z0-9]{16})'
|
63
|
+
|
64
|
+
cz: # Czech Republic
|
65
|
+
length: 24
|
66
|
+
# regexp: '\d{20}'
|
67
|
+
regexp: '(?<bank_identifier>\d{4})(?<account_number>\d{6}\d{10})'
|
68
|
+
|
69
|
+
de: # Germany
|
70
|
+
length: 22
|
71
|
+
# regexp: '\d{18}'
|
72
|
+
regexp: '(?<bank_identifier>\d{8})(?<account_number>\d{10})'
|
73
|
+
|
74
|
+
dk: # Denmark
|
75
|
+
length: 18
|
76
|
+
# regexp: '\d{14}'
|
77
|
+
regexp: '(?<bank_identifier>\d{4})(?<account_number>\d{9})(?<national_check_digits>\d{1})'
|
78
|
+
|
79
|
+
gl: # Greenland (same as Denmark)
|
80
|
+
length: 18
|
81
|
+
# regexp: '\d{14}'
|
82
|
+
regexp: '(?<bank_identifier>\d{4})(?<account_number>\d{9})(?<national_check_digits>\d{1})'
|
83
|
+
|
84
|
+
fo: # Faroe Islands (same as Denmark)
|
85
|
+
length: 18
|
86
|
+
# regexp: '\d{14}'
|
87
|
+
regexp: '(?<bank_identifier>\d{4})(?<account_number>\d{9})(?<national_check_digits>\d{1})'
|
88
|
+
|
89
|
+
do: # Dominican Republic
|
90
|
+
length: 28
|
91
|
+
# regexp: '[A-Z]{4}\d{20}'
|
92
|
+
regexp: '(?<bank_identifier>[A-Z]{4})(?<account_number>\d{20})'
|
93
|
+
|
94
|
+
ee: # Estonia
|
95
|
+
length: 20
|
96
|
+
# regexp: '\d{16}'
|
97
|
+
regexp: '(?<bank_identifier>\d{2})(?<branch_identifier>\d{2})(?<account_number>\d{11})(?<national_check_digits>\d{1})'
|
98
|
+
|
99
|
+
fi: # Finland
|
100
|
+
length: 18
|
101
|
+
# regexp: '\d{14}'
|
102
|
+
regexp: '(?<bank_identifier>\d{6})(?<account_number>\d{7})(?<national_check_digits>\d{1})'
|
103
|
+
|
104
|
+
fr: # France
|
105
|
+
length: 27
|
106
|
+
# regexp: '\d{10}[A-Z0-9]{11}\d{2}'
|
107
|
+
regexp: '(?<bank_identifier>\d{5})(?<branch_identifier>\d{5})(?<account_number>[A-Z0-9]{11})(?<national_check_digits>\d{2})'
|
108
|
+
|
109
|
+
ge: # Georgia
|
110
|
+
length: 22
|
111
|
+
# regexp: '[A-Z]{2}\d{16}'
|
112
|
+
regexp: '(?<bank_identifier>[A-Z]{2})(?<account_number>\d{16})'
|
113
|
+
|
114
|
+
gi: # Gibraltar
|
115
|
+
length: 23
|
116
|
+
# regexp: '[A-Z]{4}[A-Z0-9]{15}'
|
117
|
+
regexp: '(?<bank_identifier>[A-Z]{4})(?<account_number>[A-Z0-9]{15})'
|
118
|
+
|
119
|
+
gr: # Greece
|
120
|
+
length: 27
|
121
|
+
# regexp: '\d{7}[A-Z0-9]{16}'
|
122
|
+
regexp: '(?<bank_identifier>\d{4})(?<branch_identifier>\d{3})(?<account_number>[A-Z0-9]{16})'
|
123
|
+
|
124
|
+
gt: # Guatemala
|
125
|
+
length: 28
|
126
|
+
# regexp: '[A-Z0-9]{4}[A-Z0-9]{20}'
|
127
|
+
regexp: '(?<bank_identifier>[A-Z0-9]{4})(?<account_number>[A-Z0-9]{20})'
|
128
|
+
|
129
|
+
hu: # Hungary
|
130
|
+
length: 28
|
131
|
+
# regexp: '\d{24}'
|
132
|
+
regexp: '(?<bank_identifier>\d{3})(?<branch_identifier>\d{4})(?<account_number>\d{1}\d{15})(?<national_check_digits>\d{1})'
|
133
|
+
|
134
|
+
is: # Iceland
|
135
|
+
length: 26
|
136
|
+
# regexp: '\d{22}'
|
137
|
+
regexp: '(?<bank_identifier>\d{4})(?<branch_identifier>\d{2})(?<account_number>\d{6}\d{10})'
|
138
|
+
|
139
|
+
ie: # Ireland
|
140
|
+
length: 22
|
141
|
+
# regexp: '[A-Z0-9]{4}\d{14}'
|
142
|
+
regexp: '(?<bank_identifier>[A-Z0-9]{4})(?<branch_identifier>\d{6})(?<account_number>\d{8})'
|
143
|
+
|
144
|
+
il: # Israel
|
145
|
+
length: 23
|
146
|
+
# regexp: '\d{19}'
|
147
|
+
regexp: '(?<bank_identifier>\d{3})(?<branch_identifier>\d{3})(?<account_number>\d{13})'
|
148
|
+
|
149
|
+
it: # Italy
|
150
|
+
length: 27
|
151
|
+
# regexp: '[A-Z]\d{10}[A-Z0-9]{12}'
|
152
|
+
regexp: '(?<national_check_digits>[A-Z])(?<bank_identifier>\d{5})(?<branch_identifier>\d{5})(?<account_number>[A-Z0-9]{12})'
|
153
|
+
|
154
|
+
kz: # Kazakhstan
|
155
|
+
length: 20
|
156
|
+
# regexp: '\d{3}[A-Z0-9]{13}'
|
157
|
+
regexp: '(?<bank_identifier>\d{3})(?<account_number>[A-Z0-9]{13})'
|
158
|
+
|
159
|
+
kw: # Kuwait
|
160
|
+
length: 30
|
161
|
+
# regexp: '[A-Z]{4}[A-Z0-9]{22}'
|
162
|
+
regexp: '(?<bank_identifier>[A-Z]{4})(?<account_number>[A-Z0-9]{22})'
|
163
|
+
|
164
|
+
lv: # Latvia
|
165
|
+
length: 21
|
166
|
+
# regexp: '[A-Z]{4}[A-Z0-9]{13}'
|
167
|
+
regexp: '(?<bank_identifier>[A-Z]{4})(?<account_number>[A-Z0-9]{13})'
|
168
|
+
|
169
|
+
lb: # Lebanon
|
170
|
+
length: 28
|
171
|
+
# regexp: '\d{4}[A-Z0-9]{20}'
|
172
|
+
regexp: '(?<bank_identifier>\d{4})(?<account_number>[A-Z0-9]{20})'
|
173
|
+
|
174
|
+
li: # Liechtenstein
|
175
|
+
length: 21
|
176
|
+
# regexp: '\d{5}[A-Z0-9]{12}'
|
177
|
+
regexp: '(?<bank_identifier>\d{5})(?<account_number>[A-Z0-9]{12})'
|
178
|
+
|
179
|
+
lt: # Lithuania
|
180
|
+
length: 20
|
181
|
+
# regexp: '\d{16}'
|
182
|
+
regexp: '(?<bank_identifier>\d{5})(?<account_number>\d{11})'
|
183
|
+
|
184
|
+
lu: # Luxembourg
|
185
|
+
length: 20
|
186
|
+
# regexp: '\d{3}[A-Z0-9]{13}'
|
187
|
+
regexp: '(?<bank_identifier>\d{3})(?<account_number>[A-Z0-9]{13})'
|
188
|
+
|
189
|
+
mk: # Macedonia
|
190
|
+
length: 19
|
191
|
+
# regexp: '\d{3}[A-Z0-9]{10}\d{2}'
|
192
|
+
regexp: '(?<branch_identifier>\d{3})(?<account_number>[A-Z0-9]{10})(?<national_check_digits>\d{2})'
|
193
|
+
|
194
|
+
mt: # Malta
|
195
|
+
length: 31
|
196
|
+
# regexp: '[A-Z]{4}\d{5}[A-Z0-9]{18}'
|
197
|
+
regexp: '(?<bank_identifier>[A-Z]{4})(?<branch_identifier>\d{5})(?<account_number>[A-Z0-9]{18})'
|
198
|
+
|
199
|
+
mr: # Mauritania
|
200
|
+
length: 27
|
201
|
+
# regexp: '\d{23}'
|
202
|
+
regexp: '(?<bank_identifier>\d{5})(?<branch_identifier>\d{5})(?<account_number>\d{11})(?<national_check_digits>\d{2})'
|
203
|
+
|
204
|
+
mu: # Mauritius
|
205
|
+
length: 30
|
206
|
+
# regexp: '[A-Z]{4}\d{19}[A-Z]{3}'
|
207
|
+
regexp: '(?<bank_identifier>[A-Z]{4}\d{2})(?<branch_identifier>\d{2})(?<account_number>\d{12}\d{3}[A-Z]{3})'
|
208
|
+
|
209
|
+
mc: # Monaco
|
210
|
+
length: 27
|
211
|
+
# regexp: '\d{10}[A-Z0-9]{11}\d{2}'
|
212
|
+
regexp: '(?<bank_identifier>\d{5})(?<branch_identifier>\d{5})(?<account_number>[A-Z0-9]{11})(?<national_check_digits>\d{2})'
|
213
|
+
|
214
|
+
md: # Moldova
|
215
|
+
length: 24
|
216
|
+
# regexp: '[A-Z0-9]{2}\d{18}'
|
217
|
+
regexp: '(?<bank_identifier>[A-Z0-9]{2})(?<account_number>\d{18})'
|
218
|
+
|
219
|
+
me: # Montenegro
|
220
|
+
length: 22
|
221
|
+
# regexp: '\d{18}'
|
222
|
+
regexp: '(?<bank_identifier>\d{3})(?<account_number>(\d{13})(\d{2}))'
|
223
|
+
|
224
|
+
nl: # Netherlands
|
225
|
+
length: 18
|
226
|
+
# regexp: '[A-Z]{4}\d{10}'
|
227
|
+
regexp: '(?<bank_identifier>[A-Z]{4})(?<account_number>\d{10})'
|
228
|
+
|
229
|
+
'no': # Norway
|
230
|
+
length: 15
|
231
|
+
# regexp: '\d{11}'
|
232
|
+
regexp: '(?<bank_identifier>\d{4})(?<account_number>(\d{6})(\d{1}))'
|
233
|
+
|
234
|
+
pk: # Pakistan
|
235
|
+
length: 24
|
236
|
+
# regexp: '[A-Z0-9]{4}\d{16}'
|
237
|
+
regexp: '(?<bank_identifier>[A-Z0-9]{4})(?<account_number>\d{16})'
|
238
|
+
|
239
|
+
ps: # Palestine
|
240
|
+
length: 29
|
241
|
+
# regexp: '[A-Z0-9]{4}\d{21}'
|
242
|
+
regexp: '(?<bank_identifier>[A-Z0-9]{4})(?<account_number>\d{21})'
|
243
|
+
|
244
|
+
pl: # Poland
|
245
|
+
length: 28
|
246
|
+
# regexp: '\d{24}'
|
247
|
+
regexp: '(?<bank_identifier>\d{8})(?<account_number>\d{16})'
|
248
|
+
|
249
|
+
pt: # Portugal
|
250
|
+
length: 25
|
251
|
+
# regexp: '\d{21}'
|
252
|
+
regexp: '(?<bank_identifier>\d{4})(?<branch_identifier>\d{4})(?<account_number>\d{11})(?<national_check_digits>\d{2})'
|
253
|
+
|
254
|
+
ro: # Romania
|
255
|
+
length: 24
|
256
|
+
# regexp: '[A-Z]{4}[A-Z0-9]{16}'
|
257
|
+
regexp: '(?<bank_identifier>[A-Z]{4})(?<account_number>[A-Z0-9]{16})'
|
258
|
+
|
259
|
+
sm: # San Marino
|
260
|
+
length: 27
|
261
|
+
# regexp: '[A-Z]\d{10}[A-Z0-9]{12}'
|
262
|
+
regexp: '(?<national_check_digits>[A-Z])(?<bank_identifier>\d{5})(?<branch_identifier>\d{5})(?<account_number>[A-Z0-9]{12})'
|
263
|
+
|
264
|
+
sa: # Saudi Arabia
|
265
|
+
length: 24
|
266
|
+
# regexp: '\d{2}[A-Z0-9]{18}'
|
267
|
+
regexp: '(?<bank_identifier>\d{2})(?<account_number>[A-Z0-9]{18})'
|
268
|
+
|
269
|
+
rs: # Serbia
|
270
|
+
length: 22
|
271
|
+
# regexp: '\d{18}'
|
272
|
+
regexp: '(?<bank_identifier>\d{3})(?<account_number>\d{13})(?<national_check_digits>\d{2})'
|
273
|
+
|
274
|
+
sk: # Slovak Republic
|
275
|
+
length: 24
|
276
|
+
# regexp: '\d{20}'
|
277
|
+
regexp: '(?<bank_identifier>\d{4})(?<branch_identifier>\d{6})(?<account_number>\d{10})'
|
278
|
+
|
279
|
+
si: # Slovenia
|
280
|
+
length: 19
|
281
|
+
# regexp: '\d{15}'
|
282
|
+
regexp: '(?<bank_identifier>\d{5})(?<account_number>\d{8})(?<national_check_digits>\d{2})'
|
283
|
+
|
284
|
+
es: # Spain
|
285
|
+
length: 24
|
286
|
+
# regexp: '\d{20}'
|
287
|
+
regexp: '(?<bank_identifier>\d{4})(?<branch_identifier>\d{4})(?<national_check_digits>\d{1}\d{1})(?<account_number>\d{10})'
|
288
|
+
|
289
|
+
se: # Sweden
|
290
|
+
length: 24
|
291
|
+
# regexp: '\d{20}'
|
292
|
+
regexp: '(?<bank_identifier>\d{3})(?<account_number>\d{16}\d{1})'
|
293
|
+
|
294
|
+
ch: # Switzerland
|
295
|
+
length: 21
|
296
|
+
# regexp: '\d{5}[A-Z0-9]{12}'
|
297
|
+
regexp: '(?<bank_identifier>\d{5})(?<account_number>[A-Z0-9]{12})'
|
298
|
+
|
299
|
+
tn: # Tunisia
|
300
|
+
length: 24
|
301
|
+
# regexp: '\d{20}'
|
302
|
+
regexp: '(?<bank_identifier>\d{2})(?<branch_identifier>\d{3})(?<account_number>\d{13}\d{2})'
|
303
|
+
|
304
|
+
tr: # Turkey
|
305
|
+
length: 26
|
306
|
+
# regexp: '\d{5}[A-Z0-9]{17}'
|
307
|
+
regexp: '(?<bank_identifier>\d{5})([A-Z0-9])(?<account_number>[A-Z0-9]{16})'
|
308
|
+
|
309
|
+
ae: # United Arab Emirates
|
310
|
+
length: 23
|
311
|
+
# regexp: '\d{3}\d{16}'
|
312
|
+
regexp: '(?<bank_identifier>\d{3})(?<account_number>\d{16})'
|
313
|
+
|
314
|
+
gb: # United Kingdom
|
315
|
+
length: 22
|
316
|
+
# regexp: '[A-Z]{4}\d{14}'
|
317
|
+
regexp: '(?<bank_identifier>[A-Z]{4})(?<branch_identifier>\d{6})(?<account_number>\d{8})'
|
318
|
+
|
319
|
+
vg: # Virgin Islands, British
|
320
|
+
length: 24
|
321
|
+
# regexp: '[A-Z0-9]{4}\d{16}'
|
322
|
+
regexp: '(?<bank_identifier>[A-Z0-9]{4})(?<account_number>\d{16})'
|
323
|
+
|
324
|
+
# In addition to the above list, Nordea has catalogued IBANs for countries listed below.[32]
|
325
|
+
|
326
|
+
ao: # Angola
|
327
|
+
length: 25
|
328
|
+
# regexp: '\d{21}'
|
329
|
+
regexp: '\d{21}'
|
330
|
+
|
331
|
+
bj: # Benin
|
332
|
+
length: 28
|
333
|
+
# regexp: '[A-Z]\d{23}'
|
334
|
+
regexp: '[A-Z]\d{23}'
|
335
|
+
|
336
|
+
bf: # Burkina Faso
|
337
|
+
length: 27
|
338
|
+
# regexp: '\d{23}'
|
339
|
+
regexp: '\d{23}'
|
340
|
+
|
341
|
+
bi: # Burundi
|
342
|
+
length: 16
|
343
|
+
# regexp: '\d{12}'
|
344
|
+
regexp: '\d{12}'
|
345
|
+
|
346
|
+
cm: # Cameroon
|
347
|
+
length: 27
|
348
|
+
# regexp: '\d{23}'
|
349
|
+
regexp: '\d{23}'
|
350
|
+
|
351
|
+
cv: # Cape Verde
|
352
|
+
length: 25
|
353
|
+
# regexp: '\d{21}'
|
354
|
+
regexp: '\d{21}'
|
355
|
+
|
356
|
+
ir: # Iran
|
357
|
+
length: 26
|
358
|
+
# regexp: '\d{22}'
|
359
|
+
regexp: '\d{22}'
|
360
|
+
|
361
|
+
ci: # Ivory Coast
|
362
|
+
length: 28
|
363
|
+
# regexp: '[A-Z]\d{23}'
|
364
|
+
regexp: '[A-Z]\d{23}'
|
365
|
+
|
366
|
+
mg: # Madagascar
|
367
|
+
length: 27
|
368
|
+
# regexp: '\d{23}'
|
369
|
+
regexp: '\d{23}'
|
370
|
+
|
371
|
+
ml: # Mali
|
372
|
+
length: 28
|
373
|
+
# regexp: '[A-Z]\d{23}'
|
374
|
+
regexp: '[A-Z]\d{23}'
|
375
|
+
|
376
|
+
mz: # Mozambique
|
377
|
+
length: 25
|
378
|
+
# regexp: '\d{21}'
|
379
|
+
regexp: '\d{21}'
|
380
|
+
|
381
|
+
sn: # Senegal
|
382
|
+
length: 28
|
383
|
+
# regexp: '[A-Z]\d{23}'
|
384
|
+
regexp: '[A-Z]\d{23}'
|
385
|
+
|
386
|
+
# not quite sure about these:
|
387
|
+
|
388
|
+
# cg: # Republic Congo
|
389
|
+
# length: 27
|
390
|
+
# # regexp: ''
|
391
|
+
#
|
392
|
+
# dz: # Algeria
|
393
|
+
# length: 24
|
394
|
+
# # regexp: ''
|
395
|
+
#
|
396
|
+
# eg: # Egypt
|
397
|
+
# length: 27
|
398
|
+
# # regexp: ''
|
399
|
+
#
|
400
|
+
# ga: # Gabun
|
401
|
+
# length: 27
|
402
|
+
# # regexp: ''
|
403
|
+
#
|
404
|
+
# ua: # Ukraine
|
405
|
+
# length: 29
|
406
|
+
## regexp: ''
|
data/lib/bank.rb
ADDED
data/lib/bank/bban.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'bank'
|
2
|
+
|
3
|
+
module Bank
|
4
|
+
class BBAN # Basic Bank Account Number
|
5
|
+
def initialize(country_code, code)
|
6
|
+
@country_code, @code = country_code, code
|
7
|
+
end
|
8
|
+
|
9
|
+
def to_s
|
10
|
+
@code
|
11
|
+
end
|
12
|
+
|
13
|
+
def valid?
|
14
|
+
valid_length? && !data.nil?
|
15
|
+
end
|
16
|
+
|
17
|
+
# the bban is the iban minus the first 4 characters (country_code, check_digits)
|
18
|
+
def valid_length?
|
19
|
+
specification && specification['length'] - 4 == @code.length
|
20
|
+
end
|
21
|
+
|
22
|
+
[:account_number, :bank_identifier, :branch_identifier].each do |m|
|
23
|
+
define_method(m) { data && data[m] }
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def data
|
29
|
+
@code.match(/^#{specification['regexp']}$/) if specification
|
30
|
+
end
|
31
|
+
|
32
|
+
def specification
|
33
|
+
@specification ||= self.class.specifications[@country_code.downcase]
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.specifications
|
37
|
+
@@specs ||= Bank.load_specifications(:iban)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/bank/bic.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
require "bank/validators/bic_validator" if defined? ActiveModel
|
2
|
+
|
3
|
+
module Bank
|
4
|
+
class BIC
|
5
|
+
|
6
|
+
def self.valid?(code)
|
7
|
+
new(code).valid?
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize(code)
|
11
|
+
@code = code.to_s.strip.gsub(/\s+/, '').upcase
|
12
|
+
end
|
13
|
+
|
14
|
+
def bank_code
|
15
|
+
@code[0..3]
|
16
|
+
end
|
17
|
+
|
18
|
+
def country_code
|
19
|
+
@code[4..5]
|
20
|
+
end
|
21
|
+
|
22
|
+
def location_code
|
23
|
+
@code[6..7]
|
24
|
+
end
|
25
|
+
|
26
|
+
def branch_code
|
27
|
+
@code[8..10]
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_s(formatted=false)
|
31
|
+
formatted ? "#{bank_code} #{country_code} #{location_code} #{branch_code}".strip : @code
|
32
|
+
end
|
33
|
+
|
34
|
+
def test?
|
35
|
+
location_code[1] == '0'
|
36
|
+
end
|
37
|
+
|
38
|
+
def passive?
|
39
|
+
location_code[1] == '1'
|
40
|
+
end
|
41
|
+
|
42
|
+
def reverse_billing?
|
43
|
+
location_code[1] == '2'
|
44
|
+
end
|
45
|
+
|
46
|
+
def valid?
|
47
|
+
valid_length? && valid_format? && valid_location_code? && valid_branch_code?
|
48
|
+
end
|
49
|
+
|
50
|
+
def valid_length?
|
51
|
+
@code.length == 8 || @code.length == 11
|
52
|
+
end
|
53
|
+
|
54
|
+
def valid_format?
|
55
|
+
@code =~ /^[A-Z]{4}[A-Z]{2}[A-Z0-9]{2}([A-Z0-9]{3})?$/
|
56
|
+
end
|
57
|
+
|
58
|
+
def valid_location_code?
|
59
|
+
location_code[0] != '0' && location_code[0] != '1' && location_code[1] != 'O'
|
60
|
+
end
|
61
|
+
|
62
|
+
def valid_branch_code?
|
63
|
+
branch_code.nil? || !(branch_code[0] == 'X' && branch_code != 'XXX')
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
data/lib/bank/contact.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'bank/iban'
|
2
|
+
require 'bank/bic'
|
3
|
+
|
4
|
+
module Bank
|
5
|
+
class Contact
|
6
|
+
attr_reader :iban, :bic
|
7
|
+
|
8
|
+
def initialize(iban, bic)
|
9
|
+
self.iban = iban
|
10
|
+
self.bic = bic
|
11
|
+
end
|
12
|
+
|
13
|
+
def iban=(value)
|
14
|
+
@iban = IBAN.new(value)
|
15
|
+
end
|
16
|
+
|
17
|
+
def bic=(value)
|
18
|
+
@bic = BIC.new(value)
|
19
|
+
end
|
20
|
+
|
21
|
+
def valid?
|
22
|
+
iban.valid? && bic.valid?
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_h
|
26
|
+
{ iban: iban.to_s, bic: bic.to_s }
|
27
|
+
end
|
28
|
+
|
29
|
+
def to_a
|
30
|
+
to_h.values
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/bank/iban.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require "forwardable"
|
2
|
+
require "bank/bban"
|
3
|
+
require "bank/validators/iban_validator" if defined? ActiveModel
|
4
|
+
|
5
|
+
module Bank
|
6
|
+
class IBAN # International Bank Account Number
|
7
|
+
extend Forwardable
|
8
|
+
def_delegators :bban, :account_number, :bank_identifier, :branch_identifier
|
9
|
+
|
10
|
+
def self.valid?(code)
|
11
|
+
new(code).valid?
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(code)
|
15
|
+
@code = code.to_s.strip.gsub(/\s+/, '').upcase
|
16
|
+
end
|
17
|
+
|
18
|
+
def country_code
|
19
|
+
@code[0..1]
|
20
|
+
end
|
21
|
+
|
22
|
+
def check_digits
|
23
|
+
@code[2..3]
|
24
|
+
end
|
25
|
+
|
26
|
+
def bban
|
27
|
+
@bban ||= BBAN.new(country_code, @code[4..-1])
|
28
|
+
end
|
29
|
+
|
30
|
+
def valid?
|
31
|
+
valid_check_digits? && bban.valid?
|
32
|
+
end
|
33
|
+
|
34
|
+
def valid_check_digits?
|
35
|
+
to_i % 97 == 1
|
36
|
+
end
|
37
|
+
|
38
|
+
def to_i
|
39
|
+
"#{bban}#{country_code}#{check_digits}".each_char.map { |chr| chr.to_i(36) }.join.to_i
|
40
|
+
end
|
41
|
+
|
42
|
+
def to_s(formatted=false)
|
43
|
+
formatted ? @code.gsub(/(.{4})/, '\1 ').strip : @code
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/bank/version.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class Company
|
4
|
+
include ActiveModel::Model
|
5
|
+
|
6
|
+
attr_accessor :iban, :name
|
7
|
+
validates :iban, iban: true
|
8
|
+
|
9
|
+
def persisted?
|
10
|
+
false
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class Person
|
15
|
+
include ActiveModel::Model
|
16
|
+
|
17
|
+
attr_accessor :iban
|
18
|
+
validates :iban, iban: true, allow_nil: true
|
19
|
+
|
20
|
+
def persisted?
|
21
|
+
false
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
describe IbanValidator do
|
27
|
+
before {
|
28
|
+
@model = Company.new
|
29
|
+
}
|
30
|
+
|
31
|
+
it "should be valid" do
|
32
|
+
@model.iban = 'FR1420041010050500013M02606'
|
33
|
+
@model.valid?.must_equal true
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should not be valid" do
|
37
|
+
@model.iban = 'FR1420041010050500013'
|
38
|
+
@model.valid?.must_equal false
|
39
|
+
@model.errors[:iban].must_include "is invalid"
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should not validate with nil value" do
|
43
|
+
@model.iban.must_equal nil
|
44
|
+
@model.valid?.must_equal false
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should not use the validator with option allow_nil: true" do
|
48
|
+
@person = Person.new
|
49
|
+
@person.iban.must_equal nil
|
50
|
+
@person.valid?.must_equal true
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'bank/contact'
|
4
|
+
|
5
|
+
describe Bank::Contact do
|
6
|
+
before do
|
7
|
+
@iban = Bank::IBAN.new('FR14 2004 1010 0505 0001 3M026 06')
|
8
|
+
@bic = Bank::BIC.new('BYLADEM1203')
|
9
|
+
@contact = Bank::Contact.new(@iban, @bic)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should validate" do
|
13
|
+
@contact.valid?.must_equal true
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should have the right types" do
|
17
|
+
@contact.iban.must_be_kind_of Bank::IBAN
|
18
|
+
@contact.bic.must_be_kind_of Bank::BIC
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should export to_h" do
|
22
|
+
@contact.to_h.must_equal({iban: "FR1420041010050500013M02606", bic: "BYLADEM1203"})
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should export to_a" do
|
26
|
+
@contact.to_a.must_equal(["FR1420041010050500013M02606", "BYLADEM1203"])
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
data/spec/iban_spec.rb
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
|
4
|
+
describe Bank::IBAN do
|
5
|
+
before do
|
6
|
+
@iban = Bank::IBAN.new('FR14 2004 1010 0505 0001 3M026 06')
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should valid from class method" do
|
10
|
+
Bank::IBAN.valid?('FR14 2004 1010 0505 0001 3M026 06').must_equal true
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should load the validation rules" do
|
14
|
+
Bank.load_specifications(:iban).wont_be :empty?
|
15
|
+
Bank.load_specifications(:iban).must_be_kind_of Hash
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should return the county code" do
|
19
|
+
@iban.country_code.must_equal "FR"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should return the check digits" do
|
23
|
+
@iban.check_digits.must_equal "14"
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should return the BBAN" do
|
27
|
+
@iban.bban.must_be_kind_of Bank::BBAN
|
28
|
+
@iban.bban.to_s.must_equal "20041010050500013M02606"
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should convert to integer value" do
|
32
|
+
@iban.to_i.must_equal 200410100505000132202606152714
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should convert to string" do
|
36
|
+
@iban.to_s.must_equal 'FR1420041010050500013M02606'
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should convert to formatted string" do
|
40
|
+
@iban.to_s(true).must_equal 'FR14 2004 1010 0505 0001 3M02 606'
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should respond_to? account_number" do
|
44
|
+
@iban.respond_to?(:account_number).must_equal true
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should return account_number" do
|
48
|
+
@iban.account_number.must_equal "0500013M026"
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should return bank_identifier" do
|
52
|
+
@iban.bank_identifier.must_equal "20041"
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should return branch_identifier" do
|
56
|
+
@iban.branch_identifier.must_equal "01005"
|
57
|
+
end
|
58
|
+
|
59
|
+
[
|
60
|
+
"AL47212110090000000235698741",
|
61
|
+
"AD12 00012030200359100100",
|
62
|
+
"AT611904300234573201",
|
63
|
+
"BE68539007547034",
|
64
|
+
"BA391290079401028494",
|
65
|
+
"BG80BNBG96611020345678",
|
66
|
+
"HR1210010051863000160",
|
67
|
+
"CY17002001280000001200527600",
|
68
|
+
"CZ6508000000192000145399",
|
69
|
+
"DK5000400440116243",
|
70
|
+
"EE382200221020145685",
|
71
|
+
"FO1464600009692713",
|
72
|
+
"FI2112345600000785",
|
73
|
+
"FR1420041010050500013M02606",
|
74
|
+
"GE29NB0000000101904917",
|
75
|
+
"DE89370400440532013000",
|
76
|
+
"GI75NWBK000000007099453",
|
77
|
+
"GR1601101250000000012300695",
|
78
|
+
"GL8964710001000206",
|
79
|
+
"HU42117730161111101800000000",
|
80
|
+
"IS140159260076545510730339",
|
81
|
+
"IE29AIBK93115212345678",
|
82
|
+
"IT60X0542811101000000123456",
|
83
|
+
"LV80BANK0000435195001",
|
84
|
+
"LI21088100002324013AA",
|
85
|
+
"LT121000011101001000",
|
86
|
+
"LU280019400644750000",
|
87
|
+
"MK07300000000042425",
|
88
|
+
"MT84MALT011000012345MTLCAST001S",
|
89
|
+
"MD24AG000225100013104168",
|
90
|
+
"MC5813488000010051108001292",
|
91
|
+
"ME25505000012345678951",
|
92
|
+
"NL91ABNA0417164300",
|
93
|
+
"NO9386011117947",
|
94
|
+
"PL27114020040000300201355387",
|
95
|
+
"PT50000201231234567890154",
|
96
|
+
"RO49AAAA1B31007593840000",
|
97
|
+
"SM86U0322509800000000270100",
|
98
|
+
"RS35260005601001611379",
|
99
|
+
"SK3112000000198742637541",
|
100
|
+
"SI56191000000123438",
|
101
|
+
"ES9121000418450200051332",
|
102
|
+
"SE3550000000054910000003",
|
103
|
+
"CH9300762011623852957",
|
104
|
+
#"UA573543470006762462054925026",
|
105
|
+
"GB29NWBK60161331926819",
|
106
|
+
#"DZ4000400174401001050486",
|
107
|
+
"AO06000600000100037131174",
|
108
|
+
"AZ21NABZ00000000137010001944",
|
109
|
+
"BH29BMAG1299123456BH00",
|
110
|
+
"BJ11B00610100400271101192591",
|
111
|
+
"BR9700360305000010009795493P1",
|
112
|
+
"VG96VPVG0000012345678901",
|
113
|
+
"BF1030134020015400945000643",
|
114
|
+
"BI43201011067444",
|
115
|
+
"CM2110003001000500000605306",
|
116
|
+
"CV64000300004547069110176",
|
117
|
+
"FR7630007000110009970004942",
|
118
|
+
#"CG5230011000202151234567890",
|
119
|
+
"CR0515202001026284066",
|
120
|
+
"DO28BAGR00000001212453611324",
|
121
|
+
#"EG1100006001880800100014553",
|
122
|
+
#"GA2140002000055602673300064",
|
123
|
+
"GT82TRAJ01020000001210029690",
|
124
|
+
"IR580540105180021273113007",
|
125
|
+
"IL620108000000099999999",
|
126
|
+
"CI05A00060174100178530011852",
|
127
|
+
"KZ176010251000042993",
|
128
|
+
"KW74NBOK0000000000001000372151",
|
129
|
+
"LB30099900000001001925579115",
|
130
|
+
"MG4600005030010101914016056",
|
131
|
+
"ML03D00890170001002120000447",
|
132
|
+
"MR1300012000010000002037372",
|
133
|
+
"MU17BOMM0101101030300200000MUR",
|
134
|
+
"MZ59000100000011834194157",
|
135
|
+
"PK24SCBL0000001171495101",
|
136
|
+
"PS92PALS000000000400123456702",
|
137
|
+
"PT50000200000163099310355",
|
138
|
+
"SA0380000000608010167519",
|
139
|
+
"SN12K00100152000025690007542",
|
140
|
+
"TN5914207207100707129648",
|
141
|
+
"TR330006100519786457841326",
|
142
|
+
"AE260211000000230064016"
|
143
|
+
].each do |code|
|
144
|
+
describe code do
|
145
|
+
it "should be valid" do
|
146
|
+
Bank::IBAN.new(code).valid?.must_equal true
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bank-contact
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kevin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '4.2'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '4.2'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: activemodel
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 4.0.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 4.0.0
|
69
|
+
description: 'IBAN + SWIFT/BIC: Information, Validation and Formatting.'
|
70
|
+
email:
|
71
|
+
- kevin.melchert@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".travis.yml"
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- bank.gemspec
|
83
|
+
- data/iban.yml
|
84
|
+
- lib/bank.rb
|
85
|
+
- lib/bank/bban.rb
|
86
|
+
- lib/bank/bic.rb
|
87
|
+
- lib/bank/contact.rb
|
88
|
+
- lib/bank/iban.rb
|
89
|
+
- lib/bank/validators/bic_validator.rb
|
90
|
+
- lib/bank/validators/iban_validator.rb
|
91
|
+
- lib/bank/version.rb
|
92
|
+
- spec/activemodel_spec.rb
|
93
|
+
- spec/contact_spec.rb
|
94
|
+
- spec/iban_spec.rb
|
95
|
+
- spec/spec_helper.rb
|
96
|
+
homepage: ''
|
97
|
+
licenses:
|
98
|
+
- MIT
|
99
|
+
metadata: {}
|
100
|
+
post_install_message:
|
101
|
+
rdoc_options: []
|
102
|
+
require_paths:
|
103
|
+
- lib
|
104
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
requirements: []
|
115
|
+
rubyforge_project:
|
116
|
+
rubygems_version: 2.2.0
|
117
|
+
signing_key:
|
118
|
+
specification_version: 4
|
119
|
+
summary: IBAN + SWIFT/BIC
|
120
|
+
test_files:
|
121
|
+
- spec/activemodel_spec.rb
|
122
|
+
- spec/contact_spec.rb
|
123
|
+
- spec/iban_spec.rb
|
124
|
+
- spec/spec_helper.rb
|