iban-tools 0.0.6 → 0.0.8
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.
- data/README.md +6 -18
- data/lib/iban-tools/iban.rb +1 -1
- data/lib/iban-tools/iban_rules.rb +1 -1
- data/lib/iban-tools/rules.yml +136 -96
- metadata +25 -32
data/README.md
CHANGED
@@ -2,30 +2,14 @@
|
|
2
2
|
|
3
3
|
iban-tools is a Ruby library for manipulating and validating IBAN account numbers. You can [read more about IBAN](http://en.wikipedia.org/wiki/International_Bank_Account_Number) on Wikipedia
|
4
4
|
|
5
|
-
## Credit
|
6
|
-
|
7
|
-
[Iulianu](http://github.com/iulianu) wrote [iban-tools](http://github.com/iulianu/iban-tools). We just removed use of `String#ord` for compatibility with Ruby 1.8 and 1.9 and of course pushed the built gem to gemcutter.
|
8
|
-
|
9
|
-
You'll find the [source code](http://github.com/iulianu/iban-tools) on Github. [Our fork](http://github.com/alphasights/iban-tools) is also available on GitHub
|
10
|
-
|
11
|
-
The gem should be compatible with Ruby 1.8.6, 1.8.7 and 1.9.1.
|
12
|
-
|
13
5
|
## INSTALLATION
|
14
6
|
|
15
|
-
You'll need to add http://gems.rubyforge.com as a gem source if you don't already have it.
|
16
|
-
|
17
|
-
You can accomplish this with the gemcutter gem.
|
18
|
-
|
19
|
-
gem install gemcutter
|
20
|
-
gem tumble
|
21
|
-
|
22
|
-
Once you have the gemcutter source added you can install iban-tools with a simple gem install.
|
23
|
-
|
24
7
|
gem install iban-tools
|
25
8
|
|
9
|
+
The gem should be compatible with MRI 1.8 and 1.9.
|
10
|
+
|
26
11
|
## USAGE
|
27
12
|
|
28
|
-
require 'rubygems'
|
29
13
|
require 'iban-tools'
|
30
14
|
|
31
15
|
IBANTools::IBAN.valid?("GB82 WEST 1234 5698 7654 32")
|
@@ -48,3 +32,7 @@ Pretty print, canonicalize, and extract fields from an IBAN code
|
|
48
32
|
|
49
33
|
iban.prettify
|
50
34
|
=> "RO49 AAAA 1B31 0075 9384 0000"
|
35
|
+
|
36
|
+
## Credit
|
37
|
+
|
38
|
+
[Iulianu](http://github.com/iulianu) wrote [iban-tools](http://github.com/iulianu/iban-tools). ([AlphaSights](http://dev.alphasights.com)) is now maintaining the gem.
|
data/lib/iban-tools/iban.rb
CHANGED
@@ -21,7 +21,7 @@ module IBANTools
|
|
21
21
|
def self.load_from_string( string )
|
22
22
|
rule_hash = YAML.load(string)
|
23
23
|
rule_hash.each do |country_code, specs|
|
24
|
-
specs["bban_pattern"] = Regexp.new(specs["bban_pattern"])
|
24
|
+
specs["bban_pattern"] = Regexp.new("^" + specs["bban_pattern"] + "$")
|
25
25
|
end
|
26
26
|
IBANRules.new(rule_hash)
|
27
27
|
end
|
data/lib/iban-tools/rules.yml
CHANGED
@@ -1,242 +1,282 @@
|
|
1
1
|
# Data from http://www.tbg5-finance.org/?ibandocs.shtml/
|
2
2
|
|
3
|
-
|
3
|
+
'AD':
|
4
4
|
# Andorra
|
5
5
|
length: 24
|
6
|
-
bban_pattern:
|
6
|
+
bban_pattern: '\d{8}[A-Z0-9]{12}'
|
7
7
|
|
8
|
-
|
8
|
+
'AE':
|
9
|
+
# United Arab Emirates
|
10
|
+
length: 23
|
11
|
+
bban_pattern: '\d{19}'
|
12
|
+
|
13
|
+
'AL':
|
9
14
|
# Albania
|
10
15
|
length: 28
|
11
|
-
bban_pattern:
|
16
|
+
bban_pattern: '\d{8}[A-Z0-9]{16}'
|
12
17
|
|
13
|
-
|
18
|
+
'AT':
|
14
19
|
# Austria
|
15
20
|
length: 20
|
16
|
-
bban_pattern:
|
21
|
+
bban_pattern: '\d{16}'
|
17
22
|
|
18
|
-
|
23
|
+
'BA':
|
19
24
|
# Bosnia
|
20
25
|
length: 20
|
21
|
-
bban_pattern:
|
26
|
+
bban_pattern: '\d{16}'
|
22
27
|
|
23
|
-
|
28
|
+
'BE':
|
24
29
|
# Belgium
|
25
30
|
length: 16
|
26
|
-
bban_pattern:
|
31
|
+
bban_pattern: '\d{12}'
|
27
32
|
|
28
|
-
|
33
|
+
'BG':
|
29
34
|
# Bulgaria
|
30
35
|
length: 22
|
31
|
-
bban_pattern:
|
36
|
+
bban_pattern: '[A-Z]{4}\d{6}[A-Z0-9]{8}'
|
37
|
+
|
38
|
+
'BH':
|
39
|
+
# Bahrain
|
40
|
+
length: 22
|
41
|
+
bban_pattern: '[A-Z]{4}[A-Z0-9]{14}'
|
32
42
|
|
33
|
-
|
43
|
+
'CH':
|
34
44
|
# Switzerland
|
35
45
|
length: 21
|
36
|
-
bban_pattern:
|
46
|
+
bban_pattern: '\d{5}[A-Z0-9]{12}'
|
37
47
|
|
38
|
-
|
48
|
+
'CY':
|
39
49
|
# Cyprus
|
40
50
|
length: 28
|
41
|
-
bban_pattern:
|
51
|
+
bban_pattern: '\d{8}[A-Z0-9]{16}'
|
42
52
|
|
43
|
-
|
53
|
+
'CZ':
|
44
54
|
# Czech Republic
|
45
55
|
length: 24
|
46
|
-
bban_pattern:
|
56
|
+
bban_pattern: '\d{20}'
|
47
57
|
|
48
|
-
|
58
|
+
'DE':
|
49
59
|
# Germany
|
50
60
|
length: 22
|
51
|
-
bban_pattern:
|
61
|
+
bban_pattern: '\d{18}'
|
52
62
|
|
53
|
-
|
63
|
+
'DK':
|
54
64
|
# Denmark
|
55
65
|
length: 18
|
56
|
-
bban_pattern:
|
66
|
+
bban_pattern: '\d{14}'
|
57
67
|
|
58
|
-
|
68
|
+
'DO':
|
69
|
+
# Dominican Republic
|
70
|
+
length: 28
|
71
|
+
bban_pattern: '[A-Z]{4}\d{20}'
|
72
|
+
|
73
|
+
'EE':
|
59
74
|
# Estonia
|
60
75
|
length: 20
|
61
|
-
bban_pattern:
|
76
|
+
bban_pattern: '\d{16}'
|
62
77
|
|
63
|
-
|
78
|
+
'ES':
|
64
79
|
# Spain
|
65
80
|
length: 24
|
66
|
-
bban_pattern:
|
81
|
+
bban_pattern: '\d{20}'
|
67
82
|
|
68
|
-
|
83
|
+
'FI':
|
69
84
|
# Finland
|
70
85
|
length: 18
|
71
|
-
bban_pattern:
|
86
|
+
bban_pattern: '\d{14}'
|
72
87
|
|
73
|
-
|
88
|
+
'FO':
|
74
89
|
# Faroe Islands
|
75
90
|
length: 18
|
76
|
-
bban_pattern:
|
91
|
+
bban_pattern: '\d{14}'
|
77
92
|
|
78
|
-
|
93
|
+
'FR':
|
79
94
|
# France
|
80
95
|
length: 27
|
81
|
-
bban_pattern:
|
96
|
+
bban_pattern: '\d{10}[A-Z0-9]{11}\d{2}'
|
82
97
|
|
83
|
-
|
98
|
+
'GB':
|
84
99
|
# United Kingdom
|
85
100
|
length: 22
|
86
|
-
bban_pattern:
|
101
|
+
bban_pattern: '[A-Z]{4}\d{14}'
|
102
|
+
|
103
|
+
'GE':
|
104
|
+
# Georgia
|
105
|
+
length: 22
|
106
|
+
bban_pattern: '[A-Z]{2}\d{16}'
|
87
107
|
|
88
|
-
|
108
|
+
'GI':
|
89
109
|
# Gibraltar
|
90
110
|
length: 23
|
91
|
-
bban_pattern:
|
111
|
+
bban_pattern: '[A-Z]{4}[A-Z0-9]{15}'
|
92
112
|
|
93
|
-
|
113
|
+
'GL':
|
94
114
|
# Greenland
|
95
115
|
length: 18
|
96
|
-
bban_pattern:
|
116
|
+
bban_pattern: '\d{14}'
|
97
117
|
|
98
|
-
|
118
|
+
'GR':
|
99
119
|
# Greece
|
100
120
|
length: 27
|
101
|
-
bban_pattern:
|
121
|
+
bban_pattern: '\d{7}[A-Z0-9]{16}'
|
102
122
|
|
103
|
-
|
123
|
+
'HR':
|
104
124
|
# Croatia
|
105
125
|
length: 21
|
106
|
-
bban_pattern:
|
126
|
+
bban_pattern: '\d{17}'
|
107
127
|
|
108
|
-
|
128
|
+
'HU':
|
109
129
|
# Hungary
|
110
130
|
length: 28
|
111
|
-
bban_pattern:
|
131
|
+
bban_pattern: '\d{24}'
|
112
132
|
|
113
|
-
|
133
|
+
'IE':
|
114
134
|
# Ireland
|
115
135
|
length: 22
|
116
|
-
bban_pattern:
|
136
|
+
bban_pattern: '[A-Z]{4}\d{14}'
|
117
137
|
|
118
|
-
|
138
|
+
'IL':
|
119
139
|
# Israel
|
120
140
|
length: 23
|
121
|
-
bban_pattern:
|
141
|
+
bban_pattern: '\d{19}'
|
122
142
|
|
123
|
-
|
143
|
+
'IS':
|
124
144
|
# Iceland
|
125
145
|
length: 26
|
126
|
-
bban_pattern:
|
146
|
+
bban_pattern: '\d{22}'
|
127
147
|
|
128
|
-
|
148
|
+
'IT':
|
129
149
|
# Italy
|
130
150
|
length: 27
|
131
|
-
bban_pattern:
|
151
|
+
bban_pattern: '[A-Z]\d{10}[A-Z0-9]{12}'
|
132
152
|
|
133
|
-
|
153
|
+
'KW':
|
154
|
+
# Kuwait
|
155
|
+
length: 30
|
156
|
+
bban_pattern: '[A-Z]{4}\d{22}'
|
157
|
+
|
158
|
+
'KZ':
|
159
|
+
# Kazakhstan
|
160
|
+
length: 20
|
161
|
+
bban_pattern: '\d{3}[A-Z]{3}\d{10}'
|
162
|
+
|
163
|
+
'LB':
|
164
|
+
# Lebanon
|
165
|
+
length: 28
|
166
|
+
bban_pattern: '\d{4}[A-Z0-9]{20}'
|
167
|
+
|
168
|
+
'LI':
|
134
169
|
# Liechtenstein
|
135
170
|
length: 21
|
136
|
-
bban_pattern:
|
171
|
+
bban_pattern: '\d{5}[A-Z0-9]{12}'
|
137
172
|
|
138
|
-
|
173
|
+
'LT':
|
139
174
|
# Lithuania
|
140
175
|
length: 20
|
141
|
-
bban_pattern:
|
176
|
+
bban_pattern: '\d{16}'
|
142
177
|
|
143
|
-
|
178
|
+
'LU':
|
144
179
|
# Luxembourg
|
145
180
|
length: 20
|
146
|
-
bban_pattern:
|
181
|
+
bban_pattern: '\d{3}[A-Z0-9]{13}'
|
147
182
|
|
148
|
-
|
183
|
+
'LV':
|
149
184
|
# Latvia
|
150
185
|
length: 21
|
151
|
-
bban_pattern:
|
186
|
+
bban_pattern: '[A-Z]{4}[A-Z0-9]{13}'
|
152
187
|
|
153
|
-
|
188
|
+
'MC':
|
154
189
|
# Monaco
|
155
190
|
length: 27
|
156
|
-
bban_pattern:
|
191
|
+
bban_pattern: '\d{10}[A-Z0-9]{11}\d{2}'
|
157
192
|
|
158
|
-
|
193
|
+
'ME':
|
159
194
|
# Montenegro
|
160
195
|
length: 22
|
161
|
-
bban_pattern:
|
196
|
+
bban_pattern: '\d{18}'
|
162
197
|
|
163
|
-
|
198
|
+
'MK':
|
164
199
|
# Macedonia
|
165
200
|
length: 19
|
166
|
-
bban_pattern:
|
201
|
+
bban_pattern: '\d{3}[A-Z0-9]{10}\d{2}'
|
202
|
+
|
203
|
+
'MR':
|
204
|
+
# Mauritania
|
205
|
+
length: 27
|
206
|
+
bban_pattern: '\d{23}'
|
167
207
|
|
168
|
-
|
208
|
+
'MT':
|
169
209
|
# Malta
|
170
210
|
length: 31
|
171
|
-
bban_pattern:
|
211
|
+
bban_pattern: '[A-Z]{4}\d{5}[A-Z0-9]{18}'
|
172
212
|
|
173
|
-
|
213
|
+
'MU':
|
174
214
|
# Mauritius
|
175
215
|
length: 30
|
176
|
-
bban_pattern:
|
216
|
+
bban_pattern: '[A-Z]{4}\d{19}[A-Z]{3}'
|
177
217
|
|
178
|
-
|
218
|
+
'NL':
|
179
219
|
# Netherlands
|
180
220
|
length: 18
|
181
|
-
bban_pattern:
|
221
|
+
bban_pattern: '[A-Z]{4}\d{10}'
|
182
222
|
|
183
|
-
|
223
|
+
'NO':
|
184
224
|
# Norway
|
185
225
|
length: 15
|
186
|
-
bban_pattern:
|
226
|
+
bban_pattern: '\d{11}'
|
187
227
|
|
188
|
-
|
228
|
+
'PL':
|
189
229
|
# Poland
|
190
230
|
length: 28
|
191
|
-
bban_pattern:
|
231
|
+
bban_pattern: '\d{8}[A-Z0-9]{16}'
|
192
232
|
|
193
|
-
|
233
|
+
'PT':
|
194
234
|
# Portugal
|
195
235
|
length: 25
|
196
|
-
bban_pattern:
|
236
|
+
bban_pattern: '\d{21}'
|
197
237
|
|
198
|
-
|
238
|
+
'RO':
|
199
239
|
# Romania
|
200
240
|
length: 24
|
201
|
-
bban_pattern:
|
241
|
+
bban_pattern: '[A-Z]{4}[A-Z0-9]{16}'
|
202
242
|
|
203
|
-
|
243
|
+
'RS':
|
204
244
|
# Serbia
|
205
245
|
length: 22
|
206
|
-
bban_pattern:
|
246
|
+
bban_pattern: '\d{18}'
|
207
247
|
|
208
|
-
|
248
|
+
'SA':
|
209
249
|
# Saudi Arabia
|
210
250
|
length: 24
|
211
|
-
bban_pattern:
|
251
|
+
bban_pattern: '\d{2}[A-Z0-9]{18}'
|
212
252
|
|
213
|
-
|
253
|
+
'SE':
|
214
254
|
# Sweden
|
215
255
|
length: 24
|
216
|
-
bban_pattern:
|
256
|
+
bban_pattern: '\d{20}'
|
217
257
|
|
218
|
-
|
258
|
+
'SI':
|
219
259
|
# Slovenia
|
220
260
|
length: 19
|
221
|
-
bban_pattern:
|
261
|
+
bban_pattern: '\d{15}'
|
222
262
|
|
223
|
-
|
263
|
+
'SK':
|
224
264
|
# Slovakia
|
225
265
|
length: 24
|
226
|
-
bban_pattern:
|
266
|
+
bban_pattern: '\d{20}'
|
227
267
|
|
228
|
-
|
268
|
+
'SM':
|
229
269
|
# San Marino
|
230
270
|
length: 27
|
231
|
-
bban_pattern:
|
271
|
+
bban_pattern: '[A-Z]\d{10}[A-Z0-9]{12}'
|
232
272
|
|
233
|
-
|
273
|
+
'TN':
|
234
274
|
# Tunisia
|
235
275
|
length: 24
|
236
|
-
bban_pattern:
|
276
|
+
bban_pattern: '\d{20}'
|
237
277
|
|
238
|
-
|
278
|
+
'TR':
|
239
279
|
# Turkey
|
240
280
|
length: 26
|
241
|
-
bban_pattern:
|
281
|
+
bban_pattern: '\d{5}[A-Z0-9]{17}'
|
242
282
|
|
metadata
CHANGED
@@ -1,60 +1,53 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: iban-tools
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.8
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
|
-
authors:
|
7
|
+
authors:
|
7
8
|
- Iulian Dogariu
|
9
|
+
- Tor Erik Linnerud
|
8
10
|
autorequire:
|
9
11
|
bindir: bin
|
10
12
|
cert_chain: []
|
11
|
-
|
12
|
-
date: 2009-11-05 00:00:00 +00:00
|
13
|
-
default_executable:
|
13
|
+
date: 2012-02-22 00:00:00.000000000 Z
|
14
14
|
dependencies: []
|
15
|
-
|
16
15
|
description: Validates IBAN account numbers
|
17
|
-
email:
|
16
|
+
email:
|
18
17
|
- code@iuliandogariu.com
|
18
|
+
- tor@alphasights.com
|
19
19
|
executables: []
|
20
|
-
|
21
20
|
extensions: []
|
22
|
-
|
23
21
|
extra_rdoc_files: []
|
24
|
-
|
25
|
-
files:
|
22
|
+
files:
|
26
23
|
- README.md
|
27
24
|
- lib/iban-tools.rb
|
28
25
|
- lib/iban-tools/iban.rb
|
29
26
|
- lib/iban-tools/iban_rules.rb
|
30
27
|
- lib/iban-tools/rules.yml
|
31
|
-
has_rdoc: true
|
32
28
|
homepage:
|
33
29
|
licenses: []
|
34
|
-
|
35
30
|
post_install_message:
|
36
31
|
rdoc_options: []
|
37
|
-
|
38
|
-
require_paths:
|
32
|
+
require_paths:
|
39
33
|
- lib
|
40
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
requirements:
|
34
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
35
|
+
none: false
|
36
|
+
requirements:
|
37
|
+
- - ! '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
requirements:
|
53
47
|
- none
|
54
48
|
rubyforge_project:
|
55
|
-
rubygems_version: 1.
|
49
|
+
rubygems_version: 1.8.11
|
56
50
|
signing_key:
|
57
51
|
specification_version: 3
|
58
52
|
summary: IBAN validator
|
59
53
|
test_files: []
|
60
|
-
|