simple_cpf_cnpj 0.1.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c48ec6a7277ae88f6940a5f497f016ab1fb40722
4
- data.tar.gz: 8705d45f357935c0f251ccbe6d5025c5d077761e
3
+ metadata.gz: 41e0da4ce3a3e43a714856218408aba1bc77a3df
4
+ data.tar.gz: 3c93d710cde92b4c50dbe1d7e58c6cf12d4903a1
5
5
  SHA512:
6
- metadata.gz: 398e74ab0a04215fb60246520fd45d922122543ec5a70b6f333f584633d9c97217a42841bf0ce43d71bb77a5cf45473f033b5a026cc5fddd37a681817d66be70
7
- data.tar.gz: b91dedda38533dad0f18d1e27125d9396e44bffeb285bec3b69b54e609817574776b47a8d7e739359c8ad461d48e95cf11861a837631e05724e3e062e84a543d
6
+ metadata.gz: 1b6b189f8b91a78f2fef4bc146b66e66a78ba9e47e58b23356ac61e69a6c27d91c72efdb03939aa47de4dd7ac7e2ece862e975b406b0539e8bb3fcd94707a84d
7
+ data.tar.gz: 1484d5fc8fcb3cef72d4645fdd2e12cdc01129c3a5bcf2834666aae9f9bea9d243ffe43746c44d8263e56f456cb7643d580a005f68ca6d0080273feddf1f16b1
data/Rakefile CHANGED
@@ -10,6 +10,7 @@ end
10
10
 
11
11
  RDoc::Task.new(:doc) do |rd|
12
12
  rd.main = "README.md"
13
+ rd.title = "simple_cpf_cnpj -- CPF/CNPJ utility methods"
13
14
  rd.rdoc_files.include("README.md", "LICENSE", "lib/**/*.rb")
14
15
  rd.rdoc_dir = "doc/v#{CpfCnpj::VERSION}"
15
16
  end
data/cpf_cnpj.gemspec CHANGED
@@ -19,6 +19,8 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
21
  spec.required_ruby_version = '>= 1.8.7'
22
+ spec.extra_rdoc_files = ['README.md', 'LICENSE']
23
+ spec.rdoc_options << '--title' << 'simple_cpf_cnpj -- CPF/CNPJ utility methods' << '--main' << 'README.md'
22
24
 
23
25
  spec.add_development_dependency "bundler", "~> 1.10"
24
26
  spec.add_development_dependency "rake", "~> 10.0"
@@ -1,3 +1,3 @@
1
1
  module CpfCnpj # :nodoc:
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -14,6 +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
19
  # Checks the length of +cpf_or_cnpj+ to determine if it's a CPF or a CNPJ.
18
20
  #
19
21
  # CpfCnpj.type_of("12345678987") # 11 characters
@@ -74,7 +76,7 @@ module CpfCnpj
74
76
  # CpfCnpj.valid_cpf?(11026822840)
75
77
  # # ArgumentError: argument must be a string or nil
76
78
  def self.valid_cpf?(cpf)
77
- return type_of(cpf) == :cpf && _mod11_check(cpf, 11)
79
+ return type_of(cpf) == :cpf && !BLACKLIST_CPF.include?(cpf) && _mod11_check(cpf, 11)
78
80
  end
79
81
 
80
82
  # Validates +cnpj+ as a CNPJ by verifying that the check digits match.
@@ -90,7 +92,7 @@ module CpfCnpj
90
92
  # CpfCnpj.valid_cnpj?(63871464000193)
91
93
  # # ArgumentError: argument must be a string or nil
92
94
  def self.valid_cnpj?(cnpj)
93
- return type_of(cnpj) == :cnpj && _mod11_check(cnpj, 9)
95
+ return type_of(cnpj) == :cnpj && !BLACKLIST_CNPJ.include?(cnpj) && _mod11_check(cnpj, 9)
94
96
  end
95
97
 
96
98
  # Validates +cnpj_or_cnpj+ as either a CPF or a CNPJ by verifying that the check digits match.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_cpf_cnpj
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Santos
@@ -72,7 +72,9 @@ email:
72
72
  - david@dsantosdev.com
73
73
  executables: []
74
74
  extensions: []
75
- extra_rdoc_files: []
75
+ extra_rdoc_files:
76
+ - README.md
77
+ - LICENSE
76
78
  files:
77
79
  - ".gitignore"
78
80
  - ".travis.yml"
@@ -90,7 +92,11 @@ licenses:
90
92
  - MIT
91
93
  metadata: {}
92
94
  post_install_message:
93
- rdoc_options: []
95
+ rdoc_options:
96
+ - "--title"
97
+ - simple_cpf_cnpj -- CPF/CNPJ utility methods
98
+ - "--main"
99
+ - README.md
94
100
  require_paths:
95
101
  - lib
96
102
  required_ruby_version: !ruby/object:Gem::Requirement