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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 292219741d1a438dff93c5d02dd00b7b18cfb820
4
- data.tar.gz: 760682952992a9384edb2ab8a2a7509027d51cbe
2
+ SHA256:
3
+ metadata.gz: 0a37ca5ad49741054c33ec35e5e5a1b727fc993551102d2da5538d9758b9a335
4
+ data.tar.gz: f39bca2f2483fe444271fd4035828517ed3a44e319f09351ca50391c78f4b44d
5
5
  SHA512:
6
- metadata.gz: e6cb1728febb01c7b2bde35e21941200fef002dc9c002c623a0e0ed9e96974883f562d8fe15a562a89ca2077c31f84363d4be35ac68133ae17494976bd988959
7
- data.tar.gz: 0e23314307d0a01926c6b685288cdf15cb19897dbfad1b011d504fa4ef00a46c10d9ed9bd4f7049f5591bcc7c6f7872c838e329f7230c00913a4da5161d9ea06
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', '~> 0.7.1', group: :test, require: nil
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 [Working With Rails](http://www.workingwithrails.com/people/148426)!
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
@@ -1 +1,10 @@
1
1
  require "bundler/gem_tasks"
2
+
3
+ desc "Open an irb session preloaded with this library"
4
+ task :console do
5
+ require 'irb'
6
+ require 'irb/completion'
7
+ require 'cpf_utils'
8
+ ARGV.clear
9
+ IRB.start
10
+ end
@@ -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
- if self.valid_cpf?
37
- "#{self[0..2]}.#{self[3..5]}.#{self[6..8]}-#{self[9..11]}"
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
 
@@ -1,3 +1,3 @@
1
1
  module CpfUtils
2
- VERSION = "1.3.0"
2
+ VERSION = "1.3.1"
3
3
  end
@@ -8,7 +8,7 @@ describe CpfUtils do
8
8
  expect(cpf.numbers.size).to eql(9)
9
9
  end
10
10
 
11
- it "#initialize - Fixnum" do
11
+ it "#initialize - Integer" do
12
12
  cpf = CpfUtils::Cpf.new(123456789)
13
13
  expect(cpf.numbers).to be_a_kind_of(Array)
14
14
  expect(cpf.numbers.size).to eql(9)
@@ -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("123.456.789-12".valid_cpf_mask?).to be_true
9
- expect("12345678912".valid_cpf_mask?).to be_true
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("123.456.789-12".mascara_de_cpf_valida?).to be_true
14
- expect("12345678912".mascara_de_cpf_valida?).to be_true
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
 
@@ -1,13 +1,7 @@
1
- # Require Code Climate Test Reporter
2
- require "codeclimate-test-reporter"
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.0
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-03-13 00:00:00.000000000 Z
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.11
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