Navigation Menu

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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CLI - Integrate fakerbot 馃 #1507

Merged
merged 17 commits into from Mar 3, 2019
Merged

Add CLI - Integrate fakerbot 馃 #1507

merged 17 commits into from Mar 3, 2019

Conversation

akabiru
Copy link
Contributor

@akabiru akabiru commented Jan 5, 2019

What does this PR do?

Integrates the fakerbot gem into Faker as it's CLI

How should this be manually tested?

$ rake build
$ gem install pkg/faker-1.9.3.gem
$ faker

What are the relevant GitHub issues?

Closes #1505

Questions:

  • This seems like a major change to me, how are releases handled? Should we bump the version as part of this PR?

Screenshots

screenshot 2019-01-05 at 03 02 08

screenshot 2019-01-05 at 03 02 20

@akabiru akabiru changed the title Add CLI - Integrate fakerbot Add CLI - Integrate fakerbot 馃 Jan 5, 2019
@vbrazo vbrazo assigned vbrazo and akabiru and unassigned vbrazo Jan 5, 2019
@stympy
Copy link
Contributor

stympy commented Jan 5, 2019

We won鈥檛 bump the version as part of this PR. The version bump will be separate.

@akabiru
Copy link
Contributor Author

akabiru commented Jan 5, 2019

Sounds good! 馃憤馃従

@akabiru
Copy link
Contributor Author

akabiru commented Jan 13, 2019

Hi @vbrazo , had a chance to review this PR? 馃檪

@akabiru akabiru mentioned this pull request Jan 14, 2019
4 tasks
The Reflector was doing too much; handling Search and List reflections
which made it a tad harder to follow.

This commit defines a Reflection interface and the correspoding
subclasses.
@akabiru
Copy link
Contributor Author

akabiru commented Jan 22, 2019

Hi @stympy @vbrazo , I recently made some improvements to the fakerbot reflection object that I thought would be useful here.

Looking forward to your review, please shout if there's anything I can do to make it smoother for you. Cheers. 馃嵒

@vbrazo
Copy link
Member

vbrazo commented Jan 24, 2019

Apologies for the slowness. This week has been busy. I started reading the files, but I still need more time to pull the code and check the work. I'll do that over the next days.

@akabiru
Copy link
Contributor Author

akabiru commented Jan 24, 2019

No worries Vitor, totally understand 馃挴 . Please shout if you have any questions. 馃檪

There's an erroneous 'null byte' error in the CI which could be caused
by the bundler version.

Further, As of Ruby 2.6.0, bundler is now built into Ruby, so no need to
install it ourselves
Copy link
Member

@vbrazo vbrazo left a comment

Choose a reason for hiding this comment

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

Tested locally and liked what I saw

@@ -45,7 +45,7 @@ def all_methods

def subclasses
Faker.constants.delete_if do |subclass|
%i[Base Bank Books Cat Char Base58 ChileRut Config Creature Date Dog DragonBall Dota ElderScrolls Fallout Games GamesHalfLife HeroesOfTheStorm Internet JapaneseMedia LeagueOfLegends Movies Myst Overwatch OnePiece Pokemon SwordArtOnline TvShows Time VERSION Witcher WorldOfWarcraft Zelda].include?(subclass)
%i[Base Bank Books Cat Char Base58 ChileRut CLI Config Creature Date Dog DragonBall Dota ElderScrolls Fallout Games GamesHalfLife HeroesOfTheStorm Internet JapaneseMedia LeagueOfLegends Movies Myst Overwatch OnePiece Pokemon SwordArtOnline TvShows Time VERSION Witcher WorldOfWarcraft Zelda].include?(subclass)
Copy link
Member

@vbrazo vbrazo Feb 9, 2019

Choose a reason for hiding this comment

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

We should get rid of this big array and think about a better way to check 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.

I agree, do we want to mark that as a separate piece of work?

Copy link
Member

Choose a reason for hiding this comment

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

yes please

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe we should raise that as a separate issue? At present, I'm afraid I don't think I have enough background to raise the issue for this case. 馃檪

