simple_cpf_cnpj 0.2.0 → 0.2.1

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: 41e0da4ce3a3e43a714856218408aba1bc77a3df
4
- data.tar.gz: 3c93d710cde92b4c50dbe1d7e58c6cf12d4903a1
3
+ metadata.gz: a53b162e8e98deec06c130069c7465b64a1fe2c2
4
+ data.tar.gz: dec703257e40319e30b49969d805b8e8992fb88e
5
5
  SHA512:
6
- metadata.gz: 1b6b189f8b91a78f2fef4bc146b66e66a78ba9e47e58b23356ac61e69a6c27d91c72efdb03939aa47de4dd7ac7e2ece862e975b406b0539e8bb3fcd94707a84d
7
- data.tar.gz: 1484d5fc8fcb3cef72d4645fdd2e12cdc01129c3a5bcf2834666aae9f9bea9d243ffe43746c44d8263e56f456cb7643d580a005f68ca6d0080273feddf1f16b1
6
+ metadata.gz: 669ae28ba2c0ea949352ad110fc397bc12c57535beb50a08f4bc9766abf5bcf869282f0ce3c036c5139f71894ba8039ce173414689cc67b758ee7fd4ea8a4b5d
7
+ data.tar.gz: be3a88bcff7fc58f110e4038a45dd0fc2b21765c2922d1d0f68df14307dcd5ab7de7a940bc664400f5d04ef05dfdac2f9d9ab43a1aad278db8098bb2bb521b41
data/Gemfile CHANGED
@@ -2,3 +2,8 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in cpf_cnpj.gemspec
4
4
  gemspec
