bank-validator 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a12a8cb39e85cd7d3095f4531e93280815e1c6ad
4
- data.tar.gz: 696ef669eda1a6b45c321d8370ed271f40604ad5
3
+ metadata.gz: 2e41b6d28c648b00b2b22cbad01b8a17c9785275
4
+ data.tar.gz: a073c8689c08699d4b74ecb792c0b0540deca21c
5
5
  SHA512:
6
- metadata.gz: 4bf523388656b2848daf70438f5be12aae3255a29f8ac84351545097408af1c03960f71cf83d2b01b7b24252d143b4153737b5ad88136d956f24dfc08b5d2965
7
- data.tar.gz: 6ec35e9c6495af57215244c1c00d7924ad1cd5ae2bf7a0e944ac3bb388cc651db54803fbbf2c0df56bc508e233a128f1e15568d6516913de147abdff4d7eb6fc
6
+ metadata.gz: 0e39c283bfb49c3669421e97e786c737b27e9878f24ee3acc32f2469e95f02ac5903b70eb2feff9e59da8a8173db5579b08c707dbaebf7f970226e50402fb272
7
+ data.tar.gz: 21552b87c6b9f6169aaa1972bbdd6ef9bc54329adb2a6d1d04c9eaa8706ef3af9a2d568d0b02c63df2411841f09a044382d66d2a839aef1b77c9694478e0cb40
data/Gemfile CHANGED
@@ -2,8 +2,6 @@ source "http://rubygems.org"
2
2
  # Add dependencies required to use your gem here.
3
3
  # Example:
4
4
  # gem "activesupport", ">= 2.3.5"
5
- gem "activesupport", ">= 3.0"
6
- gem "activerecord", ">= 3.0"
7
5
  gem "activemodel", ">= 3.0"
8
6
 
9
7
  # Add dependencies to develop your gem here.
data/Gemfile.lock CHANGED
@@ -4,10 +4,6 @@ GEM
4
4
  activemodel (4.2.1)
5
5
  activesupport (= 4.2.1)
6
6
  builder (~> 3.1)
7
- activerecord (4.2.1)
8
- activemodel (= 4.2.1)
9
- activesupport (= 4.2.1)
10
- arel (~> 6.0)
11
7
  activesupport (4.2.1)
12
8
  i18n (~> 0.7)
13
9
  json (~> 1.7, >= 1.7.7)
@@ -15,7 +11,6 @@ GEM
15
11
  thread_safe (~> 0.3, >= 0.3.4)
16
12
  tzinfo (~> 1.1)
17
13
  addressable (2.3.7)
18
- arel (6.0.0)
19
14
  builder (3.2.2)
20
15
  descendants_tracker (0.0.4)
21
16
  thread_safe (~> 0.3, >= 0.3.1)
@@ -96,8 +91,6 @@ PLATFORMS
96
91
 
97
92
  DEPENDENCIES
98
93
  activemodel (>= 3.0)
99
- activerecord (>= 3.0)
100
- activesupport (>= 3.0)
101
94
  bundler (~> 1.0)
102
95
  jeweler (~> 2.0)
103
96
  rdoc (~> 3.12)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.3
1
+ 0.2.4
@@ -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.2.3 ruby lib
5
+ # stub: bank-validator 0.2.4 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "bank-validator"
9
- s.version = "0.2.3"
9
+ s.version = "0.2.4"
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"]
@@ -104,8 +104,6 @@ Gem::Specification.new do |s|
104
104
  s.specification_version = 4
105
105
 
106
106
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
107
- s.add_runtime_dependency(%q<activesupport>, [">= 3.0"])
108
- s.add_runtime_dependency(%q<activerecord>, [">= 3.0"])
109
107
  s.add_runtime_dependency(%q<activemodel>, [">= 3.0"])
110
108
  s.add_development_dependency(%q<rspec>, [">= 0"])
111
109
  s.add_development_dependency(%q<shoulda>, ["~> 3.5"])
@@ -114,8 +112,6 @@ Gem::Specification.new do |s|
114
112
  s.add_development_dependency(%q<jeweler>, ["~> 2.0"])
115
113
  s.add_development_dependency(%q<simplecov>, ["~> 0.9"])
116
114
  else
117
- s.add_dependency(%q<activesupport>, [">= 3.0"])
118
- s.add_dependency(%q<activerecord>, [">= 3.0"])
119
115
  s.add_dependency(%q<activemodel>, [">= 3.0"])
120
116
  s.add_dependency(%q<rspec>, [">= 0"])
121
117
  s.add_dependency(%q<shoulda>, ["~> 3.5"])
@@ -125,8 +121,6 @@ Gem::Specification.new do |s|
125
121
  s.add_dependency(%q<simplecov>, ["~> 0.9"])
126
122
  end
127
123
  else
128
- s.add_dependency(%q<activesupport>, [">= 3.0"])
129
- s.add_dependency(%q<activerecord>, [">= 3.0"])
130
124
  s.add_dependency(%q<activemodel>, [">= 3.0"])