README.md Outdated
@@ -62,6 +62,14 @@ Faker::Name.name #=> "Christophe Bartell"
Faker::Internet.email #=> "kirsten.greenholt@corkeryfisher.info"
```

### CLI
Copy link
Member

Choose a reason for hiding this comment

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

This change should go in our unreleased_README.md.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good shout. 馃憤

lib/cli.rb Outdated
class Base < Thor
Error = Class.new(StandardError)
# Do not print depracation warnings; the CLI will do that
Gem::Deprecate.skip = true
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to turn this false after executing the operations?

I'm asking you because we're using namespaces and there are a lot of deprecation warnings. Are we assuming that users will always use the cli?

Copy link
Contributor Author

@akabiru akabiru Feb 17, 2019

Choose a reason for hiding this comment

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

Do we want to turn this false after executing the operations?

Thanks! This makes perfect sense to me, I had missed that. I'll make the change. 猸愶笍

Background

Good call here, the intention was to disable the default deprecation warnings only in the context of the CLI. since it checks for deprecated methods and marks them.

Previously, we'd see the full default deprecation print out after the CLI exited as capture in https://github.com/akabiru/fakerbot/issues/7 - thus the need to gracefully handle the deprecation warnings (in the context of the CLI)

spec.add_dependency('thor', '~> 0.20.0')
spec.add_dependency('tty-pager', '~> 0.12.0')
spec.add_dependency('tty-screen', '~> 0.6.5')
spec.add_dependency('tty-tree', '~> 0.2.0')
Copy link
Member

Choose a reason for hiding this comment

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

Adding these dependencies is a pretty big deal. Are we comfortable with them? I saw the terminal response. It's pretty cool.

Thoughts? @stympy

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a valid concern, from my POV, these libraries go a long way in making the CLI interface easier to work with. 馃檪 The alternative would be to write it all ourselves which I'm not sure about

Choose a reason for hiding this comment

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

FWIW, I find all these dependencies to be a big deal. I opened an issue about it (#1642) and plan to stay on 1.9.3 for the time being.

Copy link
Member

Choose a reason for hiding this comment

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

@myronmarston your concern is valid.

@akabiru would you agree to remove these dependencies and just show a formatted list of searched results?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey folks, apologies for the very delayed response (on vacation). I think the move to a separate gem is the sensible approach. And allows users to opt-in into using the gem.

It did start as a separate gem , no strong objections on this one. 馃檪

@vbrazo I'm happy to assist with the extraction &/migration as well.

* move cli doc to unreleased
* Reinstate rubygems deprecation warnings
class Base < Thor
Error = Class.new(StandardError)
# Skip default deprecation warning output; the CLI will display that.
Gem::Deprecate.skip_during do
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wrapping the CLI methods in Gem::Deprecate.skip_during block ensures we safely skip the warnings only in the CLI. Although it's intended for use in tests only, it seems like a sensible solution to me. Ref. https://ruby-doc.org/stdlib-1.9.3/libdoc/rubygems/rdoc/Gem/Deprecate.html

@vbrazo vbrazo merged commit 2ef261c into faker-ruby:master Mar 3, 2019
@akabiru akabiru deleted the feature/pull-in-fakerbot branch March 3, 2019 12:41
@akabiru
Copy link
Contributor Author

akabiru commented Mar 3, 2019

Thank you Vitor. Looking forward to continuously making it even better as a community. 馃檪

michebble pushed a commit to michebble/faker that referenced this pull request Feb 16, 2020
* feat(cli): Pull in fakerbot gem logic

* chore(cli): Extract module outside of `faker` dir

The module dir `faker` houses the main "faker" namespaces; and it should
remain that way.

Best to have the CLI live outside the directory; similar to helpers

* feat(cli): Add `faker` excecutable

* feat(cli): Add renderer; reflector unit tests

* feat(cli): Add commands tests

* feat(cli): Add integration tests

* feat(cli): Add documentation 馃摉

* chore(cli): Extract constructor to base command

* fix(cli): Amend faker version load path

- Add integration test to cover that

* fix(cli): Skip default deprecation warning output in the CLI

* chore(cli): Amend var names

* chore(reflectors): Distribute Reflector responsibilities

The Reflector was doing too much; handling Search and List reflections
which made it a tad harder to follow.

This commit defines a Reflection interface and the correspoding
subclasses.

* chore: Don't specify bunlder version

There's an erroneous 'null byte' error in the CI which could be caused
by the bundler version.

Further, As of Ruby 2.6.0, bundler is now built into Ruby, so no need to
install it ourselves

* chore: Address review comments

* move cli doc to unreleased
* Reinstate rubygems deprecation warnings

* chore: Skip Gem::Deprecate warning output in CLI
davidmorton0 pushed a commit to davidmorton0/faker that referenced this pull request Jul 12, 2021
* feat(cli): Pull in fakerbot gem logic

* chore(cli): Extract module outside of `faker` dir

The module dir `faker` houses the main "faker" namespaces; and it should
remain that way.

Best to have the CLI live outside the directory; similar to helpers

* feat(cli): Add `faker` excecutable

* feat(cli): Add renderer; reflector unit tests

* feat(cli): Add commands tests

* feat(cli): Add integration tests

* feat(cli): Add documentation 馃摉

* chore(cli): Extract constructor to base command

* fix(cli): Amend faker version load path

- Add integration test to cover that

* fix(cli): Skip default deprecation warning output in the CLI

* chore(cli): Amend var names

* chore(reflectors): Distribute Reflector responsibilities

The Reflector was doing too much; handling Search and List reflections
which made it a tad harder to follow.

This commit defines a Reflection interface and the correspoding
subclasses.

* chore: Don't specify bunlder version

There's an erroneous 'null byte' error in the CI which could be caused
by the bundler version.

Further, As of Ruby 2.6.0, bundler is now built into Ruby, so no need to
install it ourselves

* chore: Address review comments

* move cli doc to unreleased
* Reinstate rubygems deprecation warnings

* chore: Skip Gem::Deprecate warning output in CLI
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.

Look Up Faker Methods with the fakerbot gem 馃攳
4 participants