Skip to content
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

Refactor Faker::IDNumber to Faker::IdNumber to be more consistent with other generator's naming convention. #2858

Conversation

Jamal-A-Mohamed
Copy link
Contributor

@Jamal-A-Mohamed Jamal-A-Mohamed commented Nov 14, 2023

Co-authored-by: Salvador Tena salvador.tena@scientist.com

Motivation / Background

This Pull Request has been created because of this issue #2787 which raises the inconsistency of generator names in the codebase. The PR changes the class name from IDNumber to IdNumber which puts it in line with the rest of the generators and updates tests and documentation as well.

Additional information

Testing:

Before changing the test files I ran the test task and made sure the delegation worked properly and that deprecation warnings were outputting correctly. screenshot is below. added the calling from the message after the fact.

Screenshot 2023-11-14 at 6 07 24 AM

Checklist

Before submitting the PR make sure the following are checked:

  • [ X] This Pull Request is related to one change. Changes that are unrelated should be opened in separate PRs.
  • [ X] Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • [X ] Tests are added or updated if you fix a bug, refactor something, or add a feature.
  • [X ] Tests and Rubocop are passing before submitting your proposed changes.

If you're proposing a new generator:

  • Open an issue first for discussion before you write any code.
  • Double-check the existing generators documentation to make sure the new generator you want to add doesn't already exist.
  • You've reviewed and followed the Documentation guidelines.

@Jamal-A-Mohamed Jamal-A-Mohamed changed the title Refactor IDNumber to IdNumber to be more consistent with other generating naming convention. Refactor Faker::IDNumber to Faker::IdNumber to be more consistent with other generating naming convention. Nov 14, 2023
@Jamal-A-Mohamed Jamal-A-Mohamed changed the title Refactor Faker::IDNumber to Faker::IdNumber to be more consistent with other generating naming convention. Refactor Faker::IDNumber to Faker::IdNumber to be more consistent with other generator's naming convention. Nov 14, 2023
Copy link
Contributor

@stefannibrasil stefannibrasil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @Jamal-A-Mohamed and Salvador! This is great. I left one suggestion, let me know if you have any questions. Thanks!

test/faker/default/test_faker_id_number.rb Show resolved Hide resolved
lib/faker/default/id_number.rb Outdated Show resolved Hide resolved
@stefannibrasil
Copy link
Contributor

The Test failure is fixed by #2868 could you rebase this branch to get the changes there?

end
end

class DeprecatedClass
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of naming this Deprecator? I find it a better name because class is not adding too much to the name.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking if we can do something like how ActiveSupport does but a simplified version for deprecating generators: https://github.com/rails/rails/blob/main/activesupport/lib/active_support/deprecation/constant_accessor.rb

It would be a module mixin that would add the const_missing and intercept calls to the deprecated module. The other mixin method would let you register the deprecated and the new modules.

If we could this in a module to be included, we can just add it to the generator to deprecate_constant passing the generator and the replacement, ie:

# id_number.rb

module Faker
  class IdNumber < Base
    include Faker::Deprecator

    deprecate_constant(Faker::IDNumber, Faker::IdNumber)
  end
end

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think this is a good idea, will implement it that way.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thank you! That would fit nicely with the others to be deprecated. Let us know if you need any help.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @stefannibrasil ,
Sorry for the taking so long on this but haven't had a chance to touch this till this morning.
I am not able to figure out a way to intercept the const_missing calls to the Faker module itself. i.e Faker::Constant_name. I tried to prepend the extension/module to the Faker module itself but that doesn't seem to work. will continue to look at it but interested to hear if you have way to get around that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Jamal-A-Mohamed thank you for your patience! I was almost there and @thdaraujo helped me with the final details. Here's how we could make it work: https://github.com/faker-ruby/faker/compare/main...hexdevs:faker:deprecator?expand=1

Not sure if you can cherry-pick this commit 8f54cbe to this branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Great Job to you both.
I cherry picked that from your guy's commit and pushed it up.
I would need to re-read to see what I was missing.
Let me know if you want me to squash commits and or write more tests.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay! Okay, almost there. I was testing some things on another project and pushed just one more commit here: efe80d0

Could you cherry-pick it again? That would be the only thing left before merging this. Thank you for your patience and your work on this!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thank you for helping out on this one! 🎉

Copy link
Contributor

@stefannibrasil stefannibrasil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@stefannibrasil stefannibrasil merged commit f586da7 into faker-ruby:main Feb 25, 2024
8 checks passed
keshavbiswa pushed a commit to keshavbiswa/faker that referenced this pull request Mar 17, 2024
… with other generator's naming convention. (faker-ruby#2858)

* Deprecate IDNumber to IdNumber per issue#2787

* wip

* Add a Faker::Deprecator module

Co-authored-by: Thiago Araujo <thd.araujo@gmail.com>

* Add more specs and improve warning message

---------

Co-authored-by: jamal.mohamed <jamal.mohamed@covermymeds.com>
Co-authored-by: Stefanni Brasil <stefannibrasil@gmail.com>
Co-authored-by: Thiago Araujo <thd.araujo@gmail.com>
stefannibrasil added a commit that referenced this pull request Mar 19, 2024
* update Faker::Australia to Faker::Locations::Australia

