banking_data_validator 0.0.1
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 +15 -0
- data/.gitignore +14 -0
- data/.rspec +3 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +38 -0
- data/Rakefile +6 -0
- data/banking_data_validator.gemspec +26 -0
- data/lib/banking_data_validator/banco_base.rb +17 -0
- data/lib/banking_data_validator/banco_bradesco.rb +22 -0
- data/lib/banking_data_validator/banco_do_brasil.rb +21 -0
- data/lib/banking_data_validator/banco_itau.rb +35 -0
- data/lib/banking_data_validator/banco_santander.rb +19 -0
- data/lib/banking_data_validator.rb +53 -0
- data/spec/banking_data_validator/banco_bradesco_spec.rb +16 -0
- data/spec/banking_data_validator/banco_do_brasil_spec.rb +22 -0
- data/spec/banking_data_validator/banco_itau_spec.rb +13 -0
- data/spec/banking_data_validator/banco_santander_spec.rb +13 -0
- data/spec/banking_data_validator.rb +62 -0
- data/spec/spec_helper.rb +96 -0
- metadata +154 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZGU1YjhiOGU3Njk2YWJhZGUxZjhkMWJjOWVlZDkxNGQ5NWFmOTRlOA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
OTBhODk1YmRhNmE0YTU4NTVkNzIwMzk3ODdmZGZmMmE0ZTU2MzcxOA==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MGE0MWQ4ZmI4YmVjYWIwNTg4YzIyMjNmNTlhMjlhMTBjNmRjMjk4NWNmNjVm
|
10
|
+
MDU1NTQwYTNiYjA2ZTU4ZDE3ZTQxMjUzMmM4MzU4MDQwNTIyNGI1YTUyNGNm
|
11
|
+
YzBjNTgwYTdkMzI3MzMwYzJmMmI2NzAxYWUxNDI1MGMxYzZiYmE=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NzUwNDJiNmNlZGI5NGY0YTQ4ZjM5ZWQxOTdiNjkwYTczZWI1ZDNlOGUyZjhk
|
14
|
+
N2M5ZjEyNzRhOWQ1YmFmNGY2NTYwM2NkYmM2ZWQ3YzliZTJkZThkZDRkZmEx
|
15
|
+
MjFlYjcyZjA3MTBkOTg5MmE0MzRmZTdiOThiY2Q4YjI3NjQ1ZTE=
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.9.3
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Americo Duarte
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# BankingDataValidator
|
2
|
+
|
3
|
+
[](https://travis-ci.org/americodls/banking_data_validator)
|
4
|
+
[](https://codeclimate.com/github/americodls/banking_data_validator)
|
5
|
+
[](https://coveralls.io/r/americodls/banking_data_validator)
|
6
|
+
[](https://gemnasium.com/americodls/banking_data_validator)
|
7
|
+
[](https://hakiri.io/github/americodls/banking_data_validator/master)
|
8
|
+
[](http://inch-ci.org/github/americodls/banking_data_validator)
|
9
|
+
|
10
|
+
An implementation of ActiveModel::Validator for bank accounts.
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
Add this line to your application"s Gemfile:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
gem "banking_data_validator"
|
18
|
+
```
|
19
|
+
|
20
|
+
And then execute:
|
21
|
+
|
22
|
+
$ bundle
|
23
|
+
|
24
|
+
Or install it yourself as:
|
25
|
+
|
26
|
+
$ gem install banking_data_validator
|
27
|
+
|
28
|
+
## Usage
|
29
|
+
|
30
|
+
TODO: Write usage instructions here
|
31
|
+
|
32
|
+
## Contributing
|
33
|
+
|
34
|
+
1. Fork it ( https://github.com/[my-github-username]/banking_data_validator/fork )
|
35
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
36
|
+
3. Commit your changes (`git commit -am "Add some feature"`)
|
37
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
38
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = "banking_data_validator"
|
6
|
+
spec.version = "0.0.1"
|
7
|
+
spec.authors = ["Americo Duarte"]
|
8
|
+
spec.email = ["americodls@gmail.com"]
|
9
|
+
spec.summary = %q{An implementation of ActiveModel::Validator for bank accounts.}
|
10
|
+
spec.description = spec.summary
|
11
|
+
spec.homepage = "http://www.bioritmo.com.br"
|
12
|
+
spec.license = "MIT"
|
13
|
+
|
14
|
+
spec.files = `git ls-files -z`.split("\x0")
|
15
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
16
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
20
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
21
|
+
spec.add_development_dependency "rspec", "~> 3.1"
|
22
|
+
spec.add_development_dependency "mutant-rspec", "~> 0.7"
|
23
|
+
spec.add_development_dependency "coveralls"
|
24
|
+
|
25
|
+
spec.add_runtime_dependency "activemodel", ">= 3.0"
|
26
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class BankingDataValidator
|
2
|
+
class BancoBase
|
3
|
+
def valid_account?(branch, account_number, account_digit)
|
4
|
+
true
|
5
|
+
end
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
def multiplier(factors, string)
|
10
|
+
multiplier_position = factors.cycle
|
11
|
+
|
12
|
+
string.chars.map(&:to_i).reverse.inject(0) do |total, algarism|
|
13
|
+
total + algarism * multiplier_position.next
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class BankingDataValidator
|
2
|
+
class BancoBradesco < BancoBase
|
3
|
+
def valid_account?(branch, account_number, account_digit)
|
4
|
+
account_digit.upcase == modulo11_2to7_p_as_1(account_number)
|
5
|
+
end
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
def modulo11_2to7_p_as_1(string)
|
10
|
+
value = modulo11_2to7(string)
|
11
|
+
case value
|
12
|
+
when 0 then "0"
|
13
|
+
when 1 then "P"
|
14
|
+
else "#{11 - value}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def modulo11_2to7(string)
|
19
|
+
multiplier([2, 3, 4, 5, 6, 7], string) % 11
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class BankingDataValidator
|
2
|
+
class BancoDoBrasil < BancoBase
|
3
|
+
def valid_account?(branch, account_number, account_digit)
|
4
|
+
account_digit.upcase == module11_9to2_10_as_x(account_number).to_s
|
5
|
+
end
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
def module11_9to2_10_as_x(string)
|
10
|
+
value = module11_9to2(string)
|
11
|
+
case value
|
12
|
+
when 10 then "X"
|
13
|
+
else value
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def module11_9to2(string)
|
18
|
+
multiplier([9, 8, 7, 6, 5, 4, 3, 2], string) % 11
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
class BankingDataValidator
|
2
|
+
class BancoItau < BancoBase
|
3
|
+
def valid_account?(branch, account_number, account_digit)
|
4
|
+
account_digit == module10("#{branch}#{account_number}")
|
5
|
+
end
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
def module10(str)
|
10
|
+
total = 0
|
11
|
+
multiplier = 2
|
12
|
+
|
13
|
+
str.split(//).reverse!.each do |char|
|
14
|
+
total += sum_digits(char.to_i * multiplier)
|
15
|
+
multiplier = multiplier == 2 ? 1 : 2
|
16
|
+
end
|
17
|
+
|
18
|
+
value = (10 - (total % 10))
|
19
|
+
value == 10 ? "0" : "#{value}"
|
20
|
+
end
|
21
|
+
|
22
|
+
def sum_digits(str)
|
23
|
+
initial_value = str.kind_of?(Fixnum) ? str : str.to_i
|
24
|
+
return 0 if initial_value == 0
|
25
|
+
return initial_value if initial_value <= 9
|
26
|
+
|
27
|
+
initial_value = initial_value.to_s
|
28
|
+
total = 0
|
29
|
+
|
30
|
+
0.upto(initial_value.size-1) {|digit| total += initial_value[digit, 1].to_i }
|
31
|
+
|
32
|
+
return total
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class BankingDataValidator
|
2
|
+
class BancoSantander < BancoBase
|
3
|
+
def valid_account?(branch, account_number, account_digit)
|
4
|
+
account_digit.upcase == module10_santander("#{branch}#{account_number}").to_s
|
5
|
+
end
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
def module10_santander(account_number)
|
10
|
+
factors = [9, 7, 3, 1, 9, 7, 1, 3, 1, 9, 7, 3].cycle
|
11
|
+
|
12
|
+
total = account_number.chars.map(&:to_i).inject(0) do |acc, digito|
|
13
|
+
acc + (digito * factors.next % 10)
|
14
|
+
end
|
15
|
+
|
16
|
+
10 - total % 10
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require "active_model"
|
2
|
+
|
3
|
+
class BankingDataValidator < ActiveModel::Validator
|
4
|
+
autoload :BancoBase, "banking_data_validator/banco_base"
|
5
|
+
autoload :BancoBradesco, "banking_data_validator/banco_bradesco"
|
6
|
+
autoload :BancoDoBrasil, "banking_data_validator/banco_do_brasil"
|
7
|
+
autoload :BancoItau, "banking_data_validator/banco_itau"
|
8
|
+
autoload :BancoSantander, "banking_data_validator/banco_santander"
|
9
|
+
|
10
|
+
def initialize(options = {})
|
11
|
+
super
|
12
|
+
@bank_number_field_name = options.fetch(:bank_number, :bank_number)
|
13
|
+
@branch_number_field_name = options.fetch(:branch_number, :branch_number)
|
14
|
+
@account_number_field_name = options.fetch(:account_number, :account_number)
|
15
|
+
@account_digit_field_name = options.fetch(:account_digit, :account_digit)
|
16
|
+
end
|
17
|
+
|
18
|
+
def validate(record)
|
19
|
+
bank_number = record.public_send(@bank_number_field_name)
|
20
|
+
branch_number = record.public_send(@branch_number_field_name)
|
21
|
+
account_number = record.public_send(@account_number_field_name)
|
22
|
+
account_digit = record.public_send(@account_digit_field_name)
|
23
|
+
|
24
|
+
bank = build_bank(bank_number)
|
25
|
+
|
26
|
+
if !valid_number?(branch_number)
|
27
|
+
record.errors.add(@branch_number_field_name, :not_a_number)
|
28
|
+
end
|
29
|
+
|
30
|
+
if !valid_number?(account_number)
|
31
|
+
record.errors.add(@account_number_field_name, :not_a_number)
|
32
|
+
elsif !bank.valid_account?(branch_number, account_number, account_digit)
|
33
|
+
record.errors.add(@account_digit_field_name)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def valid_number?(number)
|
40
|
+
number && integer?(number)
|
41
|
+
end
|
42
|
+
|
43
|
+
def integer?(string)
|
44
|
+
Integer(string, 10) && true rescue false
|
45
|
+
end
|
46
|
+
|
47
|
+
def build_bank(number)
|
48
|
+
{
|
49
|
+
"237" => BancoBradesco.new,
|
50
|
+
nil => BancoBase.new,
|
51
|
+
}[number]
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
RSpec.describe BankingDataValidator::BancoBradesco do
|
2
|
+
describe "#valid_account?" do
|
3
|
+
it "is true when the given account data is valid" do
|
4
|
+
expect(subject).to be_valid_account(nil, "0238069", "2")
|
5
|
+
expect(subject).to be_valid_account(nil, "160000", "1")
|
6
|
+
expect(subject).to be_valid_account(nil, "87087", "0")
|
7
|
+
expect(subject).to be_valid_account(nil, "71000", "8")
|
8
|
+
expect(subject).to be_valid_account(nil, "3257", "3")
|
9
|
+
expect(subject).to be_valid_account(nil, "121", "p")
|
10
|
+
end
|
11
|
+
|
12
|
+
it "is false when the given account data is not valid" do
|
13
|
+
expect(subject).to_not be_valid_account(nil, "87362", "0")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
RSpec.describe BankingDataValidator::BancoDoBrasil do
|
2
|
+
describe "#valid_account?" do
|
3
|
+
it "valid account digits" do
|
4
|
+
expect(subject).to be_valid_account(nil, "65005", "6")
|
5
|
+
expect(subject).to be_valid_account(nil, "22029", "9")
|
6
|
+
expect(subject).to be_valid_account(nil, "70000", "2")
|
7
|
+
expect(subject).to be_valid_account(nil, "7107" , "2")
|
8
|
+
expect(subject).to be_valid_account(nil, "80000", "7")
|
9
|
+
expect(subject).to be_valid_account(nil, "8354" , "2")
|
10
|
+
expect(subject).to be_valid_account(nil, "15007", "X")
|
11
|
+
expect(subject).to be_valid_account(nil, "15007", "x")
|
12
|
+
end
|
13
|
+
|
14
|
+
it "invalid account digits" do
|
15
|
+
expect(subject).to_not be_valid_account(nil, "23433", "0")
|
16
|
+
expect(subject).to_not be_valid_account(nil, "23433", "P")
|
17
|
+
expect(subject).to_not be_valid_account(nil, "23433", "10")
|
18
|
+
expect(subject).to_not be_valid_account(nil, "15007", "xx")
|
19
|
+
expect(subject).to_not be_valid_account(nil, "15007", "10")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
RSpec.describe BankingDataValidator::BancoItau do
|
2
|
+
describe "#valid_account?" do
|
3
|
+
it "valid account digits" do
|
4
|
+
expect(subject).to be_valid_account("0262", "42602", "6")
|
5
|
+
expect(subject).to be_valid_account("1517", "15667", "3")
|
6
|
+
expect(subject).to be_valid_account("2545", "02366", "1")
|
7
|
+
end
|
8
|
+
|
9
|
+
it "invalid account digits" do
|
10
|
+
expect(subject).to_not be_valid_account("0991", "87362", "0")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
RSpec.describe BankingDataValidator::BancoSantander do
|
2
|
+
describe "#valid_account?" do
|
3
|
+
it "valid account digits" do
|
4
|
+
expect(subject).to be_valid_account("0189", "01017417", "9")
|
5
|
+
expect(subject).to be_valid_account("3140", "13000470", "9")
|
6
|
+
expect(subject).to be_valid_account("1227", "43000005", "2")
|
7
|
+
end
|
8
|
+
|
9
|
+
it "invalid account digits" do
|
10
|
+
expect(subject).to_not be_valid_account("0991", "01387362", "0")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
RSpec.describe BankingDataValidator do
|
2
|
+
|
3
|
+
it "requires a branch_number" do
|
4
|
+
[nil, "X"].each do |invalid_branch_number|
|
5
|
+
payment = Payment.new(branch_number: invalid_branch_number, account_number: "87362", account_digit: nil)
|
6
|
+
expect(payment).to_not be_valid
|
7
|
+
expect(payment.errors[:branch_number]).to include("is not a number")
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
it "requires a account_number" do
|
12
|
+
[nil, "X"].each do |invalid_account_number|
|
13
|
+
payment = Payment.new(branch_number: "123", account_number: invalid_account_number, account_digit: "2")
|
14
|
+
expect(payment).to_not be_valid
|
15
|
+
expect(payment.errors[:account_number]).to include("is not a number")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
it "requires a check digit" do
|
20
|
+
payment = Payment.new(bank_number: "237", branch_number: "123", account_number: "87362", account_digit: "0")
|
21
|
+
expect(payment).to_not be_valid
|
22
|
+
expect(payment.errors[:account_digit]).to include("is invalid")
|
23
|
+
end
|
24
|
+
|
25
|
+
it "uses default field names when custom field is not given" do
|
26
|
+
valid_attributes.each { |attributes| expect(Payment.new(attributes)).to be_valid }
|
27
|
+
end
|
28
|
+
|
29
|
+
it "accepts custom field names" do
|
30
|
+
expect(CustomPayment.new(c_bank: "237", c_branch: "123", c_account: "0238069", c_digit: "2")).to be_valid
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "Bradesco" do
|
34
|
+
it "validates account digits" do
|
35
|
+
valid_attributes.each { |attributes| expect(Payment.new(attributes)).to be_valid }
|
36
|
+
|
37
|
+
expect(Payment.new(bank_number: "237", branch_number: "123", account_number: "87362", account_digit: "2")).to_not be_valid
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def valid_attributes
|
43
|
+
[
|
44
|
+
{branch_number: "123", account_number: "0238069", account_digit: "2"},
|
45
|
+
{branch_number: "123", account_number: "160000", account_digit: "1"},
|
46
|
+
{branch_number: "123", account_number: "87087", account_digit: "0"},
|
47
|
+
{branch_number: "123", account_number: "71000", account_digit: "8"},
|
48
|
+
{branch_number: "123", account_number: "3257", account_digit: "3"}
|
49
|
+
]
|
50
|
+
end
|
51
|
+
|
52
|
+
class Payment
|
53
|
+
include ActiveModel::Model
|
54
|
+
attr_accessor :bank_number, :branch_number, :account_number, :account_digit
|
55
|
+
validates_with BankingDataValidator
|
56
|
+
end
|
57
|
+
|
58
|
+
class CustomPayment
|
59
|
+
include ActiveModel::Model
|
60
|
+
attr_accessor :c_bank, :c_branch, :c_account, :c_digit
|
61
|
+
validates_with BankingDataValidator, bank_number: :c_bank, branch_number: :c_branch, account_number: :c_account, account_digit: :c_digit
|
62
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
|
3
|
+
require "banking_data_validator"
|
4
|
+
|
5
|
+
require 'coveralls'
|
6
|
+
Coveralls.wear!
|
7
|
+
|
8
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
9
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
10
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
11
|
+
# file to always be loaded, without a need to explicitly require it in any files.
|
12
|
+
#
|
13
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
14
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
15
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
16
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
17
|
+
# a separate helper file that requires the additional dependencies and performs
|
18
|
+
# the additional setup, and require it from the spec files that actually need it.
|
19
|
+
#
|
20
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
21
|
+
# users commonly want.
|
22
|
+
#
|
23
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
24
|
+
RSpec.configure do |config|
|
25
|
+
# rspec-expectations config goes here. You can use an alternate
|
26
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
27
|
+
# assertions if you prefer.
|
28
|
+
config.expect_with :rspec do |expectations|
|
29
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
30
|
+
# and `failure_message` of custom matchers include text for helper methods
|
31
|
+
# defined using `chain`, e.g.:
|
32
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
33
|
+
# # => "be bigger than 2 and smaller than 4"
|
34
|
+
# ...rather than:
|
35
|
+
# # => "be bigger than 2"
|
36
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
37
|
+
end
|
38
|
+
|
39
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
40
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
41
|
+
config.mock_with :rspec do |mocks|
|
42
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
43
|
+
# a real object. This is generally recommended, and will default to
|
44
|
+
# `true` in RSpec 4.
|
45
|
+
mocks.verify_partial_doubles = true
|
46
|
+
end
|
47
|
+
|
48
|
+
# The settings below are suggested to provide a good initial experience
|
49
|
+
# with RSpec, but feel free to customize to your heart"s content.
|
50
|
+
|
51
|
+
# These two settings work together to allow you to limit a spec run
|
52
|
+
# to individual examples or groups you care about by tagging them with
|
53
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
54
|
+
# get run.
|
55
|
+
config.filter_run :focus
|
56
|
+
config.run_all_when_everything_filtered = true
|
57
|
+
|
58
|
+
# Limits the available syntax to the non-monkey patched syntax that is recommended.
|
59
|
+
# For more details, see:
|
60
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
61
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
62
|
+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
63
|
+
config.disable_monkey_patching!
|
64
|
+
|
65
|
+
# This setting enables warnings. It"s recommended, but in some cases may
|
66
|
+
# be too noisy due to issues in dependencies.
|
67
|
+
config.warnings = true
|
68
|
+
|
69
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
70
|
+
# file, and it"s useful to allow more verbose output when running an
|
71
|
+
# individual spec file.
|
72
|
+
if config.files_to_run.one?
|
73
|
+
# Use the documentation formatter for detailed output,
|
74
|
+
# unless a formatter has already been configured
|
75
|
+
# (e.g. via a command-line flag).
|
76
|
+
config.default_formatter = "doc"
|
77
|
+
end
|
78
|
+
|
79
|
+
# Print the 10 slowest examples and example groups at the
|
80
|
+
# end of the spec run, to help surface which specs are running
|
81
|
+
# particularly slow.
|
82
|
+
config.profile_examples = 10
|
83
|
+
|
84
|
+
# Run specs in random order to surface order dependencies. If you find an
|
85
|
+
# order dependency and want to debug it, you can fix the order by providing
|
86
|
+
# the seed, which is printed after each run.
|
87
|
+
# --seed 1234
|
88
|
+
config.order = :random
|
89
|
+
|
90
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
91
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
92
|
+
# test failures related to randomization by passing the same `--seed` value
|
93
|
+
# as the one that triggered the failure.
|
94
|
+
Kernel.srand config.seed
|
95
|
+
|
96
|
+
end
|
metadata
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: banking_data_validator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Americo Duarte
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-02-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.1'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.1'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: mutant-rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.7'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.7'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: coveralls
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: activemodel
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ! '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ! '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.0'
|
97
|
+
description: An implementation of ActiveModel::Validator for bank accounts.
|
98
|
+
email:
|
99
|
+
- americodls@gmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- .gitignore
|
105
|
+
- .rspec
|
106
|
+
- .ruby-version
|
107
|
+
- Gemfile
|
108
|
+
- LICENSE.txt
|
109
|
+
- README.md
|
110
|
+
- Rakefile
|
111
|
+
- banking_data_validator.gemspec
|
112
|
+
- lib/banking_data_validator.rb
|
113
|
+
- lib/banking_data_validator/banco_base.rb
|
114
|
+
- lib/banking_data_validator/banco_bradesco.rb
|
115
|
+
- lib/banking_data_validator/banco_do_brasil.rb
|
116
|
+
- lib/banking_data_validator/banco_itau.rb
|
117
|
+
- lib/banking_data_validator/banco_santander.rb
|
118
|
+
- spec/banking_data_validator.rb
|
119
|
+
- spec/banking_data_validator/banco_bradesco_spec.rb
|
120
|
+
- spec/banking_data_validator/banco_do_brasil_spec.rb
|
121
|
+
- spec/banking_data_validator/banco_itau_spec.rb
|
122
|
+
- spec/banking_data_validator/banco_santander_spec.rb
|
123
|
+
- spec/spec_helper.rb
|
124
|
+
homepage: http://www.bioritmo.com.br
|
125
|
+
licenses:
|
126
|
+
- MIT
|
127
|
+
metadata: {}
|
128
|
+
post_install_message:
|
129
|
+
rdoc_options: []
|
130
|
+
require_paths:
|
131
|
+
- lib
|
132
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ! '>='
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
requirements: []
|
143
|
+
rubyforge_project:
|
144
|
+
rubygems_version: 2.4.5
|
145
|
+
signing_key:
|
146
|
+
specification_version: 4
|
147
|
+
summary: An implementation of ActiveModel::Validator for bank accounts.
|
148
|
+
test_files:
|
149
|
+
- spec/banking_data_validator.rb
|
150
|
+
- spec/banking_data_validator/banco_bradesco_spec.rb
|
151
|
+
- spec/banking_data_validator/banco_do_brasil_spec.rb
|
152
|
+
- spec/banking_data_validator/banco_itau_spec.rb
|
153
|
+
- spec/banking_data_validator/banco_santander_spec.rb
|
154
|
+
- spec/spec_helper.rb
|