simple_cpf_cnpj 0.2.1 → 1.0.0

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: a53b162e8e98deec06c130069c7465b64a1fe2c2
4
- data.tar.gz: dec703257e40319e30b49969d805b8e8992fb88e
2
+ SHA256:
3
+ metadata.gz: 33d8c4ceb8a8556943bd640f38d95384b7279519a363898bf04bee11fed393ca
4
+ data.tar.gz: a6aa380b3c55726ebba1cd1d69fae2665b4ead0d9926a299fb1b95db85e6446b
5
5
  SHA512:
6
- metadata.gz: 669ae28ba2c0ea949352ad110fc397bc12c57535beb50a08f4bc9766abf5bcf869282f0ce3c036c5139f71894ba8039ce173414689cc67b758ee7fd4ea8a4b5d
7
- data.tar.gz: be3a88bcff7fc58f110e4038a45dd0fc2b21765c2922d1d0f68df14307dcd5ab7de7a940bc664400f5d04ef05dfdac2f9d9ab43a1aad278db8098bb2bb521b41
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/Gemfile CHANGED
@@ -2,8 +2,3 @@ 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
-
data/README-pt.md CHANGED
@@ -1,9 +1,9 @@
1
1
  # simple_cpf_cnpj
2
2
 
3
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)
4
+ ![Tests](https://github.com/DaviMedrade/simple_cpf_cnpj/actions/workflows/run-tests.yml/badge.svg)
5
+ [![Maintainability](https://api.codeclimate.com/v1/badges/365c37a70f61436932a4/maintainability)](https://codeclimate.com/github/DaviMedrade/simple_cpf_cnpj/maintainability)
6
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/365c37a70f61436932a4/test_coverage)](https://codeclimate.com/github/DaviMedrade/simple_cpf_cnpj/test_coverage)
7
7
 
8
8
  **English Version:** [README.md](rdoc-ref:README.md)
9
9
 
@@ -106,10 +106,10 @@ Após fazer checkout do repositório, execute `bin/setup` para instalar as depen
106
106
  ## Contribuindo
107
107
 
108
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
109
+ https://github.com/DaviMedrade/simple_cpf_cnpj/issues
110
110
 
111
111
  ## Licença e copyright
112
112
 
113
- Copyright (c) 2015 David Santos
113
+ Copyright © 2015-2023 Davi Medrade
114
114
 
115
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,9 +1,9 @@
1
1
  # simple_cpf_cnpj
2
2
 
3
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)
4
+ ![Tests](https://github.com/DaviMedrade/simple_cpf_cnpj/actions/workflows/run-tests.yml/badge.svg)
5
+ [![Maintainability](https://api.codeclimate.com/v1/badges/365c37a70f61436932a4/maintainability)](https://codeclimate.com/github/DaviMedrade/simple_cpf_cnpj/maintainability)
6
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/365c37a70f61436932a4/test_coverage)](https://codeclimate.com/github/DaviMedrade/simple_cpf_cnpj/test_coverage)
7
7
 
8
8
  **Versão em Português:** [README-pt.md](rdoc-ref:README-pt.md)
9
9
 
@@ -15,7 +15,7 @@ The module provides methods to differentiate a CPF from a CNPJ, format, and vali
15
15
 
16
16
  ## Compatibility
17
17
 
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.
18
+ The code is tested with MRI Ruby 2.0-3.2, JRuby, and TruffleRuby.
19
19
 
20
20
  ## Installation
21
21
 
@@ -105,11 +105,11 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
105
105
 
106
106
  ## Contributing
107
107
 
108
- Bug reports and pull requests are welcome on GitHub at
109
- https://github.com/davidsantos-br/simple_cpf_cnpj.
108
+ Bug reports and pull requests are welcome on GitHub:
109
+ https://github.com/DaviMedrade/simple_cpf_cnpj/issues
110
110
 
111
111
  ## License and copyright
112
112
 
113
- Copyright (c) 2015 David Santos
113
+ Copyright © 2015-2023 Davi Medrade
114
114
 
115
115
  This software is released under the MIT license, which can be found in the file [LICENSE](rdoc-ref:LICENSE).
data/cpf_cnpj.gemspec CHANGED
@@ -6,8 +6,8 @@ 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 = ["David Santos"]
10
- spec.email = ["david@dsantosdev.com"]
9
+ spec.authors = ["Davi Medrade"]
10
+ spec.email = ["davi@medrade.com.br"]
11
11
 
12
12
  spec.summary = %q{Provides the module CpfCnpj, with methods that detect, format, and validate CPFs and CNPJs.}
13
13
  spec.description = <<EOT
@@ -17,19 +17,22 @@ Provides the module CpfCnpj, with methods that detect, validate, and format CPFs
17
17
 
18
18
  Fornece o módulo CpfCnpj, com funções que detectam, validam, e formatam CPFs e CNPJs.
19
19
  EOT
20
- spec.homepage = "https://github.com/davidsantos-br/simple_cpf_cnpj"
20
+ spec.homepage = "https://github.com/DaviMedrade/simple_cpf_cnpj"
21
21
  spec.license = "MIT"
22
22
 
23
23
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
24
  spec.bindir = "exe"
25
25
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
26
  spec.require_paths = ["lib"]
27
- spec.required_ruby_version = '>= 1.8.7'
27
+ spec.required_ruby_version = '>= 2.0.0'
28
28
  spec.extra_rdoc_files = ['README.md', 'README-pt.md', 'LICENSE', 'LICENSE-pt']
29
29
  spec.rdoc_options << '--title' << 'simple_cpf_cnpj -- CPF/CNPJ utility methods' << '--main' << 'README.md'
30
30
 
31
- spec.add_development_dependency "bundler", "~> 1.10"
32
- spec.add_development_dependency "rake", "~> 10.0"
31
+ spec.add_development_dependency "bundler", "> 1.10"
32
+ spec.add_development_dependency "rake"
33
33
  spec.add_development_dependency "minitest"
34
34
  spec.add_development_dependency "rdoc"
35
+ unless ENV['NO_COVERAGE']
36
+ spec.add_development_dependency "simplecov"
37
+ end
35
38
  end
@@ -1,3 +1,3 @@
1
1
  module CpfCnpj # :nodoc:
2
- VERSION = "0.2.1"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -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
- 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:
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
- def self.type_of(cpf_cnpj) # :arg: cpf_or_cnpj
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 11 ; :cpf
38
- when 14 ; :cnpj
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 +cnpj_or_cnpj+ as either a CPF or a CNPJ by verifying that the check digits match.
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
- (str.respond_to?(:ord) ? str.ord : str[0]) - 48
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.2.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
- - David Santos
8
- autorequire:
7
+ - Davi Medrade
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-07-04 00:00:00.000000000 Z
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: '10.0'
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: '10.0'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
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'
69
83
  description: |
70
84
  Provides the module CpfCnpj, with methods that detect, validate, and format CPFs and CNPJs (Brazilian federal ID numbers).
71
85
 
@@ -73,7 +87,7 @@ description: |
73
87
 
74
88
  Fornece o módulo CpfCnpj, com funções que detectam, validam, e formatam CPFs e CNPJs.
75
89
  email:
76
- - david@dsantosdev.com
90
+ - davi@medrade.com.br
77
91
  executables: []
78
92
  extensions: []
79
93
  extra_rdoc_files:
@@ -82,8 +96,8 @@ extra_rdoc_files:
82
96
  - LICENSE
83
97
  - LICENSE-pt
84
98
  files:
99
+ - ".github/workflows/run-tests.yml"
85
100
  - ".gitignore"
86
- - ".travis.yml"
87
101
  - Gemfile
88
102
  - LICENSE
89
103
  - LICENSE-pt
@@ -95,11 +109,11 @@ files:
95
109
  - cpf_cnpj.gemspec
96
110
  - lib/simple_cpf_cnpj.rb
97
111
  - lib/simple_cpf_cnpj/version.rb
98
- homepage: https://github.com/davidsantos-br/simple_cpf_cnpj
112
+ homepage: https://github.com/DaviMedrade/simple_cpf_cnpj
99
113
  licenses:
100
114
  - MIT
101
115
  metadata: {}
102
- post_install_message:
116
+ post_install_message:
103
117
  rdoc_options:
104
118
  - "--title"
105
119
  - simple_cpf_cnpj -- CPF/CNPJ utility methods
@@ -111,16 +125,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
111
125
  requirements:
112
126
  - - ">="
113
127
  - !ruby/object:Gem::Version
114
- version: 1.8.7
128
+ version: 2.0.0
115
129
  required_rubygems_version: !ruby/object:Gem::Requirement
116
130
  requirements:
117
131
  - - ">="
118
132
  - !ruby/object:Gem::Version
119
133
  version: '0'
120
134
  requirements: []
121
- rubyforge_project:
122
- rubygems_version: 2.4.8
123
- signing_key:
135
+ rubygems_version: 3.3.23
136
+ signing_key:
124
137
  specification_version: 4
125
138
  summary: Provides the module CpfCnpj, with methods that detect, format, and validate
126
139
  CPFs and CNPJs.
data/.travis.yml DELETED
@@ -1,11 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 1.8.7-p374
4
- - 1.9.2
5
- - 1.9.3
6
- - 2.0.0
7
- - 2.1
8
- - 2.2
9
- - jruby
10
- - ree
11
- before_install: gem install bundler -v 1.10.5