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

Add CLI - Integrate fakerbot 🤖 #1507

Merged
merged 17 commits into from
Mar 3, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
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
  • Loading branch information
akabiru committed Jan 5, 2019
commit 552de6ede3ff05b401b384d18410781b7a272061
5 changes: 3 additions & 2 deletions lib/faker/cli.rb → lib/cli.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# frozen_string_literal: true

require 'thor'

require 'cli/commands/list'
require 'cli/commands/search'
require 'faker/version'
require 'faker/cli/commands/list'
require 'faker/cli/commands/search'

module Faker
module CLI
Expand Down
2 changes: 2 additions & 0 deletions lib/faker/cli/command.rb → lib/cli/command.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'forwardable'

require_relative 'reflector'
Expand Down
2 changes: 2 additions & 0 deletions lib/faker/cli/commands/list.rb → lib/cli/commands/list.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../command'

module Faker
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../command'

module Faker
Expand Down
4 changes: 4 additions & 0 deletions lib/faker/cli/reflector.rb → lib/cli/reflector.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# frozen_string_literal: true

require 'faker'

module Faker
module CLI
# Exposes `Faker` reflection methods
Expand Down
6 changes: 4 additions & 2 deletions lib/faker/cli/renderer.rb → lib/cli/renderer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'pastel'
require 'tty/pager'
require 'tty/screen'
Expand All @@ -14,7 +16,7 @@ def self.call(*args)

def initialize(hash, options, output)
@hash = hash
@options = options.deep_symbolize_keys
@options = options
@output = output
@crayon = Pastel.new(enabled: output.tty?)
@pager = TTY::Pager.new(command: 'less -R')
Expand Down Expand Up @@ -69,7 +71,7 @@ def leaf_args(method, const)
end

def verbose?
options[:verbose] == true
options[:verbose]
end

def verbose_output(method, const, arr)
Expand Down
2 changes: 1 addition & 1 deletion test/test_determinism.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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. 🙂

end.sort
end

Expand Down