gpav 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e08964366d2c1abf76300d070c5eb86f8e8ae4f6
4
- data.tar.gz: 87d1d45be1c9fefca1df71176b16e1113188a116
3
+ metadata.gz: 85c6b99fdbdc0ff596ef317711fe1ec4cf314ddc
4
+ data.tar.gz: 31c9e8ca90d8947920fd0d622c441b5dcd0cec7c
5
5
  SHA512:
6
- metadata.gz: 794868c9f71fece0481f044c49ebf46672337f2d8e29dcea5a81ab6ad522c17f448d0058d11446f328d49659ff5ef45aafe217e237c39b85f40c9f0314749e2f
7
- data.tar.gz: 2eb1f981f98ce2c0d2b77972a282b1f1bde961a0dc2bc0942d36b29a9690f2e1044375e63a6df331b467ce1072836eeb6e17e84225ccd8f7d97e4fb5cb79e9ed
6
+ metadata.gz: dc4fec3605ca9d36ec0dcd9d4f898166be01920f4c36aa06f26145097f81c1534bec1a946c568a90014eb15d72dd40ff277309941239153dfd18df1a3059866c
7
+ data.tar.gz: 69476c9be1f01d8582bbf9e79f9ba965d3b879c90feea090b95018d1aefc0c722e70d551d2ae9dd9517594ecd19993064ad9e305bedaeb5441ba65774cbdc195
@@ -1,4 +1,7 @@
1
1
  require 'validators/afm'
2
2
  require 'validators/amka'
3
3
  require 'validators/cheque'
4
- require 'validators/iban'
4
+ require 'validators/iban'
5
+ module Gpav
6
+
7
+ end
@@ -1,25 +1,29 @@
1
- class Afm
2
- def self.valid?(afm) #9 chars, string
1
+ module Gpav
2
+ module Validators
3
+ class Afm
4
+ def self.valid?(afm) #9 chars, string
3
5
 
4
- @afm = afm.to_s
6
+ @afm = afm.to_s
5
7
 
6
- return false if @afm.length != 9 # length == 9
7
- return false if not @afm =~ /\A[0-9]{9}\Z/ # only digits
8
- return false if @afm.to_i == 0 # do not allow all digits zero
8
+ return false if @afm.length != 9 # length == 9
9
+ return false if not @afm =~ /\A[0-9]{9}\Z/ # only digits
10
+ return false if @afm.to_i == 0 # do not allow all digits zero
9
11
 
10
- y = @afm[-1].to_i # rest / ninth digit
11
- s = 0 # runnning sum
12
- pow2 = 2 # 2 power cache
12
+ y = @afm[-1].to_i # rest / ninth digit
13
+ s = 0 # runnning sum
14
+ pow2 = 2 # 2 power cache
13
15
 
14
- 7.downto(0) do |i|
15
- s += pow2 * @afm[i].to_i
16
- pow2 = pow2 * 2
17
- end
16
+ 7.downto(0) do |i|
17
+ s += pow2 * @afm[i].to_i
18
+ pow2 = pow2 * 2
19
+ end
18
20
 
19
- s = s % 11
20
- s = 0 if s == 10
21
+ s = s % 11
22
+ s = 0 if s == 10
21
23
 
22
- return s == y
24
+ return s == y
23
25
 
26
+ end
27
+ end
24
28
  end
25
- end
29
+ end
@@ -1,18 +1,22 @@
1
- class Amka
1
+ module Gpav
2
+ module Validators
3
+ class Amka
2
4
 
3
- def self.valid?(amka) # 11 char string
5
+ def self.valid?(amka) # 11 char string
4
6
 
5
- @amka = amka.to_s
7
+ @amka = amka.to_s
6
8
 
7
- return false unless @amka.length == 11
8
- return false unless @amka =~ /\A[0-9]{11}\Z/
9
- return false if @amka.to_i == 0 # do not allow all digits zero
9
+ return false unless @amka.length == 11
10
+ return false unless @amka =~ /\A[0-9]{11}\Z/
11
+ return false if @amka.to_i == 0 # do not allow all digits zero
10
12
 