* Bump minitest from 5.21.1 to 5.21.2 (#2894)

Bumps [minitest](https://github.com/minitest/minitest) from 5.21.1 to 5.21.2.
- [Changelog](https://github.com/minitest/minitest/blob/master/History.rdoc)
- [Commits](minitest/minitest@v5.21.1...v5.21.2)

---
updated-dependencies:
- dependency-name: minitest
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump rubocop from 1.59.0 to 1.60.2 (#2896)

Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.59.0 to 1.60.2.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](rubocop/rubocop@v1.59.0...v1.60.2)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Add Kenya to supported countries (#2871)

* Add Kenya to supported countries

* Add tests for locale

* clan up pull request

* Add landline telephone numbers and cell phone formats

* Bump minitest from 5.21.2 to 5.22.2 (#2902)

Bumps [minitest](https://github.com/minitest/minitest) from 5.21.2 to 5.22.2.
- [Changelog](https://github.com/minitest/minitest/blob/master/History.rdoc)
- [Commits](minitest/minitest@v5.21.2...v5.22.2)

---
updated-dependencies:
- dependency-name: minitest
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump test-unit from 3.6.1 to 3.6.2 (#2906)

Bumps [test-unit](https://github.com/test-unit/test-unit) from 3.6.1 to 3.6.2.
- [Release notes](https://github.com/test-unit/test-unit/releases)
- [Commits](test-unit/test-unit@3.6.1...3.6.2)

---
updated-dependencies:
- dependency-name: test-unit
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Refactor `Faker::IDNumber` to `Faker::IdNumber` to be more consistent with other generator's naming convention. (#2858)

* Deprecate IDNumber to IdNumber per issue#2787

* wip

* Add a Faker::Deprecator module

Co-authored-by: Thiago Araujo <thd.araujo@gmail.com>

* Add more specs and improve warning message

---------

Co-authored-by: jamal.mohamed <jamal.mohamed@covermymeds.com>
Co-authored-by: Stefanni Brasil <stefannibrasil@gmail.com>
Co-authored-by: Thiago Araujo <thd.araujo@gmail.com>

* Fix/Deprecate FmaBrotherhood Generator (#2856)

* Favor 'The Room' instead of 'Room'

This commit will rename instances of room to the_room including the
locales.  Originally the `room.md` had a typo that referenced ::Room and
not ::TheRoom which is also fixed here.

Ref:
  - #2787

Co-authored-by: Jamal-A-Mohamed <jamalashur@gmail.com>
Co-authored-by: Salvador <salvador.tena@scientist.com>

* Fix/Deprecate FmaBrotherhood Generator

This commit fixes the naming discrpencies with the FmaBrotherhood (now
FullmetalAlchemistBrotherhood) class and its filename.  This adds
deprecation warnings for the old FmaBrotherhood class and also makes the
new FullmetalAlchemistBrotherhood class.

Fix:
  - #2853

* Refactor deprecation for `FmaBrotherhood`

This commit will refactor the changes from `FmaBrotherhood` to
`FullmetalAlchemistBrotherhood` and use `Faker::Deprecator`.

---------

Co-authored-by: Jamal-A-Mohamed <jamalashur@gmail.com>
Co-authored-by: Salvador <salvador.tena@scientist.com>
Co-authored-by: Stefanni Brasil <stefannibrasil@gmail.com>

* Bump i18n from 1.14.1 to 1.14.4 (#2913)

Bumps [i18n](https://github.com/ruby-i18n/i18n) from 1.14.1 to 1.14.4.
- [Release notes](https://github.com/ruby-i18n/i18n/releases)
- [Changelog](https://github.com/ruby-i18n/i18n/blob/master/CHANGELOG.md)
- [Commits](ruby-i18n/i18n@v1.14.1...v1.14.4)

---
updated-dependencies:
- dependency-name: i18n
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Remove duplicates in doc file (#2914)

* Bump rubocop from 1.60.2 to 1.62.1 (#2916)

Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.60.2 to 1.62.1.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](rubocop/rubocop@v1.60.2...v1.62.1)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump yard from 0.9.34 to 0.9.36 (#2909)

Bumps [yard](https://github.com/lsegal/yard) from 0.9.34 to 0.9.36.
- [Release notes](https://github.com/lsegal/yard/releases)
- [Changelog](https://github.com/lsegal/yard/blob/main/CHANGELOG.md)
- [Commits](lsegal/yard@v0.9.34...v0.9.36)

---
updated-dependencies:
- dependency-name: yard
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Deprecated Faker::Australia

* Added Docs for Australia

* Updated Readme to include Locations

* Updated locales path for australia

* updated test to differentiate deprecated methods

* Removed whitespaces from australia.yml

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Andrew Nduati <nduatiandrew@gmail.com>
Co-authored-by: Jamal-A-Mohamed <37128483+Jamal-A-Mohamed@users.noreply.github.com>
Co-authored-by: jamal.mohamed <jamal.mohamed@covermymeds.com>
Co-authored-by: Stefanni Brasil <stefannibrasil@gmail.com>
Co-authored-by: Thiago Araujo <thd.araujo@gmail.com>
Co-authored-by: Kirk Wang <kirk.wang@scientist.com>
Co-authored-by: Jamal-A-Mohamed <jamalashur@gmail.com>
Co-authored-by: Salvador <salvador.tena@scientist.com>
Co-authored-by: Michael Marusyk <31774981+mmarusyk@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants