gpav 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 71711ea2f57aa05aa924fbf68eb1dd07fd005a0d
4
- data.tar.gz: 7ce057f6ee4de9e60ef945bc6b4d1575c52fb277
3
+ metadata.gz: e08964366d2c1abf76300d070c5eb86f8e8ae4f6
4
+ data.tar.gz: 87d1d45be1c9fefca1df71176b16e1113188a116
5
5
  SHA512:
6
- metadata.gz: 0d40f3972634be5c29a18a71cd3a32c6d49dbed8777684153e6c410acebc47aa4f24dccb658dbf4724b5d47c522b88313b07019b0e61a513ce474adecb05ad85
7
- data.tar.gz: cc3ef5583b0016f64428441bf1478bc3bb24bab6f7a3680a84ef7a6a9fe28081e94c3845725a94c81875d19548a0286e2bc9d401327a58931dd27c4fc21a3fbf
6
+ metadata.gz: 794868c9f71fece0481f044c49ebf46672337f2d8e29dcea5a81ab6ad522c17f448d0058d11446f328d49659ff5ef45aafe217e237c39b85f40c9f0314749e2f
7
+ data.tar.gz: 2eb1f981f98ce2c0d2b77972a282b1f1bde961a0dc2bc0942d36b29a9690f2e1044375e63a6df331b467ce1072836eeb6e17e84225ccd8f7d97e4fb5cb79e9ed
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 mpantel
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,2 @@
1
+ # gpav
2
+ Greek Public Administration Validators
@@ -0,0 +1,8 @@
1
+ require 'rake/testtask'
2
+
3
+ Rake::TestTask.new do |t|
4
+ t.libs << 'test'
5
+ end
6
+
7
+ desc "Run tests"
8
+ task :default => :test
@@ -1,6 +1,6 @@
1
1
  class Iban
2
2
 
3
- def valid?(iban)
3
+ def self.valid?(iban)
4
4
 
5
5
  @iban = iban.to_s
6
6
 
@@ -16,7 +16,7 @@ class Iban
16
16
 
17
17
  end
18
18
 
19
- def char_to_numbers(char)
19
+ def self.char_to_numbers(char)
20
20
 
21
21
  # iban characters to number transformation table
22
22
  #
@@ -0,0 +1,42 @@
1
+ require 'minitest/autorun'
2
+ require File.dirname(__FILE__) + '/../lib/validators/afm'
3
+
4
+ class TestAfm < Minitest::Unit::TestCase
5
+ 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
10
+ end
11
+
12
+ 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
17
+ end
18
+
19
+ def test_empty_afm
20
+ refute Afm.valid?(""), 'Invalid ΑΦΜ wrong verification: ""'
21
+ refute Afm.valid?(nil), 'Invalid ΑΦΜ wrong verification: nil'
22
+ end
23
+ 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'
33
+ end
34
+ 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
+ end
40
+
41
+
42
+ end
@@ -0,0 +1,42 @@
1
+ require 'minitest/autorun'
2
+ require File.dirname(__FILE__) + '/../lib/validators/amka'
3
+
4
+ class TestAmka < Minitest::Unit::TestCase
5
+ 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
10
+ end
11
+
12
+ 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
17
+ end
18
+
19
+ def test_empty_amka
20
+ refute Amka.valid?(""), 'Invalid ΑΜΚΑ wrong verification: ""'
21
+ refute Amka.valid?(nil), 'Invalid ΑΜΚΑ wrong verification: nil'
22
+ end
23
+ 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'
33
+ end
34
+ 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
+ end
40
+
41
+
42
+ end
@@ -0,0 +1,42 @@
1
+ require 'minitest/autorun'
2
+ require File.dirname(__FILE__) + '/../lib/validators/cheque'
3
+
4
+ class TestCheque < Minitest::Unit::TestCase
5
+ 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
10
+ end
11
+
12
+ 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
17
+ end
18
+
19
+ def test_empty_cheque
20
+ refute Cheque.valid?(""), 'Invalid Cheque wrong verification: ""'
21
+ refute Cheque.valid?(nil), 'Invalid Cheque wrong verification: nil'
22
+ end
23
+ 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'
33
+ end
34
+ 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
+ end
40
+
41
+
42
+ end
@@ -0,0 +1,43 @@
1
+ require 'minitest/autorun'
2
+ require File.dirname(__FILE__) + '/../lib/validators/iban'
3
+
4
+ class TestIban < Minitest::Unit::TestCase
5
+ 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
10
+ end
11
+
12
+ 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
17
+ end
18
+
19
+ def test_empty_iban
20
+ refute Iban.valid?(""), 'Invalid IBAN wrong verification: ""'
21
+ refute Iban.valid?(nil), 'Invalid IBAN wrong verification: nil'
22
+ end
23
+ 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'
34
+ end
35
+ 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
+ end
41
+
42
+
43
+ end
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.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michail Pantelelis
@@ -16,11 +16,18 @@ executables: []
16
16
  extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
+ - LICENSE
20
+ - README.md
21
+ - Rakefile
19
22
  - lib/gpav.rb
20
23
  - lib/validators/afm.rb
21
24
  - lib/validators/amka.rb
22
25
  - lib/validators/cheque.rb
23
26
  - lib/validators/iban.rb
27
+ - test/test_afm.rb
28
+ - test/test_amka.rb
29
+ - test/test_cheque.rb
30
+ - test/test_iban.rb
24
31
  homepage: https://github.com/mpantel/gpav
25
32
  licenses:
26
33
  - MIT
@@ -33,7 +40,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
33
40
  requirements:
34
41
  - - ">="
35
42
  - !ruby/object:Gem::Version
36
- version: '0'
43
+ version: '2.1'
37
44
  required_rubygems_version: !ruby/object:Gem::Requirement
38
45
  requirements:
39
46
  - - ">="