11
- @amka.each_char.with_index.inject(0) do |sum,(value,index)|
12
- v = value.to_i
13
- sum + v + (index.odd? ? (v - ( (v>4) ? 9 : 0)) : 0)
14
- end % 10 == 0
13
+ @amka.each_char.with_index.inject(0) do |sum, (value, index)|
14
+ v = value.to_i
15
+ sum + v + (index.odd? ? (v - ((v>4) ? 9 : 0)) : 0)
16
+ end % 10 == 0
15
17
 
16
- end
18
+ end
17
19
 
18
- end
20
+ end
21
+ end
22
+ end
@@ -1,40 +1,48 @@
1
- class Cheque
2
- attr_reader :number
1
+ module Gpav
2
+ module Validators
3
+ class Cheque
4
+ attr_reader :number
3
5
 
4
- def initialize( number )
5
- @number = number.to_s
6
- end
6
+ def initialize(number)
7
+ @number = number.to_s
8
+ end
7
9
 
8
- def check_digit
9
- i=9
10
- sum = 0
11
- @number.each_char{|c|
12
- sum += c.to_i*i
13
- i-=1
14
- }
15
- # return sum
16
- y = sum % 11
17
- result =
18
- case y
19
- when 1 then 0
20
- when 0 then 1
21
- else 11-y
10
+ def check_digit
11
+ i=9
12
+ sum = 0
13
+ @number.each_char { |c|
14
+ sum += c.to_i*i
15
+ i-=1
16
+ }
17
+ # return sum
18
+ y = sum % 11
19
+ result =
20
+ case y
21
+ when 1 then
22
+ 0
23
+ when 0 then
24
+ 1
25
+ else
26
+ 11-y
27
+ end
22
28
  end
23
- end
24
29
 
25
- def cheque_number
26
- @number + '-' + check_digit.to_s
27
- end
30
+ def cheque_number
31
+ @number + '-' + check_digit.to_s
32
+ end
33
+
34
+ def self.valid?(chequenumber)
28
35
 
29
- def self.valid?(chequenumber)
36
+ @chequenumber =chequenumber.to_s
30
37
 
31
- @chequenumber =chequenumber.to_s
38
+ return false unless @chequenumber.length == 10
39
+ return false if not @chequenumber =~ /\A[0-9]{8}-[0-9]\Z/
32
40
 
33
- return false unless @chequenumber.length == 10
34
- return false if not @chequenumber =~ /\A[0-9]{8}-[0-9]\Z/
41
+ @chequenumber[-1].to_i == Cheque.new(@chequenumber[0..7]).check_digit
35
42
 
36
- @chequenumber[-1].to_i == Cheque.new(@chequenumber[0..7]).check_digit
43
+ end
37
44
 
45
+ end
38
46
  end
39
47
 
40
48
  end
@@ -1,34 +1,39 @@
1
- class Iban
1
+ module Gpav
2
+ module Validators
3
+ class Iban
2
4
 
3
- def self.valid?(iban)
4
5
 
5
- @iban = iban.to_s
6
+ def self.valid?(iban)
6
7
 
7
- return false unless @iban.length == 27
8
- return false unless @iban =~ /\A[a-zA-Z]{2}[0-9]{25}\Z/
8
+ @iban = iban.to_s
9
9
 
10
+ return false unless @iban.length == 27
11
+ return false unless @iban =~ /\A[a-zA-Z]{2}[0-9]{25}\Z/
10
12
 
11
- # rotate 4
12
- #change letters to numbers: A=10 --> Z=35
13
- #divide with 97 mod == 1
14
13
 
15
- (@iban[4..27] + char_to_numbers(@iban[0]) + char_to_numbers(@iban[1]) + @iban[2..3]).to_i % 97 == 1
14
+ # rotate 4
15
+ #change letters to numbers: A=10 --> Z=35
16
+ #divide with 97 mod == 1
16
17
 
17
- end
18
+ (@iban[4..27] + char_to_numbers(@iban[0]) + char_to_numbers(@iban[1]) + @iban[2..3]).to_i % 97 == 1
18
19
 
19
- def self.char_to_numbers(char)
20
+ end
20
21
 
21
- # iban characters to number transformation table
22
- #
23
- # A=10 F=15 K=20 P=25 U=30 Z=35
24
- # B=11 G=16 L=21 Q=26 V=31
25
- # C=12 H=17 M=22 R=27 W=32
26
- # D=13 I=18 N=23 S=28 X=33
27
- # E=14 J=19 O=24 T=29 Y=34
28
- #
22
+ def self.char_to_numbers(char)
29
23
 
