simple_cpf_cnpj 0.2.0 → 1.0.0
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 +5 -5
- data/.github/workflows/run-tests.yml +39 -0
- data/LICENSE-pt +22 -0
- data/README-pt.md +115 -0
- data/README.md +31 -35
- data/Rakefile +1 -1
- data/cpf_cnpj.gemspec +18 -9
- data/lib/simple_cpf_cnpj/version.rb +1 -1
- data/lib/simple_cpf_cnpj.rb +10 -11
- metadata +42 -21
- data/.travis.yml +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 33d8c4ceb8a8556943bd640f38d95384b7279519a363898bf04bee11fed393ca
|
4
|
+
data.tar.gz: a6aa380b3c55726ebba1cd1d69fae2665b4ead0d9926a299fb1b95db85e6446b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 973b38cf363d44154c46586b8ccc68e7d20626b889e0b2ccb671a7308dee37f202ae512203b352d309068c1d3741bcab08c5e450c772f2a4d280056a4aa9d38c
|
7
|
+
data.tar.gz: 5d5c1a72ec0f9cd82db9b2beb7ba939c2c5953fb016767f30f8cf9f3fb669b3383a97e6a0a4f3168291e4df7cb004346647ef5f8069928b60fca32ca4090c088
|
@@ -0,0 +1,39 @@
|
|
1
|
+
name: run-tests
|
2
|
+
on: [push]
|
3
|
+
jobs:
|
4
|
+
test:
|
5
|
+
runs-on: ubuntu-latest
|
6
|
+
strategy:
|
7
|
+
matrix:
|
8
|
+
ruby-version: ['3.2', '3.1', '3.0', '2.7', '2.3', '2.2', '2.1.9', '2.0.0', 'jruby', 'truffleruby']
|
9
|
+
env:
|
10
|
+
NO_COVERAGE: '1'
|
11
|
+
steps:
|
12
|
+
- uses: actions/checkout@v3
|
13
|
+
- name: Set up Ruby ${{ matrix.ruby-version }}
|
14
|
+
uses: ruby/setup-ruby@v1
|
15
|
+
with:
|
16
|
+
ruby-version: ${{ matrix.ruby-version }}
|
17
|
+
bundler-cache: true
|
18
|
+
- name: Install dependencies
|
19
|
+
run: bundle install
|
20
|
+
- name: Run tests
|
21
|
+
run: bundle exec rake test
|
22
|
+
coverage:
|
23
|
+
needs: [ test ]
|
24
|
+
runs-on: ubuntu-latest
|
25
|
+
steps:
|
26
|
+
- uses: actions/checkout@v3
|
27
|
+
- name: Set up Ruby ${{ matrix.ruby-version }}
|
28
|
+
uses: ruby/setup-ruby@v1
|
29
|
+
with:
|
30
|
+
ruby-version: '3.2'
|
31
|
+
bundler-cache: true
|
32
|
+
- name: Install dependencies
|
33
|
+
run: bundle install
|
34
|
+
- name: Test & publish code coverage
|
35
|
+
uses: paambaati/codeclimate-action@v3.2.0
|
36
|
+
env:
|
37
|
+
CC_TEST_REPORTER_ID: 78cf86ace5d24f5d0417cf92d63d5bf039a2a3023678acfec103fe36d4c4b0e4
|
38
|
+
with:
|
39
|
+
coverageCommand: bundle exec rake test
|
data/LICENSE-pt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
A licença MIT
|
2
|
+
|
3
|
+
Copyright (c) 2015 David Santos
|
4
|
+
|
5
|
+
É dada permissão, livre de encargos, a qualquer pessoa que obtiver uma cópia
|
6
|
+
deste software e documentação associada (o "Software"), para utilizar o Software
|
7
|
+
sem restrições, incluindo os direitos de usar, copiar, modificar, fundir,
|
8
|
+
publicar, distribuir, sub-licenciar e/ou vender cópias do Software, sem
|
9
|
+
restrições, e de permitir o mesmo àqueles a quem fornecer o Software,
|
10
|
+
respeitando-se as seguintes condições:
|
11
|
+
|
12
|
+
A declaração de direitos autorais dada acima e esta nota de permissão deverão
|
13
|
+
ser incluídas em todas as cópias ou partes substanciais do Software.
|
14
|
+
|
15
|
+
O SOFTWARE É FORNECIDO "NO ESTADO EM QUE SE ENCONTRA", SEM GARANTIAS DE QUALQUER
|
16
|
+
TIPO, SEJAM EXPRESSAS OU IMPLÍCITAS, INCLUINDO MAS NÃO SE LIMITANDO ÀS GARANTIAS
|
17
|
+
DE MERCABILIDADE, ADEQUAÇÃO A UM PROPÓSITO ESPECÍFICO, E NÃO-VIOLAÇÃO. EM
|
18
|
+
NENHUMA HIPÓTESE PODERÃO OS AUTORES E/OU OS DETENTORES DOS DIREITOS AUTORAIS SER
|
19
|
+
RESPONSABILIZADOS EM QUALQUER REIVINDICAÇÃO, REPARAÇÃO DE DANOS, OU OUTRA
|
20
|
+
RECLAMAÇÃO LEGAL, SEJA EM UMA AÇÃO CONTRATUAL, CÍVEL, OU DE QUALQUER OUTRO TIPO,
|
21
|
+
QUE TENHA ORIGEM EM, A PARTIR DE, OU EM CONEXÃO COM O SOFTWARE, SUA UTILIZAÇÃO,
|
22
|
+
OU OUTROS ATOS QUE O ENVOLVAM.
|
data/README-pt.md
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
# simple_cpf_cnpj
|
2
|
+
|
3
|
+
[](https://rubygems.org/gems/simple_cpf_cnpj)
|
4
|
+

|
5
|
+
[](https://codeclimate.com/github/DaviMedrade/simple_cpf_cnpj/maintainability)
|
6
|
+
[](https://codeclimate.com/github/DaviMedrade/simple_cpf_cnpj/test_coverage)
|
7
|
+
|
8
|
+
**English Version:** [README.md](rdoc-ref:README.md)
|
9
|
+
|
10
|
+
A gem `simple_cpf_cnpj` fornece o módulo CpfCnpj, que possui métodos utilitários para lidar com CPFs e CNPJs.
|
11
|
+
|
12
|
+
Um CPF é um número de identificação federal brasileiro emitido para pessoas físicas, e um CNPJ é o equivalente para pessoas jurídicas (empresas e afins).
|
13
|
+
|
14
|
+
O módulo fornece métodos para diferenciar um CPF de um CNPJ, formatar, e validar os números por meio da confirmação dos dígitos verificadores.
|
15
|
+
|
16
|
+
## Compatibilidade
|
17
|
+
|
18
|
+
O código é testado com o Ruby (1.8.7, 1.9.2, 1.9.3, 2.0.0, 2.1, and 2.2), JRuby, e Ruby Enterprise Edition 1.8.7.
|
19
|
+
|
20
|
+
## Instalação
|
21
|
+
|
22
|
+
Adicione esta linha ao Gemfile da sua aplicação:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
gem 'simple_cpf_cnpj'
|
26
|
+
```
|
27
|
+
|
28
|
+
Em seguida, execute:
|
29
|
+
|
30
|
+
```
|
31
|
+
$ bundle
|
32
|
+
```
|
33
|
+
|
34
|
+
Ou faça a instalação manualmente:
|
35
|
+
|
36
|
+
```
|
37
|
+
$ gem install simple_cpf_cnpj
|
38
|
+
```
|
39
|
+
|
40
|
+
## Utilização
|
41
|
+
|
42
|
+
A documentação completa pode ser encontrada em: http://docs.dsantosdev.com/simple_cpf_cnpj/
|
43
|
+
|
44
|
+
Se for necessário para a sua instalação, adicione isto ao seu código, no local adequado:
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
require 'simple_cpf_cnpj'
|
48
|
+
```
|
49
|
+
|
50
|
+
### Representação de CPF/CNPJ
|
51
|
+
|
52
|
+
Os métodos neste módulo esperam que CPFs/CNPJs sejam passados como strings contendo somente caracteres numéricos. Se a string que você tem estiver formatada, é responsabilidade sua remover a pontuação antes de chamar métodos de CpfCnpj.
|
53
|
+
|
54
|
+
Isso pode ser feito dessa forma, por exemplo:
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
CpfCnpj.valid_cpf?(formatted_cpf.gsub(/\D/, ''))
|
58
|
+
```
|
59
|
+
|
60
|
+
### Validando CPFs e CNPJs
|
61
|
+
Use CpfCnpj.valid_cpf?, CpfCnpj.valid_cnpj?, ou CpfCnpj.valid_cpf_cnpj? para verificar se um número é válido.
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
CpfCnpj.valid_cpf?("12345678900") # inválido
|
65
|
+
# => false
|
66
|
+
CpfCnpj.valid_cpf?("11026822840") # válido
|
67
|
+
# => true
|
68
|
+
CpfCnpj.valid_cnpj?("12345678000100") # inválido
|
69
|
+
# => false
|
70
|
+
CpfCnpj.valid_cnpj?("63871464000193") # válido
|
71
|
+
# => true
|
72
|
+
CpfCnpj.valid_cpf_cnpj?("11026822840") # CPF válido
|
73
|
+
# => true
|
74
|
+
CpfCnpj.valid_cpf_cnpj?("63871464000193") # CNPJ válido
|
75
|
+
# => true
|
76
|
+
```
|
77
|
+
|
78
|
+
### Formatando CPFs e CNPJs
|
79
|
+
Use CpfCnpj.format para obter uma representação formatada de um CPF ou CNPJ.
|
80
|
+
|
81
|
+
```ruby
|
82
|
+
CpfCnpj.format("12345678987") # 11 dígitos (CPF)
|
83
|
+
# => "123.456.789-87"
|
84
|
+
CpfCnpj.format("01234567000198") # 14 dígitos (CNPJ)
|
85
|
+
# => "01.234.567/0001-98"
|
86
|
+
```
|
87
|
+
|
88
|
+
### Distinguindo CPFs de CNPJs
|
89
|
+
Use CpfCnpj.type_of para determinar se um número é um CPF ou um CNPJ. Note que esta verificação se baseia apenas no comprimento da string. Os caracteres que compõem a string nem chegam a ser acessados.
|
90
|
+
|
91
|
+
```ruby
|
92
|
+
CpfCnpj.type_of("12345678987") # 11 dígitos
|
93
|
+
# => :cpf
|
94
|
+
CpfCnpj.type_of("123456789876") # 12 dígitos
|
95
|
+
# => nil
|
96
|
+
CpfCnpj.type_of("01234567000198") # 14 dígitos
|
97
|
+
# => :cnpj
|
98
|
+
```
|
99
|
+
|
100
|
+
## Desenvolvimento
|
101
|
+
|
102
|
+
**Aviso:** isto não é necessário para poder utilizar a gem, apenas para fazer alterações ou executar os testes inclusos.
|
103
|
+
|
104
|
+
Após fazer checkout do repositório, execute `bin/setup` para instalar as dependências. Depois, execute `rake test` para rodar os testes. Você também pode executar `bin/console` para acessar uma prompt interativa onde você pode experimentar.
|
105
|
+
|
106
|
+
## Contribuindo
|
107
|
+
|
108
|
+
Relatórios de bugs e pull requests são bem-vindos. Envie pelo GitHub:
|
109
|
+
https://github.com/DaviMedrade/simple_cpf_cnpj/issues
|
110
|
+
|
111
|
+
## Licença e copyright
|
112
|
+
|
113
|
+
Copyright © 2015-2023 Davi Medrade
|
114
|
+
|
115
|
+
Este software é publicado sob a licença MIT, que pode ser encontrada no arquivo [LICENSE](rdoc-ref:LICENSE-pt).
|
data/README.md
CHANGED
@@ -1,28 +1,21 @@
|
|
1
1
|
# simple_cpf_cnpj
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
[](https://rubygems.org/gems/simple_cpf_cnpj)
|
4
|
+

|
5
|
+
[](https://codeclimate.com/github/DaviMedrade/simple_cpf_cnpj/maintainability)
|
6
|
+
[](https://codeclimate.com/github/DaviMedrade/simple_cpf_cnpj/test_coverage)
|
5
7
|
|
6
|
-
|
7
|
-
is its counterpart for juridic persons (companies and the like).
|
8
|
+
**Versão em Português:** [README-pt.md](rdoc-ref:README-pt.md)
|
8
9
|
|
9
|
-
The
|
10
|
-
and validating the numbers by verifying the check digits.
|
10
|
+
The gem `simple_cpf_cnpj` provides the module CpfCnpj, which has utility methods for dealing with CPFs and CNPJs.
|
11
11
|
|
12
|
-
|
12
|
+
A CPF is a Brazilian federal ID number issued to natural persons, and a CNPJ is its counterpart for juridic persons (companies and the like).
|
13
13
|
|
14
|
-
The methods
|
15
|
-
the string is formatted, it's up to you to remove the punctuation.
|
16
|
-
|
17
|
-
For example:
|
18
|
-
|
19
|
-
```ruby
|
20
|
-
CpfCnpj.valid_cpf?(formatted_cpf.gsub(/\D/, ''))
|
21
|
-
```
|
14
|
+
The module provides methods to differentiate a CPF from a CNPJ, format, and validate the numbers by verifying the check digits.
|
22
15
|
|
23
16
|
## Compatibility
|
24
17
|
|
25
|
-
The code
|
18
|
+
The code is tested with MRI Ruby 2.0-3.2, JRuby, and TruffleRuby.
|
26
19
|
|
27
20
|
## Installation
|
28
21
|
|
@@ -54,9 +47,18 @@ If necessary for your installation, add this to your code in the appropriate pla
|
|
54
47
|
require 'simple_cpf_cnpj'
|
55
48
|
```
|
56
49
|
|
57
|
-
###
|
58
|
-
|
59
|
-
|
50
|
+
### CPF/CNPJ representation
|
51
|
+
|
52
|
+
The methods in this module expect CPFs/CNPJs to be passed as strings comprised only of numeric characters. If the string you have is formatted, it's up to you to remove the punctuation before calling CpfCnpj methods.
|
53
|
+
|
54
|
+
Here's an example of how to do that:
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
CpfCnpj.valid_cpf?(formatted_cpf.gsub(/\D/, ''))
|
58
|
+
```
|
59
|
+
|
60
|
+
### Validating CPFs and CNPJs
|
61
|
+
Use CpfCnpj.valid_cpf?, CpfCnpj.valid_cnpj?, or CpfCnpj.valid_cpf_cnpj? to check if a number is valid.
|
60
62
|
|
61
63
|
```ruby
|
62
64
|
CpfCnpj.valid_cpf?("12345678900") # invalid
|
@@ -73,8 +75,8 @@ CpfCnpj.valid_cpf_cnpj?("63871464000193") # valid CNPJ
|
|
73
75
|
# => true
|
74
76
|
```
|
75
77
|
|
76
|
-
###
|
77
|
-
Use CpfCnpj.format to
|
78
|
+
### Formatting CPFs and CNPJs
|
79
|
+
Use CpfCnpj.format to get a formatted representation of a CPF or CNPJ.
|
78
80
|
|
79
81
|
```ruby
|
80
82
|
CpfCnpj.format("12345678987") # 11 characters (CPF)
|
@@ -83,10 +85,8 @@ CpfCnpj.format("01234567000198") # 14 characters (CNPJ)
|
|
83
85
|
# => "01.234.567/0001-98"
|
84
86
|
```
|
85
87
|
|
86
|
-
###
|
87
|
-
Use CpfCnpj.type_of to determine if a number is a CPF or a CNPJ. Note that
|
88
|
-
this check is only based on the length of the string. The actual characters in
|
89
|
-
the string aren't checked at all.
|
88
|
+
### Telling CPFs and CNPJs apart
|
89
|
+
Use CpfCnpj.type_of to determine if a number is a CPF or a CNPJ. Note that this check is only based on the length of the string. The actual characters in the string aren't checked at all.
|
90
90
|
|
91
91
|
```ruby
|
92
92
|
CpfCnpj.type_of("12345678987") # 11 characters
|
@@ -99,21 +99,17 @@ CpfCnpj.type_of("01234567000198") # 14 characters
|
|
99
99
|
|
100
100
|
## Development
|
101
101
|
|
102
|
-
**Note:** this is not necessary in order to use the gem, only to make changes
|
103
|
-
or run the included tests.
|
102
|
+
**Note:** this is not necessary in order to use the gem, only to make changes or run the included tests.
|
104
103
|
|
105
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then,
|
106
|
-
run `rake test` to run the tests. You can also run `bin/console` for an
|
107
|
-
interactive prompt that will allow you to experiment.
|
104
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
108
105
|
|
109
106
|
## Contributing
|
110
107
|
|
111
|
-
Bug reports and pull requests are welcome on GitHub
|
112
|
-
https://github.com/
|
108
|
+
Bug reports and pull requests are welcome on GitHub:
|
109
|
+
https://github.com/DaviMedrade/simple_cpf_cnpj/issues
|
113
110
|
|
114
111
|
## License and copyright
|
115
112
|
|
116
|
-
Copyright
|
113
|
+
Copyright © 2015-2023 Davi Medrade
|
117
114
|
|
118
|
-
This software is released under the MIT license, which can be found in the
|
119
|
-
file [LICENSE](rdoc-ref:LICENSE).
|
115
|
+
This software is released under the MIT license, which can be found in the file [LICENSE](rdoc-ref:LICENSE).
|
data/Rakefile
CHANGED
@@ -11,7 +11,7 @@ end
|
|
11
11
|
RDoc::Task.new(:doc) do |rd|
|
12
12
|
rd.main = "README.md"
|
13
13
|
rd.title = "simple_cpf_cnpj -- CPF/CNPJ utility methods"
|
14
|
-
rd.rdoc_files.include("README.md", "LICENSE", "lib/**/*.rb")
|
14
|
+
rd.rdoc_files.include("README.md", "README-pt.md", "LICENSE", "LICENSE-pt", "lib/**/*.rb")
|
15
15
|
rd.rdoc_dir = "doc/v#{CpfCnpj::VERSION}"
|
16
16
|
end
|
17
17
|
|
data/cpf_cnpj.gemspec
CHANGED
@@ -6,24 +6,33 @@ require 'simple_cpf_cnpj/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "simple_cpf_cnpj"
|
8
8
|
spec.version = CpfCnpj::VERSION
|
9
|
-
spec.authors = ["
|
10
|
-
spec.email = ["
|
9
|
+
spec.authors = ["Davi Medrade"]
|
10
|
+
spec.email = ["davi@medrade.com.br"]
|
11
11
|
|
12
|
-
spec.summary = %q{Provides the module CpfCnpj, with
|
13
|
-
spec.description =
|
14
|
-
|
12
|
+
spec.summary = %q{Provides the module CpfCnpj, with methods that detect, format, and validate CPFs and CNPJs.}
|
13
|
+
spec.description = <<EOT
|
14
|
+
Provides the module CpfCnpj, with methods that detect, validate, and format CPFs and CNPJs (Brazilian federal ID numbers).
|
15
|
+
|
16
|
+
//
|
17
|
+
|
18
|
+
Fornece o módulo CpfCnpj, com funções que detectam, validam, e formatam CPFs e CNPJs.
|
19
|
+
EOT
|
20
|
+
spec.homepage = "https://github.com/DaviMedrade/simple_cpf_cnpj"
|
15
21
|
spec.license = "MIT"
|
16
22
|
|
17
23
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
24
|
spec.bindir = "exe"
|
19
25
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
26
|
spec.require_paths = ["lib"]
|
21
|
-
spec.required_ruby_version = '>=
|
22
|
-
spec.extra_rdoc_files = ['README.md', 'LICENSE']
|
27
|
+
spec.required_ruby_version = '>= 2.0.0'
|
28
|
+
spec.extra_rdoc_files = ['README.md', 'README-pt.md', 'LICENSE', 'LICENSE-pt']
|
23
29
|
spec.rdoc_options << '--title' << 'simple_cpf_cnpj -- CPF/CNPJ utility methods' << '--main' << 'README.md'
|
24
30
|
|
25
|
-
spec.add_development_dependency "bundler", "
|
26
|
-
spec.add_development_dependency "rake"
|
31
|
+
spec.add_development_dependency "bundler", "> 1.10"
|
32
|
+
spec.add_development_dependency "rake"
|
27
33
|
spec.add_development_dependency "minitest"
|
28
34
|
spec.add_development_dependency "rdoc"
|
35
|
+
unless ENV['NO_COVERAGE']
|
36
|
+
spec.add_development_dependency "simplecov"
|
37
|
+
end
|
29
38
|
end
|
data/lib/simple_cpf_cnpj.rb
CHANGED
@@ -14,8 +14,11 @@ require "simple_cpf_cnpj/version"
|
|
14
14
|
# One way to do that is, for example:
|
15
15
|
# CpfCnpj.valid_cpf?(formatted_cpf.gsub(/\D/, ''))
|
16
16
|
module CpfCnpj
|
17
|
-
|
18
|
-
|
17
|
+
LENGTH_CPF = 11
|
18
|
+
LENGTH_CNPJ = 14
|
19
|
+
BLACKLIST_CPF = (0..9).collect{|n| n.to_s * LENGTH_CPF } # :nodoc:
|
20
|
+
BLACKLIST_CNPJ = (0..9).collect{|n| n.to_s * LENGTH_CNPJ } # :nodoc:
|
21
|
+
|
19
22
|
# Checks the length of +cpf_or_cnpj+ to determine if it's a CPF or a CNPJ.
|
20
23
|
#
|
21
24
|
# CpfCnpj.type_of("12345678987") # 11 characters
|
@@ -28,14 +31,14 @@ module CpfCnpj
|
|
28
31
|
# # => nil
|
29
32
|
# CpfCnpj.type_of(12345678987)
|
30
33
|
# # ArgumentError: argument must be a string or nil
|
31
|
-
|
34
|
+
def self.type_of(cpf_cnpj) # :arg: cpf_or_cnpj
|
32
35
|
return nil if cpf_cnpj.nil?
|
33
36
|
unless cpf_cnpj.is_a?(String)
|
34
37
|
raise(ArgumentError, "argument must be a string or nil")
|
35
38
|
end
|
36
39
|
case cpf_cnpj.length
|
37
|
-
when
|
38
|
-
when
|
40
|
+
when LENGTH_CPF ; :cpf
|
41
|
+
when LENGTH_CNPJ ; :cnpj
|
39
42
|
else ; nil
|
40
43
|
end
|
41
44
|
end
|
@@ -95,7 +98,7 @@ module CpfCnpj
|
|
95
98
|
return type_of(cnpj) == :cnpj && !BLACKLIST_CNPJ.include?(cnpj) && _mod11_check(cnpj, 9)
|
96
99
|
end
|
97
100
|
|
98
|
-
# Validates +
|
101
|
+
# Validates +cpf_or_cnpj+ as either a CPF or a CNPJ by verifying that the check digits match.
|
99
102
|
#
|
100
103
|
# CpfCnpj.valid_cpf_cnpj?("12345678900") # invalid CPF
|
101
104
|
# # => false
|
@@ -132,11 +135,7 @@ module CpfCnpj
|
|
132
135
|
_mod11_check_digit(digits[0..-2], mult_max) && _mod11_check_digit(digits, mult_max)
|
133
136
|
end
|
134
137
|
|
135
|
-
# ruby 1.8.7 doesn't have String#ord, and in versions after 1.8.7 String#[num] returns a
|
136
|
-
# one-character string instead of the byte value of the character.
|
137
|
-
# Since the return of this is always used to perform what is essentially an unclamped to_i
|
138
|
-
# on the first character, do it right here.
|
139
138
|
def self._int_value(str) # :nodoc:
|
140
|
-
|
139
|
+
str.ord - 48
|
141
140
|
end
|
142
141
|
end
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_cpf_cnpj
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
8
|
-
autorequire:
|
7
|
+
- Davi Medrade
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.10'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.10'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,20 +66,42 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
|
70
|
-
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: |
|
84
|
+
Provides the module CpfCnpj, with methods that detect, validate, and format CPFs and CNPJs (Brazilian federal ID numbers).
|
85
|
+
|
86
|
+
//
|
87
|
+
|
88
|
+
Fornece o módulo CpfCnpj, com funções que detectam, validam, e formatam CPFs e CNPJs.
|
71
89
|
email:
|
72
|
-
-
|
90
|
+
- davi@medrade.com.br
|
73
91
|
executables: []
|
74
92
|
extensions: []
|
75
93
|
extra_rdoc_files:
|
76
94
|
- README.md
|
95
|
+
- README-pt.md
|
77
96
|
- LICENSE
|
97
|
+
- LICENSE-pt
|
78
98
|
files:
|
99
|
+
- ".github/workflows/run-tests.yml"
|
79
100
|
- ".gitignore"
|
80
|
-
- ".travis.yml"
|
81
101
|
- Gemfile
|
82
102
|
- LICENSE
|
103
|
+
- LICENSE-pt
|
104
|
+
- README-pt.md
|
83
105
|
- README.md
|
84
106
|
- Rakefile
|
85
107
|
- bin/console
|
@@ -87,11 +109,11 @@ files:
|
|
87
109
|
- cpf_cnpj.gemspec
|
88
110
|
- lib/simple_cpf_cnpj.rb
|
89
111
|
- lib/simple_cpf_cnpj/version.rb
|
90
|
-
homepage: https://github.com/
|
112
|
+
homepage: https://github.com/DaviMedrade/simple_cpf_cnpj
|
91
113
|
licenses:
|
92
114
|
- MIT
|
93
115
|
metadata: {}
|
94
|
-
post_install_message:
|
116
|
+
post_install_message:
|
95
117
|
rdoc_options:
|
96
118
|
- "--title"
|
97
119
|
- simple_cpf_cnpj -- CPF/CNPJ utility methods
|
@@ -103,17 +125,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
103
125
|
requirements:
|
104
126
|
- - ">="
|
105
127
|
- !ruby/object:Gem::Version
|
106
|
-
version:
|
128
|
+
version: 2.0.0
|
107
129
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
130
|
requirements:
|
109
131
|
- - ">="
|
110
132
|
- !ruby/object:Gem::Version
|
111
133
|
version: '0'
|
112
134
|
requirements: []
|
113
|
-
|
114
|
-
|
115
|
-
signing_key:
|
135
|
+
rubygems_version: 3.3.23
|
136
|
+
signing_key:
|
116
137
|
specification_version: 4
|
117
|
-
summary: Provides the module CpfCnpj, with
|
138
|
+
summary: Provides the module CpfCnpj, with methods that detect, format, and validate
|
118
139
|
CPFs and CNPJs.
|
119
140
|
test_files: []
|