iso-iban 0.0.1 → 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 +4 -4
- data/iso-iban.gemspec +1 -1
- data/lib/iso/iban.rb +10 -4
- data/lib/iso/iban/specification.rb +19 -1
- data/lib/iso/iban/version.rb +1 -1
- data/test/unit/lib/iso/iban.rb +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1331caf363e5c9959e34a85b95c69a112e9b9e52
|
4
|
+
data.tar.gz: 86451b8eeb5fd428501f250cf442ba49aacc3e65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b84ad4b9a52ffb2b1c644237f3ef462f0003746ef9ce1503039df28f46a1c52518e741f8d6335f5439503821b9d3ffeca951e0b42a13077fdf0ca07eab727a88
|
7
|
+
data.tar.gz: abc912af4577970c0708822751d206ba0b097d744290a6c13972f90e2b8837f47ae37655020db96ea93270a49bdcc199249e14a9b7f30cbf40018be075d4f8c9
|
data/iso-iban.gemspec
CHANGED
data/lib/iso/iban.rb
CHANGED
@@ -37,7 +37,7 @@ module ISO
|
|
37
37
|
# Bank identifier: The identifier that uniquely identifies the financial
|
38
38
|
# institution and, when appropriate, the branch of that financial institution
|
39
39
|
# servicing an account
|
40
|
-
#
|
40
|
+
#
|
41
41
|
# `In this registry, the branch identifier format is shown specifically, when
|
42
42
|
# present.`
|
43
43
|
#
|
@@ -84,11 +84,17 @@ module ISO
|
|
84
84
|
elsif ENV['IBAN_SPECIFICATIONS'] then
|
85
85
|
spec_file = ENV['IBAN_SPECIFICATIONS']
|
86
86
|
else
|
87
|
-
spec_file = File.expand_path('
|
88
|
-
|
87
|
+
spec_file = File.expand_path('../../../data/iso-iban/specs.yaml', __FILE__)
|
88
|
+
if !File.file?(spec_file) && defined?(Gem) && Gem.datadir('iso-iban')
|
89
|
+
spec_file = Gem.datadir('iso-iban')+'/specs.yaml'
|
90
|
+
end
|
89
91
|
end
|
90
92
|
|
91
|
-
|
93
|
+
if spec_file && File.file?(spec_file)
|
94
|
+
@specifications = ISO::IBAN::Specification.load_yaml(spec_file)
|
95
|
+
else
|
96
|
+
raise "Could not load IBAN specifications, no specs file found."
|
97
|
+
end
|
92
98
|
|
93
99
|
self
|
94
100
|
end
|
@@ -105,7 +105,25 @@ module ISO
|
|
105
105
|
|
106
106
|
# @return [Array<Integer>] An array with the lengths of all components.
|
107
107
|
def component_lengths
|
108
|
-
|
108
|
+
[bank_code_length, branch_code_length, account_code_lenght].tap { |lengths| lengths.delete(0) }
|
109
|
+
end
|
110
|
+
|
111
|
+
# @return [Fixnum]
|
112
|
+
# The length of the bank code in the IBAN, 0 if the IBAN has no bank code.
|
113
|
+
def bank_code_length
|
114
|
+
@bank_position_from && @bank_position_to ? @bank_position_to-@bank_position_from+1 : 0
|
115
|
+
end
|
116
|
+
|
117
|
+
# @return [Fixnum]
|
118
|
+
# The length of the bank code in the IBAN, 0 if the IBAN has no branch code.
|
119
|
+
def branch_code_length
|
120
|
+
@branch_position_from && @branch_position_to ? @branch_position_to-@branch_position_from+1 : 0
|
121
|
+
end
|
122
|
+
|
123
|
+
# @return [Fixnum]
|
124
|
+
# The length of the account code in the IBAN.
|
125
|
+
def account_code_lenght
|
126
|
+
bban_length-bank_code_length-branch_code_length
|
109
127
|
end
|
110
128
|
|
111
129
|
# @return [Array] An array with the Specification properties. Used for serialization.
|
data/lib/iso/iban/version.rb
CHANGED
data/test/unit/lib/iso/iban.rb
CHANGED
@@ -7,6 +7,12 @@ suite "ISO::IBAN" do
|
|
7
7
|
ISO::IBAN.instance_variable_set(:@specifications, {'CH' => ISO::IBAN::Specification.new("Switzerland", "CH", "CH2!n5!n12!c", 21, "5!n12!c", 17, 4, 8, nil, nil)})
|
8
8
|
end
|
9
9
|
|
10
|
+
test 'ISO::IBAN::generate problem, TODO' do
|
11
|
+
ISO::IBAN.instance_variable_set(:@specifications, {'BG' => ISO::IBAN::Specification.new("Bulgaria", "BG", "BG2!n4!a4!n2!n8!c", 22, "4!a4!n2!n8!c", 18, 4, 7, 8, 11)})
|
12
|
+
assert ISO::IBAN.generate('BG', 'AAAA', '2', 'C').valid? # this works now
|
13
|
+
assert ISO::IBAN.generate('BG', 'A', '2', 'C').valid? # this still fails, because ISO::IBAN::generate can't pad 'a' format fields
|
14
|
+
end
|
15
|
+
|
10
16
|
test 'ISO::IBAN::load_specifications' do
|
11
17
|
reset_test_files
|
12
18
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iso-iban
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Rusterholz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |-
|
14
14
|
ISO::IBAN implements IBAN (International Bank Account Number) specification as per ISO 13616-1.
|