30
- (char.upcase.ord - 'a'.upcase.ord + 10).to_s
24
+ # iban characters to number transformation table
25
+ #
26
+ # A=10 F=15 K=20 P=25 U=30 Z=35
27
+ # B=11 G=16 L=21 Q=26 V=31
28
+ # C=12 H=17 M=22 R=27 W=32
29
+ # D=13 I=18 N=23 S=28 X=33
30
+ # E=14 J=19 O=24 T=29 Y=34
31
+ #
31
32
 
32
- end
33
+ (char.upcase.ord - 'a'.upcase.ord + 10).to_s
33
34
 
35
+ end
36
+
37
+ end
38
+ end
34
39
  end
@@ -1,41 +1,45 @@
1
1
  require 'minitest/autorun'
2
- require File.dirname(__FILE__) + '/../lib/validators/afm'
2
+ require File.expand_path(File.dirname(__FILE__)) + '/../lib/validators/afm'
3
+
4
+ class TestAfm < Minitest::Unit::TestCase
5
+ include Gpav::Validators
3
6
 
4
- class TestAfm < Minitest::Unit::TestCase
5
7
  def test_valid_afm_validation
6
- valid_afm = ['101676480','102676489','103676487']
7
- valid_afm.each do |a|
8
- assert Afm.valid?(a), "ΑΦΜ verification failed: #{a}"
9
- end
8
+ valid_afm = ['101676480', '102676489', '103676487']
9
+ valid_afm.each do |a|
10
+ assert Afm.valid?(a), "ΑΦΜ verification failed: #{a}"
11
+ end
10
12
  end
11
13
 
12
14
  def test_invalid_afm_validation
13
- invalid_afm = ['101676481','102676481','103676481','000000000' ]
14
- invalid_afm.each do |a|
15
- refute Afm.valid?(a), "Invalid ΑΦΜ wrong verification: #{a}"
16
- end
15
+ invalid_afm = ['101676481', '102676481', '103676481', '000000000']
16
+ invalid_afm.each do |a|
17
+ refute Afm.valid?(a), "Invalid ΑΦΜ wrong verification: #{a}"
18
+ end
17
19
  end
18
20
 
19
21
  def test_empty_afm
20
22
  refute Afm.valid?(""), 'Invalid ΑΦΜ wrong verification: ""'
21
23
  refute Afm.valid?(nil), 'Invalid ΑΦΜ wrong verification: nil'
22
24
  end
25
+
23
26
  def test_wrong_length_afm
24
- refute Afm.valid?('01676480'), 'Invalid ΑΦΜ wrong verification: less numbers'
25
- refute Afm.valid?('10167680'), 'Invalid ΑΦΜ wrong verification: less numbers'
26
- refute Afm.valid?('1016763480'), 'Invalid ΑΦΜ wrong verification: more numbers'
27
- refute Afm.valid?('1012676480'), 'Invalid ΑΦΜ wrong verification: more numbers'
28
- refute Afm.valid?('1016762480'), 'Invalid ΑΦΜ wrong verification: more numbers'
29
- refute Afm.valid?('1016764802'), 'Invalid ΑΦΜ wrong verification: more numbers'
30
- refute Afm.valid?('1101676480'), 'Invalid ΑΦΜ wrong verification: more numbers'
31
- refute Afm.valid?('101676480 '), 'Invalid ΑΦΜ wrong verification: with spaceses'
32
- refute Afm.valid?(' 101676480'), 'Invalid ΑΦΜ wrong verification: with spaceses'
27
+ refute Afm.valid?('01676480'), 'Invalid ΑΦΜ wrong verification: less numbers'
28
+ refute Afm.valid?('10167680'), 'Invalid ΑΦΜ wrong verification: less numbers'
29
+ refute Afm.valid?('1016763480'), 'Invalid ΑΦΜ wrong verification: more numbers'
30
+ refute Afm.valid?('1012676480'), 'Invalid ΑΦΜ wrong verification: more numbers'
31
+ refute Afm.valid?('1016762480'), 'Invalid ΑΦΜ wrong verification: more numbers'
32
+ refute Afm.valid?('1016764802'), 'Invalid ΑΦΜ wrong verification: more numbers'
33
+ refute Afm.valid?('1101676480'), 'Invalid ΑΦΜ wrong verification: more numbers'
34
+ refute Afm.valid?('101676480 '), 'Invalid ΑΦΜ wrong verification: with spaceses'
35
+ refute Afm.valid?(' 101676480'), 'Invalid ΑΦΜ wrong verification: with spaceses'
33
36
  end