131
125
  s.add_dependency(%q<rspec>, [">= 0"])
132
126
  s.add_dependency(%q<shoulda>, ["~> 3.5"])
@@ -3,7 +3,7 @@ require 'active_model'
3
3
  class BicValidator < ActiveModel::EachValidator
4
4
 
5
5
  def validate_each(record, attribute, value)
6
- record_error(record, attribute, value) unless value =~ regexp
6
+ record_error(record, attribute, value) unless value =~ BicValidator.regexp
7
7
  end
8
8
 
9
9
  private
@@ -12,7 +12,7 @@ class BicValidator < ActiveModel::EachValidator
12
12
  record.errors.add(attribute, (options[:message] || :invalid_bic))
13
13
  end
14
14
 
15
- def regexp
15
+ def self.regexp
16
16
  /[A-Z]{6}[A-Z0-9]{2,}/
17
17
  end
18
18
  end
@@ -3,27 +3,28 @@ require 'active_model'
3
3
  class IbanValidator < ActiveModel::EachValidator
4
4
 
5
5
  def validate_each(record, attribute, value)
6
- record_error(record, attribute, value) unless value =~ regexp && valid_iban?(value)
6
+ record_error(record, attribute, value) unless value =~ IbanValidator.regexp && valid_iban?(value)
7
7
  end
8
8
 
9
+
9
10
  private
10
11
 
11
12
  def record_error(record, attribute, value)
12
- record.errors.add(attribute, (options[:message] || :invalid_iban))# || options[:message]))
13
+ record.errors.add(attribute, (options[:message] || :invalid_iban))
13
14
  end
14
-
15
- def regexp
15
+
16
+ def self.regexp
16
17
  /[A-Z]{2}[a-zA-Z0-9]{14,}/
17
18
  end
18
19
 
19
20
  def valid_iban?(iban)
20
21
  # Move first four characters to end of string
21
- dummy_iban = iban.slice(4..-1) + iban.slice(0..3)
22
+ dummy_iban = iban[4..-1] + iban[0..3]
22
23
 
23
24
  # Substitute all letters with integers
24
- dummy_iban.split(//).each { |char| dummy_iban.gsub!(char, (char.downcase.ord - 87).to_s) if (char =~ /[a-zA-Z]/).present? }
25
+ checksum = dummy_iban.chars.map { |char| ((char =~ /[a-zA-Z]/).present?) ? (char.downcase.ord - 87).to_s : char }.join
25
26
 
26
27
  # Check if division by 97 yields a remainder of 1, in which case it could be a valid IBAN
27
- (dummy_iban.to_i % 97) == 1
28
+ (checksum.to_i % 97) == 1
28
29
  end
29
30
  end
@@ -3,7 +3,7 @@ require 'active_model'
3
3
  class RoutingNumberValidator < ActiveModel::EachValidator
4
4
 
5
5
  def validate_each(record, attribute, value)
6
- record_error(record, attribute, value) unless value =~ regexp && valid_routing_number?(value)
6
+ record_error(record, attribute, value) unless value =~ RoutingNumberValidator.regexp && valid_routing_number?(value)
7
7
  end
8
8
 
9
9
  private
@@ -12,12 +12,12 @@ class RoutingNumberValidator < ActiveModel::EachValidator
12
12
  record.errors.add(attribute, (options[:message] || :invalid_routing_number))
13
13
  end
14
14
 
15
- def regexp
15
+ def self.regexp
16
16
  /^[0-9]{9}$/
17
17
  end
18
18
 
19
19
  def valid_routing_number?(route_number)
20
- d = route_number.split(//)
20
+ d = route_number.chars
21
21
 
22
22
  ((3 * (d[0].to_i + d[3].to_i + d[6].to_i)) + (7 * (d[1].to_i + d[4].to_i + d[7].to_i)) + (d[2].to_i + d[5].to_i + d[8].to_i)) % 10 == 0
23
23
  end
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ~/Workspace/bank-validator
3
3
  specs:
4
- bank-validator (0.2.2)
4
+ bank-validator (0.2.3)
5
5
  activemodel (>= 3.0)
6
6
  activerecord (>= 3.0)
7
7
  activesupport (>= 3.0)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bank-validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Bahlke
@@ -10,34 +10,6 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2015-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: activesupport
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - '>='
18
- - !ruby/object:Gem::Version
19
- version: '3.0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - '>='
25
- - !ruby/object:Gem::Version
26
- version: '3.0'
27
- - !ruby/object:Gem::Dependency
28
- name: activerecord
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - '>='
32
- - !ruby/object:Gem::Version
33
- version: '3.0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - '>='
39
- - !ruby/object:Gem::Version
40
- version: '3.0'
41
13
  - !ruby/object:Gem::Dependency
42
14
  name: activemodel
43
15
  requirement: !ruby/object:Gem::Requirement