cpf_cnpj 0.5.0 → 1.0.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 +4 -4
- data/.github/FUNDING.yml +3 -0
- data/.github/dependabot.yml +15 -0
- data/.github/workflows/ruby-tests.yml +47 -0
- data/.rubocop.yml +10 -56
- data/README.md +30 -14
- data/Rakefile +4 -1
- data/bin/cnpj +1 -1
- data/bin/cpf +1 -1
- data/cpf_cnpj.gemspec +21 -14
- data/lib/cnpj/formatter.rb +6 -3
- data/lib/cnpj/verifier_digit.rb +1 -1
- data/lib/cnpj.rb +38 -17
- data/lib/cpf/formatter.rb +2 -2
- data/lib/cpf/verifier_digit.rb +1 -1
- data/lib/cpf.rb +28 -16
- data/lib/cpf_cnpj/cli.rb +1 -2
- data/lib/cpf_cnpj/version.rb +1 -1
- data/lib/cpf_cnpj.rb +0 -1
- data/test/cnpj/cli_test.rb +112 -0
- data/test/{unit/cnpj → cnpj}/formatter_test.rb +2 -0
- data/test/{unit/cnpj_test.rb → cnpj_test.rb} +42 -5
- data/test/cpf/cli_test.rb +112 -0
- data/test/{unit/cpf → cpf}/formatter_test.rb +6 -4
- data/test/{unit/cpf_test.rb → cpf_test.rb} +15 -2
- data/test/support/run_command.rb +30 -0
- data/test/test_helper.rb +1 -1
- metadata +54 -33
- data/.travis.yml +0 -8
- data/lib/cpf_cnpj/generator.rb +0 -14
- data/test/support/capture_syscall.rb +0 -18
- data/test/unit/cnpj/cli_test.rb +0 -134
- data/test/unit/cpf/cli_test.rb +0 -134
- /data/test/{unit/cnpj → cnpj}/generator_test.rb +0 -0
- /data/test/{unit/cpf → cpf}/generator_test.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39920a466745460c30ee825d79ebea024b9fd2f76ea481d911564406ca651135
|
4
|
+
data.tar.gz: 5f32f4fac220fc8768ece5806270974590905b213464f4ab0e72f33e7d615013
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b72011979e87333f55a565bbd999d9e0c14d31936d82d235f2f1981c90374f534d3026154abf053de133e2abc4092c6c12f82e951d9b4bd41d64ba8951859e16
|
7
|
+
data.tar.gz: bd0b2ab1c6731d5dd34173e9545b143ec506938b5333ef78835b1d14f0dd48e3d2d991c81ff5a7457693d24baaf0f1fd073200fbd5dac232e8ef10be8b07742d
|
data/.github/FUNDING.yml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
# Documentation:
|
3
|
+
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
4
|
+
|
5
|
+
version: 2
|
6
|
+
updates:
|
7
|
+
- package-ecosystem: "github-actions"
|
8
|
+
directory: "/"
|
9
|
+
schedule:
|
10
|
+
interval: "daily"
|
11
|
+
|
12
|
+
- package-ecosystem: bundler
|
13
|
+
directory: "/"
|
14
|
+
schedule:
|
15
|
+
interval: "daily"
|
@@ -0,0 +1,47 @@
|
|
1
|
+
---
|
2
|
+
name: ruby-tests
|
3
|
+
|
4
|
+
on:
|
5
|
+
push:
|
6
|
+
branches:
|
7
|
+
- main
|
8
|
+
pull_request_target:
|
9
|
+
workflow_dispatch:
|
10
|
+
inputs: {}
|
11
|
+
|
12
|
+
jobs:
|
13
|
+
build:
|
14
|
+
name: Tests with Ruby ${{ matrix.ruby }}
|
15
|
+
runs-on: "ubuntu-latest"
|
16
|
+
if: |
|
17
|
+
github.actor == 'dependabot[bot]' && github.event_name == 'pull_request_target' ||
|
18
|
+
github.actor != 'dependabot[bot]'
|
19
|
+
strategy:
|
20
|
+
fail-fast: false
|
21
|
+
matrix:
|
22
|
+
ruby: ["3.2", "3.3"]
|
23
|
+
|
24
|
+
steps:
|
25
|
+
- uses: actions/checkout@v4
|
26
|
+
|
27
|
+
- uses: actions/cache@v4
|
28
|
+
with:
|
29
|
+
path: vendor/bundle
|
30
|
+
key: >
|
31
|
+
${{ runner.os }}-${{ matrix.ruby }}-gems-${{
|
32
|
+
hashFiles(matrix.gemfile) }}
|
33
|
+
|
34
|
+
- name: Set up Ruby
|
35
|
+
uses: ruby/setup-ruby@v1
|
36
|
+
with:
|
37
|
+
ruby-version: ${{ matrix.ruby }}
|
38
|
+
|
39
|
+
- name: Install gem dependencies
|
40
|
+
run: |
|
41
|
+
gem install bundler
|
42
|
+
bundle config path vendor/bundle
|
43
|
+
bundle update --jobs 4 --retry 3
|
44
|
+
|
45
|
+
- name: Run Tests
|
46
|
+
run: |
|
47
|
+
bundle exec rake
|
data/.rubocop.yml
CHANGED
@@ -1,59 +1,13 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
---
|
2
|
+
inherit_gem:
|
3
|
+
rubocop-fnando: .rubocop.yml
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
-
|
9
|
-
-
|
10
|
-
- '**/config.ru'
|
11
|
-
- '**/Gemfile'
|
12
|
-
- '**/Rakefile'
|
13
|
-
- '**/Capfile'
|
14
|
-
- '**/Guardfile'
|
15
|
-
- '**/Podfile'
|
16
|
-
- '**/Thorfile'
|
17
|
-
- '**/Vagrantfile'
|
18
|
-
- '**/Berksfile'
|
19
|
-
- '**/Cheffile'
|
20
|
-
- '**/Vagabondfile'
|
5
|
+
AllCops:
|
6
|
+
TargetRubyVersion: 2.7
|
7
|
+
NewCops: enable
|
8
|
+
Exclude:
|
9
|
+
- vendor/**/*
|
10
|
+
- gemfiles/**/*
|
21
11
|
|
22
|
-
Style/
|
12
|
+
Style/OptionalBooleanParameter:
|
23
13
|
Enabled: false
|
24
|
-
|
25
|
-
Style/StringLiterals:
|
26
|
-
EnforcedStyle: double_quotes
|
27
|
-
|
28
|
-
Layout/SpaceInsideBlockBraces:
|
29
|
-
EnforcedStyle: space
|
30
|
-
EnforcedStyleForEmptyBraces: space
|
31
|
-
SpaceBeforeBlockParameters: false
|
32
|
-
|
33
|
-
Layout/SpaceInsideHashLiteralBraces:
|
34
|
-
EnforcedStyle: no_space
|
35
|
-
EnforcedStyleForEmptyBraces: no_space
|
36
|
-
|
37
|
-
Layout/FirstArrayElementLineBreak:
|
38
|
-
Enabled: true
|
39
|
-
|
40
|
-
Layout/FirstHashElementLineBreak:
|
41
|
-
Enabled: true
|
42
|
-
|
43
|
-
Style/SymbolArray:
|
44
|
-
Enabled: true
|
45
|
-
|
46
|
-
Style/PercentLiteralDelimiters:
|
47
|
-
PreferredDelimiters:
|
48
|
-
'%': '[]'
|
49
|
-
'%i': '[]'
|
50
|
-
'%q': '[]'
|
51
|
-
'%Q': '[]'
|
52
|
-
'%r': '[]'
|
53
|
-
'%s': '[]'
|
54
|
-
'%w': '[]'
|
55
|
-
'%W': '[]'
|
56
|
-
'%x': '[]'
|
57
|
-
|
58
|
-
Metrics/LineLength:
|
59
|
-
Max: 100
|
data/README.md
CHANGED
@@ -1,14 +1,19 @@
|
|
1
1
|
# CPF/CNPJ
|
2
2
|
|
3
|
-
[](https://github.com/fnando/cpf_cnpj)
|
4
|
+
[](https://rubygems.org/gems/cpf_cnpj)
|
5
|
+
[](https://rubygems.org/gems/cpf_cnpj)
|
6
6
|
|
7
|
-
This gem does some
|
7
|
+
This gem does some
|
8
|
+
[CPF](http://en.wikipedia.org/wiki/Cadastro_de_Pessoas_F%C3%ADsicas)/[CNPJ](http://en.wikipedia.org/wiki/CNPJ)
|
9
|
+
magic. It allows you to create, validate and format CPF/CNPJ, even through the
|
10
|
+
command-line.
|
8
11
|
|
9
|
-
Just making my life easier when filling these damn numbers on internet bankings
|
12
|
+
Just making my life easier when filling these damn numbers on internet bankings
|
13
|
+
and government sites.
|
10
14
|
|
11
|
-
For ActiveModel/ActiveRecord validations, please check
|
15
|
+
For ActiveModel/ActiveRecord validations, please check
|
16
|
+
<https://github.com/fnando/validators>.
|
12
17
|
|
13
18
|
## Installation
|
14
19
|
|
@@ -28,24 +33,35 @@ Or install it yourself as:
|
|
28
33
|
|
29
34
|
### Ruby API
|
30
35
|
|
31
|
-
This library has the same API for both CNPJ/CPF, so only one of them is
|
36
|
+
This library has the same API for both CNPJ/CPF, so only one of them is
|
37
|
+
documented below.
|
38
|
+
|
39
|
+
> [!NOTE]
|
40
|
+
>
|
41
|
+
> This library already supports the new alphanumeric CNPJ algorithm that will be
|
42
|
+
> available starting July 2026. For more information, see
|
43
|
+
> <https://www.gov.br/receitafederal/pt-br/acesso-a-informacao/acoes-e-programas/programas-e-atividades/cnpj-alfanumerico>.
|
32
44
|
|
33
45
|
```ruby
|
34
46
|
require "cpf_cnpj"
|
35
47
|
|
36
|
-
CPF.
|
37
|
-
CPF.
|
38
|
-
CPF.generate
|
48
|
+
CPF.format(number) # Format CPF (xxx.xxx.xxx-xx)
|
49
|
+
CPF.valid?(number) # Check if a CPF is valid
|
50
|
+
CPF.generate # Generate a random CPF number
|
51
|
+
CPF.generate(true) # Generate a formatted number
|
39
52
|
|
40
53
|
cpf = CPF.new(number)
|
41
|
-
cpf.formatted
|
42
|
-
cpf.stripped
|
43
|
-
cpf.valid?
|
54
|
+
cpf.formatted # Return formatted CPF (xxx.xxx.xxx-xx)
|
55
|
+
cpf.stripped # Return stripped CPF (xxxxxxxxxxx)
|
56
|
+
cpf.valid? # Check if CPF is valid
|
57
|
+
cpf.number_without_verifier # Return CPF without verifier digits
|
44
58
|
```
|
45
59
|
|
46
60
|
#### Strict Validation
|
47
61
|
|
48
|
-
By default, validations will strip any characters that aren't numbers. This
|
62
|
+
By default, validations will strip any characters that aren't numbers. This
|
63
|
+
means that `532#####820------857\n96` is considered a valid number. To perform a
|
64
|
+
strict validation use `strict: true`.
|
49
65
|
|
50
66
|
```ruby
|
51
67
|
CPF.valid?(number, strict: true)
|
data/Rakefile
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require "bundler/gem_tasks"
|
4
4
|
require "rake/testtask"
|
5
|
+
require "rubocop/rake_task"
|
5
6
|
|
6
7
|
Rake::TestTask.new(:test) do |t|
|
7
8
|
t.libs << "test"
|
@@ -10,4 +11,6 @@ Rake::TestTask.new(:test) do |t|
|
|
10
11
|
t.warning = false
|
11
12
|
end
|
12
13
|
|
13
|
-
|
14
|
+
RuboCop::RakeTask.new
|
15
|
+
|
16
|
+
task default: %i[test rubocop]
|
data/bin/cnpj
CHANGED
data/bin/cpf
CHANGED
data/cpf_cnpj.gemspec
CHANGED
@@ -2,20 +2,27 @@
|
|
2
2
|
|
3
3
|
require "./lib/cpf_cnpj/version"
|
4
4
|
|
5
|
-
Gem::Specification.new do |
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.authors = ["Nando Vieira"]
|
7
|
+
spec.email = ["fnando.vieira@gmail.com"]
|
8
|
+
spec.description = "Validate, generate and format CPF/CNPJ numbers. " \
|
9
|
+
"Include command-line tools."
|
10
|
+
spec.summary = spec.description
|
11
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
|
12
|
+
spec.homepage = "https://github.com/fnando/cpf_cnpj"
|
13
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
14
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
15
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
10
16
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
gem.version = CPF::VERSION
|
17
|
+
spec.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}).map {|f| File.basename(f) }
|
19
|
+
spec.name = "cpf_cnpj"
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
spec.version = CPF::VERSION
|
17
22
|
|
18
|
-
|
19
|
-
|
20
|
-
|
23
|
+
spec.add_development_dependency "minitest-utils"
|
24
|
+
spec.add_development_dependency "pry-meta"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
spec.add_development_dependency "rubocop"
|
27
|
+
spec.add_development_dependency "rubocop-fnando"
|
21
28
|
end
|
data/lib/cnpj/formatter.rb
CHANGED
@@ -2,11 +2,14 @@
|
|
2
2
|
|
3
3
|
class CNPJ
|
4
4
|
class Formatter
|
5
|
-
STRICT_REGEX = %r[
|
6
|
-
LOOSE_REGEX = /[
|
5
|
+
STRICT_REGEX = %r{[/.-]}.freeze
|
6
|
+
LOOSE_REGEX = /[^A-Z\d]/.freeze
|
7
|
+
REPLACE_REGEX = /
|
8
|
+
\A([A-Z\d]{2})([A-Z\d]{3})([A-Z\d]{3})([A-Z\d]{4})([A-Z\d]{2})\Z
|
9
|
+
/x.freeze
|
7
10
|
|
8
11
|
def self.format(number)
|
9
|
-
strip(number).gsub(
|
12
|
+
strip(number).gsub(REPLACE_REGEX, "\\1.\\2.\\3/\\4-\\5")
|
10
13
|
end
|
11
14
|
|
12
15
|
def self.strip(number, strict = false)
|
data/lib/cnpj/verifier_digit.rb
CHANGED
data/lib/cnpj.rb
CHANGED
@@ -5,14 +5,13 @@ class CNPJ
|
|
5
5
|
require "cnpj/formatter"
|
6
6
|
require "cnpj/verifier_digit"
|
7
7
|
|
8
|
-
attr_reader :number
|
9
|
-
attr_reader :strict
|
8
|
+
attr_reader :number, :strict
|
10
9
|
|
11
|
-
REGEX = %r[\A\
|
12
|
-
VALIDATION_SIZE_REGEX =
|
10
|
+
REGEX = %r[\A[\dA-Z]{2}\.[\dA-Z]{3}.[\dA-Z]{3}/[\dA-Z]{4}-\d{2}\Z].freeze
|
11
|
+
VALIDATION_SIZE_REGEX = /^[A-Z\d]{12}\d{2}$/.freeze
|
13
12
|
NUMBER_SIZE = 12
|
14
13
|
|
15
|
-
|
14
|
+
DENYLIST = %w[
|
16
15
|
00000000000000
|
17
16
|
11111111111111
|
18
17
|
22222222222222
|
@@ -25,18 +24,27 @@ class CNPJ
|
|
25
24
|
99999999999999
|
26
25
|
].freeze
|
27
26
|
|
27
|
+
def self.format(number)
|
28
|
+
new(number).formatted
|
29
|
+
end
|
30
|
+
|
28
31
|
def self.valid?(number, strict: false)
|
29
32
|
new(number, strict).valid?
|
30
33
|
end
|
31
34
|
|
32
35
|
def self.generate(formatted = false)
|
33
|
-
|
34
|
-
|
36
|
+
numbers = Array("0".."9") + ("A".."Z").to_a
|
37
|
+
digits = Array.new(NUMBER_SIZE) { numbers.sample }
|
38
|
+
numeric_digits = digits.map {|d| d.ord - 48 }
|
39
|
+
numeric_digits << VerifierDigit.generate(numeric_digits)
|
40
|
+
numeric_digits << VerifierDigit.generate(numeric_digits)
|
41
|
+
|
42
|
+
cnpj = new((digits + numeric_digits[-2, 2]).join)
|
35
43
|
formatted ? cnpj.formatted : cnpj.stripped
|
36
44
|
end
|
37
45
|
|
38
46
|
def initialize(number, strict = false)
|
39
|
-
@number = number.to_s
|
47
|
+
@number = number.to_s.upcase
|
40
48
|
@strict = strict
|
41
49
|
end
|
42
50
|
|
@@ -56,24 +64,37 @@ class CNPJ
|
|
56
64
|
end
|
57
65
|
|
58
66
|
def valid?
|
59
|
-
|
60
|
-
|
67
|
+
if strict && !(number.match?(REGEX) || number.match?(VALIDATION_SIZE_REGEX))
|
68
|
+
return false
|
69
|
+
end
|
70
|
+
|
71
|
+
return false unless stripped.match?(VALIDATION_SIZE_REGEX)
|
61
72
|
|
62
|
-
|
73
|
+
return false if DENYLIST.include?(stripped)
|
74
|
+
|
75
|
+
digits = numbers[0...NUMBER_SIZE]
|
63
76
|
digits << VerifierDigit.generate(digits)
|
64
77
|
digits << VerifierDigit.generate(digits)
|
65
78
|
|
66
79
|
digits[-2, 2] == numbers[-2, 2]
|
67
80
|
end
|
68
81
|
|
69
|
-
def ==(
|
70
|
-
super ||
|
82
|
+
def ==(other)
|
83
|
+
super || (other.instance_of?(self.class) && other.stripped == stripped)
|
84
|
+
end
|
85
|
+
alias eql? ==
|
86
|
+
|
87
|
+
def number_without_verifier
|
88
|
+
stripped_chars[0...NUMBER_SIZE].join
|
71
89
|
end
|
72
|
-
alias :eql? :==
|
73
90
|
|
74
|
-
private
|
91
|
+
private def stripped_chars
|
92
|
+
@stripped_chars ||= stripped.chars
|
93
|
+
end
|
75
94
|
|
76
|
-
def numbers
|
77
|
-
@numbers ||=
|
95
|
+
private def numbers
|
96
|
+
@numbers ||= stripped_chars.map do |number|
|
97
|
+
number.ord - 48
|
98
|
+
end
|
78
99
|
end
|
79
100
|
end
|
data/lib/cpf/formatter.rb
CHANGED
data/lib/cpf/verifier_digit.rb
CHANGED
data/lib/cpf.rb
CHANGED
@@ -5,14 +5,13 @@ class CPF
|
|
5
5
|
require "cpf/formatter"
|
6
6
|
require "cpf/verifier_digit"
|
7
7
|
|
8
|
-
attr_reader :number
|
9
|
-
attr_reader :strict
|
8
|
+
attr_reader :number, :strict
|
10
9
|
|
11
|
-
REGEX = /\A\d{3}\.\d{3}\.\d{3}-\d{2}\Z
|
12
|
-
VALIDATION_SIZE_REGEX =
|
10
|
+
REGEX = /\A\d{3}\.\d{3}\.\d{3}-\d{2}\Z/.freeze
|
11
|
+
VALIDATION_SIZE_REGEX = /^\d{11}$/.freeze
|
13
12
|
NUMBER_SIZE = 9
|
14
13
|
|
15
|
-
|
14
|
+
DENYLIST = %w[
|
16
15
|
00000000000
|
17
16
|
11111111111
|
18
17
|
22222222222
|
@@ -24,16 +23,23 @@ class CPF
|
|
24
23
|
88888888888
|
25
24
|
99999999999
|
26
25
|
12345678909
|
27
|
-
01234567890
|
28
26
|
].freeze
|
29
27
|
|
28
|
+
def self.format(number)
|
29
|
+
new(number).formatted
|
30
|
+
end
|
31
|
+
|
30
32
|
def self.valid?(number, strict: false)
|
31
33
|
new(number, strict).valid?
|
32
34
|
end
|
33
35
|
|
34
36
|
def self.generate(formatted = false)
|
35
|
-
|
36
|
-
|
37
|
+
numbers = Array(0..9)
|
38
|
+
digits = Array.new(NUMBER_SIZE) { numbers.sample }
|
39
|
+
digits << VerifierDigit.generate(digits)
|
40
|
+
digits << VerifierDigit.generate(digits)
|
41
|
+
|
42
|
+
cpf = new(digits.join)
|
37
43
|
formatted ? cpf.formatted : cpf.stripped
|
38
44
|
end
|
39
45
|
|
@@ -58,24 +64,30 @@ class CPF
|
|
58
64
|
end
|
59
65
|
|
60
66
|
def valid?
|
61
|
-
|
62
|
-
|
67
|
+
if strict && !(number.match?(REGEX) || number.match?(VALIDATION_SIZE_REGEX))
|
68
|
+
return false
|
69
|
+
end
|
70
|
+
|
71
|
+
return false unless stripped.match?(VALIDATION_SIZE_REGEX)
|
72
|
+
return false if DENYLIST.include?(stripped)
|
63
73
|
|
64
|
-
digits = numbers[0...
|
74
|
+
digits = numbers[0...NUMBER_SIZE]
|
65
75
|
digits << VerifierDigit.generate(digits)
|
66
76
|
digits << VerifierDigit.generate(digits)
|
67
77
|
|
68
78
|
digits[-2, 2] == numbers[-2, 2]
|
69
79
|
end
|
70
80
|
|
71
|
-
def
|
72
|
-
|
81
|
+
def number_without_verifier
|
82
|
+
numbers[0...NUMBER_SIZE].join
|
73
83
|
end
|
74
|
-
alias :eql? :==
|
75
84
|
|
76
|
-
|
85
|
+
def ==(other)
|
86
|
+
super || (other.instance_of?(self.class) && other.stripped == stripped)
|
87
|
+
end
|
88
|
+
alias eql? ==
|
77
89
|
|
78
|
-
def numbers
|
90
|
+
private def numbers
|
79
91
|
@numbers ||= stripped.each_char.to_a.map(&:to_i)
|
80
92
|
end
|
81
93
|
end
|
data/lib/cpf_cnpj/cli.rb
CHANGED
@@ -24,7 +24,6 @@ module CpfCnpj
|
|
24
24
|
@options ||= {}
|
25
25
|
end
|
26
26
|
|
27
|
-
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
28
27
|
def process_command
|
29
28
|
opts.banner = "Usage: #{bin_name} [options] [#{document_name} number]"
|
30
29
|
opts.separator ""
|
@@ -58,7 +57,6 @@ module CpfCnpj
|
|
58
57
|
opts.parse!(arguments)
|
59
58
|
opts.permute!(arguments)
|
60
59
|
end
|
61
|
-
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
62
60
|
|
63
61
|
def input
|
64
62
|
stdin.tty? ? arguments.first : stdin.read
|
@@ -77,6 +75,7 @@ module CpfCnpj
|
|
77
75
|
|
78
76
|
def validate(document)
|
79
77
|
return if document.valid?
|
78
|
+
|
80
79
|
stderr << "Error: Invalid number\n"
|
81
80
|
exit 1
|
82
81
|
end
|
data/lib/cpf_cnpj/version.rb
CHANGED