5
+
6
+ if RUBY_VERSION > '1.8.7'
7
+ gem "codeclimate-test-reporter", :require => nil
8
+ end
9
+
@@ -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.
@@ -0,0 +1,115 @@
1
+ # simple_cpf_cnpj
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/simple_cpf_cnpj.svg)](https://rubygems.org/gems/simple_cpf_cnpj)
4
+ [![Build Status](https://travis-ci.org/davidsantos-br/simple_cpf_cnpj.svg)](https://travis-ci.org/davidsantos-br/simple_cpf_cnpj)
5
+ [![Code Climate](https://codeclimate.com/github/davidsantos-br/simple_cpf_cnpj/badges/gpa.svg)](https://codeclimate.com/github/davidsantos-br/simple_cpf_cnpj)
6
+ [![Test Coverage](https://codeclimate.com/github/davidsantos-br/simple_cpf_cnpj/badges/coverage.svg)](https://codeclimate.com/github/davidsantos-br/simple_cpf_cnpj/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/davidsantos-br/simple_cpf_cnpj/issues
110
+
111
+ ## Licença e copyright
112
+
113
+ Copyright (c) 2015 David Santos
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
- The gem `simple_cpf_cnpj` provides the module `CpfCnpj`, with utility
4
- methods for dealing with CPFs and CNPJs.
3
+ [![Gem Version](https://badge.fury.io/rb/simple_cpf_cnpj.svg)](https://rubygems.org/gems/simple_cpf_cnpj)
4
+ [![Build Status](https://travis-ci.org/davidsantos-br/simple_cpf_cnpj.svg)](https://travis-ci.org/davidsantos-br/simple_cpf_cnpj)
5
+ [![Code Climate](https://codeclimate.com/github/davidsantos-br/simple_cpf_cnpj/badges/gpa.svg)](https://codeclimate.com/github/davidsantos-br/simple_cpf_cnpj)
6
+ [![Test Coverage](https://codeclimate.com/github/davidsantos-br/simple_cpf_cnpj/badges/coverage.svg)](https://codeclimate.com/github/davidsantos-br/simple_cpf_cnpj/coverage)
5
7
 
6
- A CPF is a Brazilian federal ID number issued to natural persons, and a CNPJ
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 module provides methods for differentiating a CPF from a CNPJ, formatting,
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
- ### Expected format
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 in this module expect CPFs/CNPJs as strings, with only numbers. If
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 has been tested with MRI Ruby (1.8.7, 1.9.2, 1.9.3, 2.0.0, 2.1, and 2.2), JRuby, and Ruby Enterprise Edition 1.8.7.
18
+ The code is tested with Ruby (1.8.7, 1.9.2, 1.9.3, 2.0.0, 2.1, and 2.2), JRuby, and Ruby Enterprise Edition 1.8.7.
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
- ### Validate
58
- Use CpfCnpj.valid_cpf?, CpfCnpj.valid_cnpj?, or CpfCnpj.valid_cpf_cnpj? to
59
- check if a number is valid.
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
- ### Format
77
- Use CpfCnpj.format to format a CPF or CNPJ.
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
- ### Identify the type
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,12 +99,9 @@ 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
 
@@ -115,5 +112,4 @@ https://github.com/davidsantos-br/simple_cpf_cnpj.
115
112
 
116
113
  Copyright (c) 2015 David Santos
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
 
@@ -9,8 +9,14 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["David Santos"]
10
10
  spec.email = ["david@dsantosdev.com"]
11
11
 
12
- spec.summary = %q{Provides the module CpfCnpj, with functions to detect, format, and validate CPFs and CNPJs.}
13
- spec.description = %q{Provides the module CpfCnpj, with functions to detect, validate, and format CPFs and CNPJs (Brazilian federal ID numbers).}
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
14
20
  spec.homepage = "https://github.com/davidsantos-br/simple_cpf_cnpj"
15
21
  spec.license = "MIT"
16
22
 
@@ -19,7 +25,7 @@ Gem::Specification.new do |spec|
19
25
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
26
  spec.require_paths = ["lib"]
21
27
  spec.required_ruby_version = '>= 1.8.7'
22
- spec.extra_rdoc_files = ['README.md', 'LICENSE']
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
31
  spec.add_development_dependency "bundler", "~> 1.10"
@@ -14,8 +14,8 @@ 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
- BLACKLIST_CPF = %w{00000000000 11111111111 22222222222 33333333333 44444444444 55555555555 66666666666 77777777777 88888888888 99999999999}
18
- BLACKLIST_CNPJ = %w{00000000000000 11111111111111 22222222222222 33333333333333 44444444444444 55555555555555 66666666666666 77777777777777 88888888888888 99999999999999}
17
+ BLACKLIST_CPF = %w{00000000000 11111111111 22222222222 33333333333 44444444444 55555555555 66666666666 77777777777 88888888888 99999999999} # :nodoc:
18
+ BLACKLIST_CNPJ = %w{00000000000000 11111111111111 22222222222222 33333333333333 44444444444444 55555555555555 66666666666666 77777777777777 88888888888888 99999999999999} # :nodoc:
19
19
  # Checks the length of +cpf_or_cnpj+ to determine if it's a CPF or a CNPJ.
20
20
  #
21
21
  # CpfCnpj.type_of("12345678987") # 11 characters
@@ -1,3 +1,3 @@
1
1
  module CpfCnpj # :nodoc:
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_cpf_cnpj
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Santos
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-07-03 00:00:00.000000000 Z
11
+ date: 2015-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,20 +66,28 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- description: Provides the module CpfCnpj, with functions to detect, validate, and
70
- format CPFs and CNPJs (Brazilian federal ID numbers).
69
+ description: |
70
+ Provides the module CpfCnpj, with methods that detect, validate, and format CPFs and CNPJs (Brazilian federal ID numbers).
71
+
72
+ //
73
+
74
+ Fornece o módulo CpfCnpj, com funções que detectam, validam, e formatam CPFs e CNPJs.
71
75
  email:
72
76
  - david@dsantosdev.com
73
77
  executables: []
74
78
  extensions: []
75
79
  extra_rdoc_files:
76
80
  - README.md
81
+ - README-pt.md
77
82
  - LICENSE
83
+ - LICENSE-pt
78
84
  files:
79
85
  - ".gitignore"
80
86
  - ".travis.yml"
81
87
  - Gemfile
82
88
  - LICENSE
89
+ - LICENSE-pt
90
+ - README-pt.md
83
91
  - README.md
84
92
  - Rakefile
85
93
  - bin/console
@@ -114,6 +122,6 @@ rubyforge_project:
114
122
  rubygems_version: 2.4.8
115
123
  signing_key:
116
124
  specification_version: 4
117
- summary: Provides the module CpfCnpj, with functions to detect, format, and validate
125
+ summary: Provides the module CpfCnpj, with methods that detect, format, and validate
118
126
  CPFs and CNPJs.
119
127
  test_files: []