validates_cpf 3.0.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +8 -4
- data/.ruby-version +1 -1
- data/.travis.yml +37 -10
- data/README.md +5 -4
- data/Rakefile +3 -0
- data/gemfiles/Gemfile.rails5 +1 -1
- data/gemfiles/Gemfile.rails6 +5 -0
- data/lib/validates_cpf/cpf.rb +2 -0
- data/lib/validates_cpf/cpf_validator.rb +8 -1
- data/lib/validates_cpf/version.rb +1 -1
- data/spec/spec_helper.rb +0 -10
- data/validates_cpf.gemspec +1 -3
- metadata +14 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a51bcc75d139d82663a7f4de36b199df7d0544f7d38e3c94f950a71676dd8a2c
|
4
|
+
data.tar.gz: 73179bb8a799acddcc28b8f9d756052cfe40a05b659debe35b7811f37bbe6ac6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e88ccc8e127484fa95bcd7180d86e838d670c426e57ca77a07b6e461c935eeab6a152dadc0862cb3f7c149bc3eea4c52379c513c0393c01e7365b412c8a250b7
|
7
|
+
data.tar.gz: 053aff16e8a75661b4285d86206575157286da071065b698306fedc5a7f09360ffcbd4592328e998ce27f6321b89cda7ec26a0f27b4bb609268f81bb7108405d
|
data/.rubocop.yml
CHANGED
@@ -1,13 +1,17 @@
|
|
1
|
-
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.2
|
3
|
+
|
4
|
+
Metrics/AbcSize:
|
5
|
+
Max: 17
|
2
6
|
|
3
7
|
Metrics/BlockLength:
|
4
8
|
Enabled: false
|
5
9
|
|
6
10
|
Metrics/LineLength:
|
7
|
-
Max:
|
11
|
+
Max: 150
|
8
12
|
|
9
|
-
|
10
|
-
|
13
|
+
Metrics/MethodLength:
|
14
|
+
Max: 25
|
11
15
|
|
12
16
|
Style/Documentation:
|
13
17
|
Enabled: false
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.7.3
|
data/.travis.yml
CHANGED
@@ -1,10 +1,37 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
gemfile:
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
1
|
+
matrix:
|
2
|
+
include:
|
3
|
+
- rvm: 2.2
|
4
|
+
gemfile: gemfiles/Gemfile.rails4
|
5
|
+
- rvm: 2.2
|
6
|
+
gemfile: gemfiles/Gemfile.rails5
|
7
|
+
- rvm: 2.3
|
8
|
+
gemfile: gemfiles/Gemfile.rails4
|
9
|
+
- rvm: 2.3
|
10
|
+
gemfile: gemfiles/Gemfile.rails5
|
11
|
+
- rvm: 2.4
|
12
|
+
gemfile: gemfiles/Gemfile.rails4
|
13
|
+
- rvm: 2.4
|
14
|
+
gemfile: gemfiles/Gemfile.rails5
|
15
|
+
- rvm: 2.5
|
16
|
+
gemfile: gemfiles/Gemfile.rails4
|
17
|
+
- rvm: 2.5
|
18
|
+
gemfile: gemfiles/Gemfile.rails5
|
19
|
+
- rvm: 2.5
|
20
|
+
gemfile: gemfiles/Gemfile.rails6
|
21
|
+
- rvm: 2.6
|
22
|
+
gemfile: gemfiles/Gemfile.rails4
|
23
|
+
- rvm: 2.6
|
24
|
+
gemfile: gemfiles/Gemfile.rails5
|
25
|
+
- rvm: 2.6
|
26
|
+
gemfile: gemfiles/Gemfile.rails6
|
27
|
+
- rvm: 2.7
|
28
|
+
gemfile: gemfiles/Gemfile.rails4
|
29
|
+
- rvm: 2.7
|
30
|
+
gemfile: gemfiles/Gemfile.rails5
|
31
|
+
- rvm: 2.7
|
32
|
+
gemfile: gemfiles/Gemfile.rails6
|
33
|
+
- rvm: 3.0
|
34
|
+
gemfile: gemfiles/Gemfile.rails4
|
35
|
+
- rvm: 3.0
|
36
|
+
gemfile: gemfiles/Gemfile.rails6
|
37
|
+
script: rake complete
|
data/README.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
# ValidatesCPF
|
1
|
+
# ValidatesCPF
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/validates_cpf.png)](http://badge.fury.io/rb/validates_cpf) [![Build Status](https://secure.travis-ci.org/plribeiro3000/validates_cpf.png?branch=master)](http://travis-ci.org/plribeiro3000/validates_cpf) [![Dependency Status](https://gemnasium.com/plribeiro3000/validates_cpf.png)](https://gemnasium.com/plribeiro3000/validates_cpf) [![Coverage Status](https://coveralls.io/repos/plribeiro3000/validates_cpf/badge.png?branch=master)](https://coveralls.io/r/plribeiro3000/validates_cpf) [![Code Climate](https://codeclimate.com/github/plribeiro3000/validates_cpf.png)](https://codeclimate.com/github/plribeiro3000/validates_cpf)
|
4
4
|
|
5
|
-
Validates cpf and test it in a simple way.
|
5
|
+
Validates cpf and test it in a simple way.
|
6
|
+
Supports ruby 2.2+ and rails 3+. For older ruby versions use the version `2`.
|
6
7
|
|
7
8
|
## Installation
|
8
9
|
|
@@ -41,7 +42,7 @@ end
|
|
41
42
|
Require the matcher:
|
42
43
|
|
43
44
|
```ruby
|
44
|
-
require 'validates_cpf/
|
45
|
+
require 'validates_cpf/require_a_valid_cpf_matcher'
|
45
46
|
```
|
46
47
|
|
47
48
|
Use in your tests:
|
@@ -57,4 +58,4 @@ it { is_expected.to require_a_valid_cpf(:id) }
|
|
57
58
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
58
59
|
3. Commit your changes (`git commit -am 'Added some feature'`)
|
59
60
|
4. Push to the branch (`git push origin my-new-feature`)
|
60
|
-
5. Create new Pull Request
|
61
|
+
5. Create new Pull Request
|
data/Rakefile
CHANGED
data/gemfiles/Gemfile.rails5
CHANGED
data/lib/validates_cpf/cpf.rb
CHANGED
@@ -14,6 +14,7 @@ module ValidatesCpf
|
|
14
14
|
def valid?
|
15
15
|
return true if @number.blank?
|
16
16
|
return false unless @pure_number
|
17
|
+
|
17
18
|
check_cpf
|
18
19
|
end
|
19
20
|
|
@@ -23,6 +24,7 @@ module ValidatesCpf
|
|
23
24
|
|
24
25
|
def check_cpf
|
25
26
|
return false if @cleaned_number.length != 11 || @cleaned_number.scan(/\d/).uniq.length == 1
|
27
|
+
|
26
28
|
@result == first_digit_verifier + second_digit_verifier
|
27
29
|
end
|
28
30
|
|
@@ -7,7 +7,14 @@ class CpfValidator < ActiveModel::EachValidator
|
|
7
7
|
if cpf.valid?
|
8
8
|
record.send("#{attribute}=", cpf.number) if options[:mask]
|
9
9
|
else
|
10
|
-
|
10
|
+
ruby_prior_version_three =
|
11
|
+
Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.0.0')
|
12
|
+
|
13
|
+
if ruby_prior_version_three
|
14
|
+
record.errors.add(attribute, :invalid, options)
|
15
|
+
else
|
16
|
+
record.errors.add(attribute, :invalid, **options)
|
17
|
+
end
|
11
18
|
end
|
12
19
|
end
|
13
20
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -3,18 +3,8 @@
|
|
3
3
|
require 'rspec'
|
4
4
|
require 'active_model'
|
5
5
|
require 'coveralls'
|
6
|
-
require 'jazz_fingers'
|
7
6
|
require 'shoulda-matchers'
|
8
7
|
|
9
|
-
JazzFingers.configure do |config|
|
10
|
-
config.colored_prompt = false
|
11
|
-
config.awesome_print = false
|
12
|
-
config.coolline = false
|
13
|
-
config.application_name = ValidatesCpf
|
14
|
-
end
|
15
|
-
|
16
|
-
require 'jazz_fingers/setup'
|
17
|
-
|
18
8
|
RSpec.configure do |config|
|
19
9
|
config.include Shoulda::Matchers::ActiveModel
|
20
10
|
end
|
data/validates_cpf.gemspec
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
# frozen_string_literal: true
|
3
2
|
|
4
3
|
require File.expand_path('lib/validates_cpf/version', __dir__)
|
@@ -20,10 +19,9 @@ Gem::Specification.new do |gem|
|
|
20
19
|
gem.license = 'MIT'
|
21
20
|
|
22
21
|
gem.add_development_dependency 'coveralls'
|
23
|
-
gem.add_development_dependency 'jazz_fingers'
|
24
22
|
gem.add_development_dependency 'rake'
|
25
23
|
gem.add_development_dependency 'rspec'
|
26
|
-
gem.add_development_dependency 'rubocop'
|
24
|
+
gem.add_development_dependency 'rubocop', '< 0.68'
|
27
25
|
gem.add_development_dependency 'rubocop-rspec'
|
28
26
|
gem.add_development_dependency 'shoulda-matchers'
|
29
27
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: validates_cpf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paulo Henrique Lopes Ribeiro
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: coveralls
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: jazz_fingers
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: rake
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -70,16 +56,16 @@ dependencies:
|
|
70
56
|
name: rubocop
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
72
58
|
requirements:
|
73
|
-
- - "
|
59
|
+
- - "<"
|
74
60
|
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
61
|
+
version: '0.68'
|
76
62
|
type: :development
|
77
63
|
prerelease: false
|
78
64
|
version_requirements: !ruby/object:Gem::Requirement
|
79
65
|
requirements:
|
80
|
-
- - "
|
66
|
+
- - "<"
|
81
67
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
68
|
+
version: '0.68'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: rubocop-rspec
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,7 +108,7 @@ dependencies:
|
|
122
108
|
- - ">="
|
123
109
|
- !ruby/object:Gem::Version
|
124
110
|
version: '0'
|
125
|
-
description:
|
111
|
+
description:
|
126
112
|
email: plribeiro3000@gmail.com
|
127
113
|
executables: []
|
128
114
|
extensions: []
|
@@ -140,6 +126,7 @@ files:
|
|
140
126
|
- Rakefile
|
141
127
|
- gemfiles/Gemfile.rails4
|
142
128
|
- gemfiles/Gemfile.rails5
|
129
|
+
- gemfiles/Gemfile.rails6
|
143
130
|
- lib/validates_cpf.rb
|
144
131
|
- lib/validates_cpf/cpf.rb
|
145
132
|
- lib/validates_cpf/cpf_validator.rb
|
@@ -151,11 +138,11 @@ files:
|
|
151
138
|
- spec/spec_helper.rb
|
152
139
|
- spec/validates_cpf/cpf_spec.rb
|
153
140
|
- validates_cpf.gemspec
|
154
|
-
homepage:
|
141
|
+
homepage:
|
155
142
|
licenses:
|
156
143
|
- MIT
|
157
144
|
metadata: {}
|
158
|
-
post_install_message:
|
145
|
+
post_install_message:
|
159
146
|
rdoc_options: []
|
160
147
|
require_paths:
|
161
148
|
- lib
|
@@ -170,14 +157,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
157
|
- !ruby/object:Gem::Version
|
171
158
|
version: '0'
|
172
159
|
requirements: []
|
173
|
-
|
174
|
-
|
175
|
-
signing_key:
|
160
|
+
rubygems_version: 3.1.6
|
161
|
+
signing_key:
|
176
162
|
specification_version: 4
|
177
163
|
summary: Validates CPF and test it with matchers in a simple way.
|
178
164
|
test_files:
|
179
165
|
- gemfiles/Gemfile.rails4
|
180
166
|
- gemfiles/Gemfile.rails5
|
167
|
+
- gemfiles/Gemfile.rails6
|
181
168
|
- spec/cpf_validator_spec.rb
|
182
169
|
- spec/fake_app/user.rb
|
183
170
|
- spec/shoulda/matchers/active_model/require_a_valid_cpf_matcher_spec.rb
|