37
+
34
38
  def test_includes_letters_afm
35
- refute Afm.valid?('10d676480'), 'Invalid ΑΦΜ wrong verification: with letters'
36
- refute Afm.valid?('101676s80'), 'Invalid ΑΦΜ wrong verification: with letters'
37
- refute Afm.valid?('10167648s'), 'Invalid ΑΦΜ wrong verification: with letters'
38
- refute Afm.valid?('a01676480'), 'Invalid ΑΦΜ wrong verification: with letters'
39
+ refute Afm.valid?('10d676480'), 'Invalid ΑΦΜ wrong verification: with letters'
40
+ refute Afm.valid?('101676s80'), 'Invalid ΑΦΜ wrong verification: with letters'
41
+ refute Afm.valid?('10167648s'), 'Invalid ΑΦΜ wrong verification: with letters'
42
+ refute Afm.valid?('a01676480'), 'Invalid ΑΦΜ wrong verification: with letters'
39
43
  end
40
44
 
41
45
 
@@ -1,41 +1,45 @@
1
1
  require 'minitest/autorun'
2
- require File.dirname(__FILE__) + '/../lib/validators/amka'
2
+ require File.expand_path(File.dirname(__FILE__)) + '/../lib/validators/amka'
3
+
4
+ class TestAmka < Minitest::Unit::TestCase
5
+ include Gpav::Validators
3
6
 
4
- class TestAmka < Minitest::Unit::TestCase
5
7
  def test_valid_amka_validation
6
- valid_amka = ['15067603256','16057602159','16067502233']
7
- valid_amka.each do |a|
8
- assert Amka.valid?(a), "ΑΜΚΑ verification failed: #{a}"
9
- end
8
+ valid_amka = ['15067603256', '16057602159', '16067502233']
9
+ valid_amka.each do |a|
10
+ assert Amka.valid?(a), "ΑΜΚΑ verification failed: #{a}"
11
+ end
10
12
  end
11
13
 
12
14
  def test_invalid_amka_validation
13
- invalid_amka = ['15067603253','16057602153','16067502232','00000000000' ]
14
- invalid_amka.each do |a|
15
- refute Amka.valid?(a), "Invalid ΑΜΚΑ wrong verification: #{a}"
16
- end
15
+ invalid_amka = ['15067603253', '16057602153', '16067502232', '00000000000']
16
+ invalid_amka.each do |a|
17
+ refute Amka.valid?(a), "Invalid ΑΜΚΑ wrong verification: #{a}"
18
+ end
17
19
  end
18
20
 
19
21
  def test_empty_amka
20
22
  refute Amka.valid?(""), 'Invalid ΑΜΚΑ wrong verification: ""'
21
23
  refute Amka.valid?(nil), 'Invalid ΑΜΚΑ wrong verification: nil'
22
24
  end
25
+
23
26
  def test_wrong_length_amka
24
- refute Amka.valid?('1506760325'), 'Invalid ΑΜΚΑ wrong verification: less numbers'
25
- refute Amka.valid?('5067603256'), 'Invalid ΑΜΚΑ wrong verification: less numbers'
26
- refute Amka.valid?('115067603256'), 'Invalid ΑΜΚΑ wrong verification: more numbers'
27
- refute Amka.valid?('125067603256'), 'Invalid ΑΜΚΑ wrong verification: more numbers'
28
- refute Amka.valid?('153067603256'), 'Invalid ΑΜΚΑ wrong verification: more numbers'
29
- refute Amka.valid?('150676032564'), 'Invalid ΑΜΚΑ wrong verification: more numbers'
30
- refute Amka.valid?('150a67603256'), 'Invalid ΑΜΚΑ wrong verification: more numbers'
31
- refute Amka.valid?('15067603256 '), 'Invalid ΑΜΚΑ wrong verification: with spaceses'
32
- refute Amka.valid?(' 15067603256'), 'Invalid ΑΜΚΑ wrong verification: with spaceses'
27
+ refute Amka.valid?('1506760325'), 'Invalid ΑΜΚΑ wrong verification: less numbers'
28
+ refute Amka.valid?('5067603256'), 'Invalid ΑΜΚΑ wrong verification: less numbers'
29
+ refute Amka.valid?('115067603256'), 'Invalid ΑΜΚΑ wrong verification: more numbers'
30
+ refute Amka.valid?('125067603256'), 'Invalid ΑΜΚΑ wrong verification: more numbers'
31
+ refute Amka.valid?('153067603256'), 'Invalid ΑΜΚΑ wrong verification: more numbers'
32
+ refute Amka.valid?('150676032564'), 'Invalid ΑΜΚΑ wrong verification: more numbers'
33
+ refute Amka.valid?('150a67603256'), 'Invalid ΑΜΚΑ wrong verification: more numbers'
34
+ refute Amka.valid?('15067603256 '), 'Invalid ΑΜΚΑ wrong verification: with spaceses'
35
+ refute Amka.valid?(' 15067603256'), 'Invalid ΑΜΚΑ wrong verification: with spaceses'
33
36
  end
