-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support to formatted brazilian_citizen_number and brazilian_company_number #1489
Conversation
eef1195
to
2f4a877
Compare
There is a offense in rubocop that says "Favor format over String#%" and forces me to change this: '%s.%s.%s-%s' % number.scan(/\d{2,3}/).flatten to this: named_captures = number.match(/(?<a>\d{3})(?<b>\d{3})(?<c>\d{3})(?<d>\d{2})/).named_captures
named_captures = named_captures.each.with_object({}) { |(k, v), hash| hash[k.to_sym] = v }
@formatted ||= format('%<a>s.%<b>s.%<c>s-%<d>s', named_captures) Is it ok to ignore this offense in I will improve this PR until tomorrow. |
Yes, you can update the rubocop config to ignore that rule. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Firstly thanks for following the structure of the unreleased project. We appreciate that!
It seems we already have these faker methods:
Faker::IDNumber.brazilian_citizen_number
https://github.com/stympy/faker/blob/master/lib/faker/default/id_number.rb#L78Faker::Company.brazilian_company_number
https://github.com/stympy/faker/blob/master/lib/faker/default/company.rb#L156
I think you could improve them. Please review these methods and let me know what you think.
Just noticed that currently we don't have an option to output a formatted/unformatted response. This feature request is welcome! |
Thank you for the info. I will improve the existent method to allow formatted numbers instead of a creating a new one. |
2f4a877
to
6f5b7fc
Compare
@vbrazo what do you think? |
Add support to valid and full random brazilian documents: CPF (person id) and CNPJ (company id).