cpf_utils 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +1 -1
- data/README.md +6 -2
- data/Rakefile +9 -0
- data/lib/cpf_utils/string.rb +4 -2
- data/lib/cpf_utils/version.rb +1 -1
- data/spec/cpf_utils/cpf_spec.rb +1 -1
- data/spec/cpf_utils/string_spec.rb +9 -6
- data/spec/spec_helper.rb +2 -8
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0a37ca5ad49741054c33ec35e5e5a1b727fc993551102d2da5538d9758b9a335
|
4
|
+
data.tar.gz: f39bca2f2483fe444271fd4035828517ed3a44e319f09351ca50391c78f4b44d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69bcc4e4a0d95b19a377b890bb06ef10ed8c4b6793af3eaa7568e1c6256bb495a41e39fd1d7cf1ddfc121341fdcb04b9e1cd72cecb611bced8d64a0302510730
|
7
|
+
data.tar.gz: 2ad1523d41dbb230675ec474981de069d73cb83e031eb0a56264afcd8d66a48d107cd5f1eb830f7745e2f4a87a096621d5fc99ef2ff62fb7967c0a6bb5f5c9d1
|
data/Gemfile
CHANGED
@@ -5,7 +5,7 @@ gem "codeclimate-test-reporter", group: :test, require: nil
|
|
5
5
|
|
6
6
|
# Code coverage for Ruby 1.9+ with a powerful configuration library and
|
7
7
|
# automatic merging of coverage across test suites
|
8
|
-
gem 'simplecov',
|
8
|
+
gem 'simplecov', group: :test, require: nil
|
9
9
|
|
10
10
|
# A Ruby implementation of the Coveralls API.
|
11
11
|
gem 'coveralls', require: false
|
data/README.md
CHANGED
@@ -11,7 +11,7 @@ O CpfUtils é capaz de gerar CPF para testes no formado tradicional ou apenas nu
|
|
11
11
|
|
12
12
|
O CpfUtils usa o Travis-CI para efetuar testes em diferentes versões do Ruby. As versões testadas e aprovadas, por enquanto, são:
|
13
13
|
|
14
|
-
* MRI 1.9.2, 1.9.3, 2.0.0, 2.1.0
|
14
|
+
* MRI 1.9.2, 1.9.3, 2.0.0, 2.1.0, 2.2.0, 2.3.0, 2.4.0, 2.5.0
|
15
15
|
* JRuby 1.9.x
|
16
16
|
|
17
17
|
## Instalação
|
@@ -106,7 +106,7 @@ CpfUtils.cpf_valido?("111.111.111-11") => # false
|
|
106
106
|
|
107
107
|
## Recomende
|
108
108
|
|
109
|
-
Gostou dessa gem? Recomende-me no [
|
109
|
+
Gostou dessa gem? Recomende-me no [Linkedin](https://www.linkedin.com/in/jackson-pires-a0832b14)!
|
110
110
|
|
111
111
|
## Contribuindo
|
112
112
|
|
@@ -115,3 +115,7 @@ Gostou dessa gem? Recomende-me no [Working With Rails](http://www.workingwithrai
|
|
115
115
|
3. Faça o commit de suas alterações (`git commit -am 'Adicionada nova funcionalidade'`)
|
116
116
|
4. Faça um push da sua nova funconalidade (`git push origin minha-nova-funcionalidade`)
|
117
117
|
5. Submeta uma nova Pull Request
|
118
|
+
|
119
|
+
## Dica
|
120
|
+
|
121
|
+
Use ```rake console``` para iniciar uma sessão com o CpfUtils carreado.
|
data/Rakefile
CHANGED
data/lib/cpf_utils/string.rb
CHANGED
@@ -33,8 +33,10 @@ class String
|
|
33
33
|
#
|
34
34
|
# "45698394823".to_cpf_format => # "456.983.948-23"
|
35
35
|
def to_cpf_format
|
36
|
-
|
37
|
-
|
36
|
+
cleaned_cpf = self.gsub(/\.?-?/,"",)
|
37
|
+
|
38
|
+
if cleaned_cpf.valid_cpf?
|
39
|
+
"#{cleaned_cpf[0..2]}.#{cleaned_cpf[3..5]}.#{cleaned_cpf[6..8]}-#{cleaned_cpf[9..11]}"
|
38
40
|
end
|
39
41
|
end
|
40
42
|
|
data/lib/cpf_utils/version.rb
CHANGED
data/spec/cpf_utils/cpf_spec.rb
CHANGED
@@ -2,16 +2,17 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe String do
|
4
4
|
let(:valid_cpf) { CpfUtils.cpf }
|
5
|
+
let(:valid_formatted_cpf) { CpfUtils.cpf_formatted }
|
5
6
|
let(:invalid_cpf) { "11111111111" }
|
6
7
|
|
7
8
|
it "#valid_cpf_mask?" do
|
8
|
-
expect(
|
9
|
-
expect(
|
9
|
+
expect(valid_formatted_cpf.valid_cpf_mask?).to be_true
|
10
|
+
expect(valid_cpf.valid_cpf_mask?).to be_true
|
10
11
|
end
|
11
12
|
|
12
13
|
it "#mascara_de_cpf_valida?" do
|
13
|
-
expect(
|
14
|
-
expect(
|
14
|
+
expect(valid_formatted_cpf.mascara_de_cpf_valida?).to be_true
|
15
|
+
expect(valid_cpf.mascara_de_cpf_valida?).to be_true
|
15
16
|
end
|
16
17
|
|
17
18
|
it "#valid_cpf_mask? - be false" do
|
@@ -38,14 +39,16 @@ describe String do
|
|
38
39
|
expect(valid_cpf.cpf_valido?).to be_true
|
39
40
|
end
|
40
41
|
|
41
|
-
it "#to_cpf_format?" do
|
42
|
+
it "#to_cpf_format? - with unformatted cpf" do
|
42
43
|
expect(valid_cpf.to_cpf_format).to match(/^[0-9]{3}\.[0-9]{3}\.[0-9]{3}-[0-9]{2}+$/)
|
44
|
+
expect(valid_formatted_cpf.to_cpf_format).to match(/^[0-9]{3}\.[0-9]{3}\.[0-9]{3}-[0-9]{2}+$/)
|
43
45
|
end
|
44
46
|
|
45
47
|
it "#para_formato_cpf?" do
|
46
48
|
expect(valid_cpf.para_formato_cpf).to match(/^[0-9]{3}\.[0-9]{3}\.[0-9]{3}-[0-9]{2}+$/)
|
49
|
+
expect(valid_formatted_cpf.para_formato_cpf).to match(/^[0-9]{3}\.[0-9]{3}\.[0-9]{3}-[0-9]{2}+$/)
|
47
50
|
end
|
48
|
-
|
51
|
+
|
49
52
|
it "#generate_cpf" do
|
50
53
|
final_cpf = valid_cpf[0..8].generate_cpf
|
51
54
|
|
data/spec/spec_helper.rb
CHANGED
@@ -1,13 +1,7 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require 'simplecov'
|
2
|
+
SimpleCov.start
|
3
3
|
|
4
|
-
# Starts Code Climate Test Reporter
|
5
|
-
CodeClimate::TestReporter.start
|
6
|
-
|
7
|
-
# Require Coveralls for Test cover
|
8
4
|
require 'coveralls'
|
9
|
-
|
10
|
-
# Starts Coderalls
|
11
5
|
Coveralls.wear!
|
12
6
|
|
13
7
|
# Require other files of project
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cpf_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jackson Pires
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -95,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
95
|
version: '0'
|
96
96
|
requirements: []
|
97
97
|
rubyforge_project:
|
98
|
-
rubygems_version: 2.6
|
98
|
+
rubygems_version: 2.7.6
|
99
99
|
signing_key:
|
100
100
|
specification_version: 4
|
101
101
|
summary: Gera CPF para testes no formado tradicional ou apenas numérico, testa se
|