37
+
34
38
  def test_includes_letters_amka
35
- refute Amka.valid?('15067a03256'), 'Invalid ΑΜΚΑ wrong verification: with letters'
36
- refute Amka.valid?('1506760s356'), 'Invalid ΑΜΚΑ wrong verification: with letters'
37
- refute Amka.valid?('1506760356s'), 'Invalid ΑΜΚΑ wrong verification: with letters'
38
- refute Amka.valid?('s1506760356'), 'Invalid ΑΜΚΑ wrong verification: with letters'
39
+ refute Amka.valid?('15067a03256'), 'Invalid ΑΜΚΑ wrong verification: with letters'
40
+ refute Amka.valid?('1506760s356'), 'Invalid ΑΜΚΑ wrong verification: with letters'
41
+ refute Amka.valid?('1506760356s'), 'Invalid ΑΜΚΑ wrong verification: with letters'
42
+ refute Amka.valid?('s1506760356'), 'Invalid ΑΜΚΑ wrong verification: with letters'
39
43
  end
40
44
 
41
45
 
@@ -1,41 +1,45 @@
1
1
  require 'minitest/autorun'
2
- require File.dirname(__FILE__) + '/../lib/validators/cheque'
2
+ require File.expand_path(File.dirname(__FILE__)) + '/../lib/validators/cheque'
3
+
4
+ class TestCheque < Minitest::Unit::TestCase
5
+ include Gpav::Validators
3
6
 
4
- class TestCheque < Minitest::Unit::TestCase
5
7
  def test_valid_cheque_validation
6
- valid_cheque = %w(72349701-0 72349702-8 72349703-6 72349704-4 72349705-2 72349706-1 72349707-9 72349708-7 72349709-5)
7
- valid_cheque.each do |a|
8
- assert Cheque.valid?(a), "Cheque verification failed: #{a}"
9
- end
8
+ valid_cheque = %w(72349701-0 72349702-8 72349703-6 72349704-4 72349705-2 72349706-1 72349707-9 72349708-7 72349709-5)
9
+ valid_cheque.each do |a|
10
+ assert Cheque.valid?(a), "Cheque verification failed: #{a}"
11
+ end
10
12
  end
11
13
 
12
14
  def test_invalid_cheque_validation
13
- invalid_cheque = %w(72349201-0 72339702-8 72349703-4 72345704-4 62349705-2 78349706-1 72349797-9 72049708-7 72049709-5 00000000-0)
14
- invalid_cheque.each do |a|
15
- refute Cheque.valid?(a), "Invalid Cheque wrong verification: #{a}"
16
- end
15
+ invalid_cheque = %w(72349201-0 72339702-8 72349703-4 72345704-4 62349705-2 78349706-1 72349797-9 72049708-7 72049709-5 00000000-0)
16
+ invalid_cheque.each do |a|
17
+ refute Cheque.valid?(a), "Invalid Cheque wrong verification: #{a}"
18
+ end
17
19
  end
18
20
 
19
21
  def test_empty_cheque
20
22
  refute Cheque.valid?(""), 'Invalid Cheque wrong verification: ""'
21
23
  refute Cheque.valid?(nil), 'Invalid Cheque wrong verification: nil'
22
24
  end
25
+
23
26
  def test_wrong_length_cheque
24
- refute Cheque.valid?('7234901-0'), 'Invalid Cheque wrong verification: less numbers'
25
- refute Cheque.valid?('2349701-0'), 'Invalid Cheque wrong verification: less numbers'
26
- refute Cheque.valid?('742349701-0'), 'Invalid Cheque wrong verification: more numbers'
27
- refute Cheque.valid?('72349701-05'), 'Invalid Cheque wrong verification: more numbers'
28
- refute Cheque.valid?('723497015-0'), 'Invalid Cheque wrong verification: more numbers'
29
- refute Cheque.valid?('72349701--0'), 'Invalid Cheque wrong verification: more numbers'
30
- refute Cheque.valid?('723497015-0'), 'Invalid Cheque wrong verification: more numbers'
31
- refute Cheque.valid?('72349701-0 '), 'Invalid Cheque wrong verification: with spaceses'
32
- refute Cheque.valid?(' 72349701-0'), 'Invalid Cheque wrong verification: with spaceses'
27
+ refute Cheque.valid?('7234901-0'), 'Invalid Cheque wrong verification: less numbers'
28
+ refute Cheque.valid?('2349701-0'), 'Invalid Cheque wrong verification: less numbers'
29
+ refute Cheque.valid?('742349701-0'), 'Invalid Cheque wrong verification: more numbers'
30
+ refute Cheque.valid?('72349701-05'), 'Invalid Cheque wrong verification: more numbers'
31
+ refute Cheque.valid?('723497015-0'), 'Invalid Cheque wrong verification: more numbers'
32
+ refute Cheque.valid?('72349701--0'), 'Invalid Cheque wrong verification: more numbers'
33
+ refute Cheque.valid?('723497015-0'), 'Invalid Cheque wrong verification: more numbers'
34
+ refute Cheque.valid?('72349701-0 '), 'Invalid Cheque wrong verification: with spaceses'
35
+ refute Cheque.valid?(' 72349701-0'), 'Invalid Cheque wrong verification: with spaceses'
33
36
  end
37
+
34
38
  def test_includes_letters_cheque
35
- refute Cheque.valid?('72349701+0'), 'Invalid Cheque wrong verification: with letters'
36
- refute Cheque.valid?('72349701a0'), 'Invalid Cheque wrong verification: with letters'
37
- refute Cheque.valid?('7234s701-0'), 'Invalid Cheque wrong verification: with letters'
38
- refute Cheque.valid?('7a349701-0'), 'Invalid Cheque wrong verification: with letters'
39
+ refute Cheque.valid?('72349701+0'), 'Invalid Cheque wrong verification: with letters'
40
+ refute Cheque.valid?('72349701a0'), 'Invalid Cheque wrong verification: with letters'
41
+ refute Cheque.valid?('7234s701-0'), 'Invalid Cheque wrong verification: with letters'
42
+ refute Cheque.valid?('7a349701-0'), 'Invalid Cheque wrong verification: with letters'
39
43
  end
40
44
 
41
45
 
@@ -1,42 +1,46 @@
1
1
  require 'minitest/autorun'
2
- require File.dirname(__FILE__) + '/../lib/validators/iban'
2
+ require File.expand_path(File.dirname(__FILE__)) + '/../lib/validators/iban'
3
+
4
+ class TestIban < Minitest::Unit::TestCase
5
+ include Gpav::Validators
3
6
 
4
- class TestIban < Minitest::Unit::TestCase
5
7
  def test_valid_iban_validation
6
- valid_iban = %w(GR9401406010601002001000246 GR5401406010601002001000190 GR9101406010601002001000300 GR9001406010601002001000318 GR0701406010601002001001812)
7
- valid_iban.each do |a|
8
- assert Iban.valid?(a), "IBAN verification failed: #{a}"
9
- end
8
+ valid_iban = %w(GR9401406010601002001000246 GR5401406010601002001000190 GR9101406010601002001000300 GR9001406010601002001000318 GR0701406010601002001001812)
9
+ valid_iban.each do |a|
10
+ assert Iban.valid?(a), "IBAN verification failed: #{a}"
11
+ end
10
12
  end
11
13
 
12
14
  def test_invalid_iban_validation
13
- invalid_iban = %w(DR9401406010601002001000246 GF5401406010601002001000190 GR9101406010631002001000300 GR9001406010601002001400318 GR0701406010601002001001814)
14
- invalid_iban.each do |a|
15
- refute Iban.valid?(a), "Invalid IBAN wrong verification: #{a}"
16
- end
15
+ invalid_iban = %w(DR9401406010601002001000246 GF5401406010601002001000190 GR9101406010631002001000300 GR9001406010601002001400318 GR0701406010601002001001814)
16
+ invalid_iban.each do |a|
17
+ refute Iban.valid?(a), "Invalid IBAN wrong verification: #{a}"
18
+ end
17
19
  end
18
20
 
19
21
  def test_empty_iban
20
22
  refute Iban.valid?(""), 'Invalid IBAN wrong verification: ""'
21
23
  refute Iban.valid?(nil), 'Invalid IBAN wrong verification: nil'
22
24
  end
25
+
23
26
  def test_wrong_length_iban
24
- refute Iban.valid?('9401406010601002001000246'), 'Invalid IBAN wrong verification: less numbers'
25
- refute Iban.valid?('R9401406010601002001000246'), 'Invalid IBAN wrong verification: less numbers'
26
- refute Iban.valid?('GR940140601060100200100024'), 'Invalid IBAN wrong verification: less numbers'
27
- refute Iban.valid?('G2R9401406010601002001000246'), 'Invalid IBAN wrong verification: more numbers'
28
- refute Iban.valid?('GGR9401406010601002001000246'), 'Invalid IBAN wrong verification: more numbers'
29
- refute Iban.valid?('1GR9401406010601002001000246'), 'Invalid IBAN wrong verification: more numbers'
30
- refute Iban.valid?('GR94014060106010020021000246'), 'Invalid IBAN wrong verification: more numbers'
31
- refute Iban.valid?('GR94014060106010020010002462'), 'Invalid IBAN wrong verification: more numbers'
32
- refute Iban.valid?('GR9401406010601002001000246 '), 'Invalid IBAN wrong verification: with spaceses'
33
- refute Iban.valid?(' GR9401406010601002001000246'), 'Invalid IBAN wrong verification: with spaceses'
27
+ refute Iban.valid?('9401406010601002001000246'), 'Invalid IBAN wrong verification: less numbers'
28
+ refute Iban.valid?('R9401406010601002001000246'), 'Invalid IBAN wrong verification: less numbers'
29
+ refute Iban.valid?('GR940140601060100200100024'), 'Invalid IBAN wrong verification: less numbers'
30
+ refute Iban.valid?('G2R9401406010601002001000246'), 'Invalid IBAN wrong verification: more numbers'
31
+ refute Iban.valid?('GGR9401406010601002001000246'), 'Invalid IBAN wrong verification: more numbers'
32
+ refute Iban.valid?('1GR9401406010601002001000246'), 'Invalid IBAN wrong verification: more numbers'
33
+ refute Iban.valid?('GR94014060106010020021000246'), 'Invalid IBAN wrong verification: more numbers'
34
+ refute Iban.valid?('GR94014060106010020010002462'), 'Invalid IBAN wrong verification: more numbers'
35
+ refute Iban.valid?('GR9401406010601002001000246 '), 'Invalid IBAN wrong verification: with spaceses'
36
+ refute Iban.valid?(' GR9401406010601002001000246'), 'Invalid IBAN wrong verification: with spaceses'
34
37
  end
38
+
35
39
  def test_includes_letters_iban
36
- refute Iban.valid?('GR94014060106010F2001000246'), 'Invalid IBAN wrong verification: with letters'
37
- refute Iban.valid?('9401406010601002001000246GR'), 'Invalid IBAN wrong verification: with letters'
38
- refute Iban.valid?('01406010601002001000246GR94'), 'Invalid IBAN wrong verification: with letters'
39
- refute Iban.valid?('GRR901406010601002001000246'), 'Invalid IBAN wrong verification: with letters'
40
+ refute Iban.valid?('GR94014060106010F2001000246'), 'Invalid IBAN wrong verification: with letters'
41
+ refute Iban.valid?('9401406010601002001000246GR'), 'Invalid IBAN wrong verification: with letters'
42
+ refute Iban.valid?('01406010601002001000246GR94'), 'Invalid IBAN wrong verification: with letters'
43
+ refute Iban.valid?('GRR901406010601002001000246'), 'Invalid IBAN wrong verification: with letters'
40
44
  end
41
45
 
42
46
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gpav
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michail Pantelelis