cpf_tools 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
  SHA256:
3
- metadata.gz: 0bc316f7ab66ab0ce32c02a5fce788c0d571d4b9603c856ca97b3caad158583b
4
- data.tar.gz: 13efd3b03c0c0dfbc76d178bd0df07e07926ace87c367a01eb7ccdfedb5dd198
3
+ metadata.gz: c5c3e89ec707c076fa095bb710771f33097d3ad68e585f55988c50253bb2f48f
4
+ data.tar.gz: 696eb53b5a97816400ea240a028a5e5daf44795c0c97c7943e3b06b25f5437ca
5
5
  SHA512:
6
- metadata.gz: f65061c314a9ff8fe40e6abfe657b70f1aa39fa062e8c9c045b1c96ae3356f5aec6f96874a581c407fe04c1a4f59c8794d50c79d4c3f8ad13344134eae0b5aef
7
- data.tar.gz: ad18ec611cd2ab55f181506c2fb9dc4d57f4b84137ca28cd327b7905f77768bdb4fe2becb17aa767f6236112327a1f439400e9a5700d1e2bf938cdd46a387879
6
+ metadata.gz: 4f3b403dcec389bd970b9cf6afa074082c023df36bc281e781eeda8af6ade5f84fa02b3923e34b5dd3e85a4030bb4a765ef6c4433bebdb7c082850e5b5bcf687
7
+ data.tar.gz: 79387d02ea4e73c18df4473e75a9f71d58813b97ca8f27e54de8a3ab50868b7467545b9a9710748734375db54fadda46bfd1cf07a8475077860015a3d2969c5d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cpf_tools (0.1.0)
4
+ cpf_tools (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -42,15 +42,31 @@ If the string length is different from 11 (CPF standard length) an empty string
42
42
 
43
43
  ### with_mask
44
44
  A string with default mask applied will be returned -> '###.###.###-##'
45
-
45
+
46
46
  CpfTools.format('19906064072') => '199.060.640-72'
47
47
 
48
48
  ### digits_only
49
49
  A string with digits only will be returned.
50
-
50
+
51
51
  CpfTools.format('199.060.640-72', format: :digits_only) => '19906064072'
52
52
 
53
53
 
54
+ ### CpfTools.return_valid (string)
55
+ This method combines valid? and format and will return a formatted string if CPF is valid.
56
+
57
+ If the string length is different from 11 (CPF standard length) or CPF isn't valid an empty string will be returned.
58
+
59
+ ### with_mask
60
+ A string with default mask applied will be returned -> '###.###.###-##'
61
+
62
+ CpfTools.return_valid('19906064072') => '199.060.640-72'
63
+
64
+ ### digits_only
65
+ A string with digits only will be returned.
66
+
67
+ CpfTools.return_valid('199.060.640-72', format: :digits_only) => '19906064072'
68
+
69
+
54
70
  ## Development
55
71
 
56
72
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/cpf_tools.gemspec CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
7
7
  spec.email = ['mers.escobar@gmail.com']
8
8
 
9
9
  spec.summary = 'Tools to work with the Brazilian Tax ID'
10
- spec.description = 'The Brazilian tax ID (CPF) validation and formatting, more functions to come'
10
+ spec.description = 'The Brazilian Tax ID (CPF) validation and formatting, more functions to come'
11
11
  spec.homepage = 'http://github.com/m-escobar/cpf_tools'
12
12
  spec.license = 'MIT'
13
13
  spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
data/lib/cpf_tools.rb CHANGED
@@ -33,6 +33,10 @@ module CpfTools
33
33
  end
34
34
  end
35
35
 
36
+ def return_valid(cpf, format: :masked)
37
+ valid?(cpf) ? format(cpf, format: format) : ''
38
+ end
39
+
36
40
  private
37
41
  def cpf_to_s(cpf)
38
42
  cpf = cpf.to_s if cpf.is_a? Integer
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CpfTools
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cpf_tools
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
  - Marcelo Escobar
@@ -10,7 +10,7 @@ bindir: exe
10
10
  cert_chain: []
11
11
  date: 2021-02-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: The Brazilian tax ID (CPF) validation and formatting, more functions
13
+ description: The Brazilian Tax ID (CPF) validation and formatting, more functions
14
14
  to come
15
15
  email:
16
16
  - mers.escobar@gmail.com