banking_data_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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NDcyMmY3ZGIyMDZlMGNhODc1ZWY3Mjg0M2Q3YjY2Yjg3MGVkNGJkNQ==
4
+ ZjRiZDAxNGNjMGFkZTZjZGNlYmMyNDA4ZDRlMTc0ZjgzNjJkNmI5ZA==
5
5
  data.tar.gz: !binary |-
6
- OGMxZGYxMDI5YWU1OTUxOTA3ODk2YTY2ZDdhYzg2MDBjYWU5ZWIwNA==
6
+ Y2U4NDA0ODQ3ZWI0YzMyYTI5NDc4YzAyODE0ZGQ4MjlkZjU1MTRjYg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MGRiYzg4YzQwNGE1YTAzNmI5ZDVjYmY1YmJhODA5ZDZiZmE0ZDEwMDI4ZjNl
10
- NjA2YjcyZjUzOTYxMjVmNDgyZDcwM2M2NjQ4MmRlODE0ODA0YWU3ZDM5OTQw
11
- MzdhOWUxMjNlMTk0ZTNhNzVjYWQ5MTIyODRkZDc5MjdhZmFkZWE=
9
+ ZjNiN2Y4ZmRiMjRiMDE4MzAwNjNjYzFiZDVmNGFkNjRlMjBmZDljZjQwMTYw
10
+ OTBjOGVhYTRmYzEwNzQ2MGVkMDNlYjc2MDg3ZTM5NDdjOGNmYTE0NzkyMTVm
11
+ YjkwZDlkYjM4ZmExZGVlNzMwZmNlNDkzM2EzZDQ4ZTdlMWRhNDM=
12
12
  data.tar.gz: !binary |-
13
- ZWUyNTU3ZmEwZGVhM2JjZjA5YzE4MGM5YWY1MTE5Nzc3ZDYzY2ZkZDIxNDRj
14
- N2JjN2I2Mzg0YTc0ODU3MDQyMmFjNzAxMmQ4Y2Y0OWE3Y2VlNmE0OTE0Nzg3
15
- MTAzYmUxNjk5ZmZiNzY5ODM4MzdjNWJhMzFkZTFlMWI4MDEzMzU=
13
+ NDAzODcxMTg5NWFlYTA1MmY2NGI2MjcwMGE3NDY1ZGIwZmRkMDc2N2ViZTMz
14
+ MjhlYjJhYTY5NGI4NjZhN2I4YjZlMmM4MDc2MzExOTcxZjVjYWIxMTI4ZTk4
15
+ N2JjMmJkZDUwOWYyYmVmMzA3ZjdjZWNhNDc5NTNiZDUyY2RhY2E=
@@ -3,18 +3,23 @@ require "banking_data_validator/bank/base"
3
3
  module BankingDataValidator
4
4
  module Bank
5
5
  class Bradesco < Base
6
+
7
+ def initialize(branch, account_number, account_digit)
8
+ super
9
+ @account_digit = padding_with_zeros(account_digit.to_i)
10
+ end
11
+
6
12
  private
7
13
 
8
14
  def checksum
9
15
  case raw_checksum
10
- when 0 then "0"
11
- when 1 then "P"
12
- else "#{11 - raw_checksum}"
16
+ when 1..9 then "#{raw_checksum}"
17
+ else "0"
13
18
  end
14
19
  end
15
20
 
16
21
  def raw_checksum
17
- @raw_checksum ||= multiply_factors % 11
22
+ @raw_checksum ||= 11 - multiply_factors % 11
18
23
  end
19
24
 
20
25
  def factors
@@ -1,3 +1,3 @@
1
1
  module BankingDataValidator
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -10,7 +10,9 @@ module BankingDataValidator
10
10
  expect(Bradesco.valid_account?(nil, "87087", "0")).to eq(true)
11
11
  expect(Bradesco.valid_account?(nil, "71000", "8")).to eq(true)
12
12
  expect(Bradesco.valid_account?(nil, "3257", "3")).to eq(true)
13
+ expect(Bradesco.valid_account?(nil, 121, "0")).to eq(true)
13
14
  expect(Bradesco.valid_account?(nil, 121, "p")).to eq(true)
15
+ expect(Bradesco.valid_account?(nil, "1818", "0")).to eq(true)
14
16
  end
15
17
 
16
18
  it "returns false when is given an account_number with an invalid digit" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: banking_data_validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Americo Duarte
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-13 00:00:00.000000000 Z
11
+ date: 2015-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler