ibandit 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +17 -0
- data/CHANGELOG.md +4 -0
- data/README.md +10 -1
- data/bin/build_structure_file.rb +3 -3
- data/lib/ibandit/check_digit.rb +2 -1
- data/lib/ibandit/iban_builder.rb +3 -3
- data/lib/ibandit/version.rb +1 -1
- data/spec/ibandit/check_digit_spec.rb +8 -0
- metadata +3 -3
- data/circle.yml +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb2005426e8eca7ec2cf398a060fe361bb699d82
|
4
|
+
data.tar.gz: 9340e8905dbf91ea90e83fb09c2fa14e53ccf35f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a4bde497c40a9ca0aad45e89edbaae721fb72e60dcd023fbf1782c4a94308dbe0bb592d2fd846dc88568b2ce65f64f701050e25397efffa990b6386bdd7527c
|
7
|
+
data.tar.gz: 6a0ff40c72b3db4ba8a6606994cd172792786d91bd17aca2adf708722e01ff51ce0c66151ac0739a68c8cb17e4bad9898efb9148610a4f68eb685168b830b782
|
data/.travis.yml
ADDED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
|
1
|
+
Ibandit [![Build Status](https://travis-ci.org/gocardless/ibandit.svg?branch=master)](https://travis-ci.org/gocardless/ibandit)
|
2
|
+
=======
|
2
3
|
|
3
4
|
Ibandit is a Ruby library for manipulating and validating
|
4
5
|
[IBANs](http://en.wikipedia.org/wiki/International_Bank_Account_Number). It
|
@@ -301,3 +302,11 @@ iban.iban # => "SM88X0542811101000000123456"
|
|
301
302
|
```
|
302
303
|
|
303
304
|
Support for Greece and Malta is coming soon.
|
305
|
+
|
306
|
+
## Other libraries
|
307
|
+
|
308
|
+
Another gem, [iban-tools](https://github.com/alphasights/iban-tools), also
|
309
|
+
exists and is an excellent choice if you only require basic IBAN validation.
|
310
|
+
We built Ibandit because iban-tools doesn't provide a comprehensive, consistent
|
311
|
+
interface for the construction and deconstruction of IBANs into national
|
312
|
+
details.
|
data/bin/build_structure_file.rb
CHANGED
@@ -54,9 +54,9 @@ end
|
|
54
54
|
|
55
55
|
def convert_swift_convention(swift_string)
|
56
56
|
swift_string.gsub(/(\d+)!([nac])/, '\2{\1}').
|
57
|
-
|
58
|
-
|
59
|
-
|
57
|
+
tr('n', '\d').
|
58
|
+
tr('a', '[A-Z]').
|
59
|
+
tr('c', '[A-Z0-9]')
|
60
60
|
end
|
61
61
|
|
62
62
|
def merge_structures(structures, additions)
|
data/lib/ibandit/check_digit.rb
CHANGED
@@ -20,7 +20,8 @@ module Ibandit
|
|
20
20
|
# digits are used in the 1st and 2nd digits of local Spanish
|
21
21
|
# account numbers.
|
22
22
|
def self.spanish(string)
|
23
|
-
|
23
|
+
padded_string = string.rjust(10, '0')
|
24
|
+
scaled_values = padded_string.chars.map.with_index do |digit, index|
|
24
25
|
unless digit.to_i.to_s == digit
|
25
26
|
raise InvalidCharacterError,
|
26
27
|
"Unexpected non-numeric character '#{digit}'"
|
data/lib/ibandit/iban_builder.rb
CHANGED
@@ -65,7 +65,7 @@ module Ibandit
|
|
65
65
|
# numbers and the IBAN structure file includes them in its definition of
|
66
66
|
# the account number. As a result, this method ignores all arguments
|
67
67
|
# other than the account number.
|
68
|
-
opts[:account_number].
|
68
|
+
opts[:account_number].tr('-', '')
|
69
69
|
end
|
70
70
|
|
71
71
|
def self.build_cy_bban(opts)
|
@@ -192,7 +192,7 @@ module Ibandit
|
|
192
192
|
opts[:account_number]
|
193
193
|
].join
|
194
194
|
else
|
195
|
-
opts[:account_number].
|
195
|
+
opts[:account_number].tr('-', '')
|
196
196
|
end
|
197
197
|
end
|
198
198
|
|
@@ -477,7 +477,7 @@ module Ibandit
|
|
477
477
|
else
|
478
478
|
[
|
479
479
|
opts[:bank_code],
|
480
|
-
opts[:account_number].
|
480
|
+
opts[:account_number].tr('-', '').rjust(16, '0')
|
481
481
|
].join
|
482
482
|
end
|
483
483
|
end
|
data/lib/ibandit/version.rb
CHANGED
@@ -29,6 +29,14 @@ describe Ibandit::CheckDigit do
|
|
29
29
|
expect { subject }.to raise_error(Ibandit::InvalidCharacterError)
|
30
30
|
end
|
31
31
|
end
|
32
|
+
|
33
|
+
context 'with a string that is fewer than 10 characters' do
|
34
|
+
let(:account_number) { '20386010' }
|
35
|
+
|
36
|
+
it 'zero-pads the string to get the correct check digit' do
|
37
|
+
expect(subject).to eq('5')
|
38
|
+
end
|
39
|
+
end
|
32
40
|
end
|
33
41
|
|
34
42
|
describe '.lund' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ibandit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Grey Baker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -92,13 +92,13 @@ files:
|
|
92
92
|
- .gitignore
|
93
93
|
- .rubocop.yml
|
94
94
|
- .rubocop_todo.yml
|
95
|
+
- .travis.yml
|
95
96
|
- CHANGELOG.md
|
96
97
|
- Gemfile
|
97
98
|
- LICENSE
|
98
99
|
- README.md
|
99
100
|
- TODO.md
|
100
101
|
- bin/build_structure_file.rb
|
101
|
-
- circle.yml
|
102
102
|
- data/IBANSTRUCTURE.xml
|
103
103
|
- data/IBAN_Registry.txt
|
104
104
|
- data/structure_additions.yml
|
data/circle.yml
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
machine:
|
2
|
-
ruby:
|
3
|
-
version: 2.0.0-p353
|
4
|
-
|
5
|
-
test:
|
6
|
-
pre:
|
7
|
-
- bundle exec rubocop:
|
8
|
-
parallel: true
|
9
|
-
files:
|
10
|
-
- config.ru
|
11
|
-
- Rakefile
|
12
|
-
- app/**/*.rb
|
13
|
-
- lib/**/*.rb
|
14
|
-
- spec/**/*.rb
|
15
|
-
override:
|
16
|
-
- bundle exec rspec:
|
17
|
-
parallel: true
|
18
|
-
files:
|
19
|
-
- spec/**/*_spec.rb
|