bank-validator 0.0.5 → 0.0.6
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/VERSION +1 -1
- data/bank-validator.gemspec +2 -2
- data/lib/active_model/iban_validator.rb +3 -4
- data/test/dummy/Gemfile.lock +2 -1
- data/test/dummy/spec/features/gem_testing_spec.rb +5 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73aa72dcb3b94f3f1c58f0c996406c7931eecbcd
|
4
|
+
data.tar.gz: f1ec617013e30ffe8e8be14aa09ae97c163dc63e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c12eb467855a4f70b83ef4c43ed3e5fd4ac2955a16041dc8ac82f729821621b1e2da68ed753af965481848c98e642e2a7a5226368d22ca372ec7ea2a98451bb
|
7
|
+
data.tar.gz: 38018cdf9bc96940426dc25c18cd2dfe6a3eb5aec3538be8e710ffa985691043415011e1246ffd2388fd9a4ccadac7d9a468eac42febbe1f603f27722a9e465b
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.6
|
data/bank-validator.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: bank-validator 0.0.
|
5
|
+
# stub: bank-validator 0.0.6 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "bank-validator"
|
9
|
-
s.version = "0.0.
|
9
|
+
s.version = "0.0.6"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
@@ -18,13 +18,12 @@ class IbanValidator < ActiveModel::EachValidator
|
|
18
18
|
|
19
19
|
def valid_iban?(iban)
|
20
20
|
# Move first four characters to end of string
|
21
|
-
|
22
|
-
iban += first_four_chars
|
21
|
+
dummy_iban = iban.slice(4..-1) + iban.slice(0..3)
|
23
22
|
|
24
23
|
# Substitute all letters with integers
|
25
|
-
|
24
|
+
dummy_iban.split(//).each { |char| dummy_iban.gsub!(char, (char.downcase.ord - 87).to_s) if (char =~ /[a-zA-Z]/).present? }
|
26
25
|
|
27
26
|
# Check if division by 97 yields a remainder of 1, in which case it could be a valid IBAN
|
28
|
-
(
|
27
|
+
(dummy_iban.to_i % 97) == 1
|
29
28
|
end
|
30
29
|
end
|
data/test/dummy/Gemfile.lock
CHANGED
@@ -19,4 +19,9 @@ RSpec.describe 'testing the gem', type: :feature do
|
|
19
19
|
@user.iban = 'BE62510007547061'
|
20
20
|
expect(@user.save).to be(true)
|
21
21
|
end
|
22
|
+
|
23
|
+
it 'creates a user with full iban' do
|
24
|
+
user = User.create(name: 'Adam', iban: 'BE62510007547061')
|
25
|
+
expect(user.iban).to eq('BE62510007547061')
|
26
|
+
end
|
22
27
|
end
|