validator_ie 0.1.4 → 0.1.5

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: 1a60f77dbe1205b9f501d92cb5d541b53e4a15bd
4
- data.tar.gz: 6b752c8fccb4faef303aed41335c1546344f8716
3
+ metadata.gz: 05f2dccc7b5a42e2ea0314b763e3888d63cf5aa1
4
+ data.tar.gz: 781fd0ee6716b7d16d1a0294f333d8bcb0df722e
5
5
  SHA512:
6
- metadata.gz: 3f90c7546ed99d35f9c0b6a9d58b0aa347db2c3b44ed8ef8b109302edd4cc5c3b995cd3b20fec18710a223a66b7f3a977b9c3119bcb3f8313e886a9d82a4bbeb
7
- data.tar.gz: 196a3bf5f9e65e9fc30aa23a6403424396f9b1d64db52fc186d4f4a8c6147dc65ebcfb8f5f84c0040d85f9aa08938387399a895a16687001f63202b75b9a1e4b
6
+ metadata.gz: 1905921ca757eea130fcf6c3c5f0d0a04a222a5d43fbfdb77c665f5628c272b4979413a05c2f6824b1ec36a1d4cd41995248d71e96f81976d4eb4df3aaf55541
7
+ data.tar.gz: c2680092446fcfce26b47691cbaa3abcb07c6e0db48f459b2f43d1a441550fccc066786db6448c8d0b19bb6094a84531d6dde605ac33f24aa604e7011476c815
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in validator_ie.gemspec
4
4
  gemspec
5
+ gem "activemodel", require: "active_model"
6
+ gem "pry"
data/README.md CHANGED
@@ -22,15 +22,9 @@ Or install it yourself as:
22
22
  ```ruby
23
23
  result = ValidatorIE::valid?('XXXXXXXXXXXX','AC') # Only numbers
24
24
  unless result
25
- puts result.errors.full_messages
25
+ puts ValidatorIE::errors.full_messages
26
26
  end
27
27
  ```
28
- ## Development
29
-
30
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
31
-
32
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
33
-
34
28
  ## Contributing
35
29
 
36
30
  Bug reports and pull requests are welcome on GitHub at https://github.com/rmomogi/validator_ie. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
@@ -20,10 +20,10 @@ module ValidatorIE
20
20
  self.number = number[0..2].concat("0").concat(number[3..12])
21
21
  matrix = number[0..number.size - 3].split(//).map.with_index {|m, k| k.next.odd? ? 1 : 2}
22
22
  result1 = number_should_modX(11, 11, nil, matrix, true)
23
-
23
+
24
24
  self.number = number[0..2].concat(number[4..13])
25
25
  result2 = number_should_modX(11, 11, 11, nil)
26
-
26
+
27
27
  return if result1 && result2
28
28
  errors.add(:number, 'não é válido para inscrição estadual.')
29
29
 
@@ -37,10 +37,11 @@ module ValidatorIE
37
37
  return false if at > matrix.size - 1
38
38
  sum = numberX[0..at].map.with_index { |v, k| v * matrix[k]}.join('').split(//).map(&:to_i).reduce(&:+)
39
39
  digit = (sum - (sum.to_s.split(//).last.to_i - 10)) - sum
40
+ digit = (digit == 10 ? 0 : digit)
40
41
  else
41
42
  sum = ModFunctions.sumX(numberX, at, final, true, matrix)
42
43
  divmod = sum.divmod(mod).last
43
- digit = divmod < 2 ? 0 : mod - divmod
44
+ digit = divmod < 2 ? 0 : mod - divmod
44
45
  end
45
46
  numberX[at + 1].eql?(digit)
46
47
  end
@@ -1,3 +1,3 @@
1
1
  module ValidatorIE
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validator_ie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Moraes de Oliveira
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-15 00:00:00.000000000 Z
11
+ date: 2018-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -119,9 +119,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  version: '0'
120
120
  requirements: []
121
121
  rubyforge_project:
122
- rubygems_version: 2.5.1
122
+ rubygems_version: 2.6.12
123
123
  signing_key:
124
124
  specification_version: 4
125
125
  summary: Gem para validação de inscrição estadual
126
126
  test_files: []
127
- has_rdoc: