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

chore: Rename from FakerBot to Faker::CLI #28

Merged
merged 2 commits into from
Jul 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ source "https://rubygems.org"

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

# Specify your gem's dependencies in fakerbot.gemspec
# Specify your gem's dependencies in faker-cli.gemspec
gemspec
95 changes: 45 additions & 50 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
fakerbot (0.4.4)
faker-cli (0.4.4)
faker
pastel (~> 0.7.2)
thor (~> 0.20.0)
Expand All @@ -13,26 +13,21 @@ GEM
remote: https://rubygems.org/
specs:
coderay (1.1.2)
concurrent-ruby (1.1.4)
concurrent-ruby (1.1.5)
coveralls (0.7.1)
multi_json (~> 1.3)
rest-client
simplecov (>= 0.7)
term-ansicolor
thor
diff-lcs (1.3)
docile (1.3.1)
domain_name (0.5.20180417)
docile (1.3.2)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
equatable (0.5.0)
faker (1.9.1)
equatable (0.6.1)
faker (1.9.5)
i18n (>= 0.7)
pastel (~> 0.7.2)
thor (~> 0.20.0)
tty-pager (~> 0.12.0)
tty-screen (~> 0.6.5)
tty-tree (~> 0.2.0)
ffi (1.9.25)
ffi (1.11.1)
formatador (0.2.5)
guard (2.15.0)
formatador (>= 0.2.4)
Expand All @@ -50,28 +45,28 @@ GEM
rspec (>= 2.99.0, < 4.0)
http-cookie (1.0.3)
domain_name (~> 0.5)
i18n (1.5.2)
i18n (1.6.0)
concurrent-ruby (~> 1.0)
json (2.1.0)
json (2.2.0)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
lumberjack (1.0.13)
method_source (0.9.0)
mime-types (3.1)
method_source (0.9.2)
mime-types (3.2.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mime-types-data (3.2019.0331)
multi_json (1.13.1)
nenv (0.3.0)
netrc (0.11.0)
notiffany (0.1.1)
nenv (~> 0.1)
shellany (~> 0.0)
pastel (0.7.2)
equatable (~> 0.5.0)
tty-color (~> 0.4.0)
pry (0.11.3)
pastel (0.7.3)
equatable (~> 0.6)
tty-color (~> 0.5)
pry (0.12.2)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
rake (10.5.0)
Expand All @@ -82,61 +77,61 @@ GEM
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rspec (3.7.0)
rspec-core (~> 3.7.0)
rspec-expectations (~> 3.7.0)
rspec-mocks (~> 3.7.0)
rspec-core (3.7.1)
rspec-support (~> 3.7.0)
rspec-expectations (3.7.0)
rspec (3.8.0)
rspec-core (~> 3.8.0)
rspec-expectations (~> 3.8.0)
rspec-mocks (~> 3.8.0)
rspec-core (3.8.2)
rspec-support (~> 3.8.0)
rspec-expectations (3.8.4)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.7.0)
rspec-mocks (3.7.0)
rspec-support (~> 3.8.0)
rspec-mocks (3.8.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.7.0)
rspec-support (3.7.1)
rspec-support (~> 3.8.0)
rspec-support (3.8.2)
ruby_dep (1.5.0)
shellany (0.0.1)
simplecov (0.16.1)
simplecov (0.17.0)
docile (~> 1.1)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.2)
strings (0.1.4)
strings-ansi (~> 0.1.0)
unicode-display_width (~> 1.4.0)
unicode_utils (~> 1.4.0)
strings (0.1.5)
strings-ansi (~> 0.1)
unicode-display_width (~> 1.5)
unicode_utils (~> 1.4)
strings-ansi (0.1.0)
term-ansicolor (1.6.0)
term-ansicolor (1.7.1)
tins (~> 1.0)
thor (0.20.0)
tins (1.16.3)
tty-color (0.4.3)
tty-pager (0.12.0)
thor (0.20.3)
tins (1.21.0)
tty-color (0.5.0)
tty-pager (0.12.1)
strings (~> 0.1.4)
tty-screen (~> 0.6)
tty-which (~> 0.4)
tty-screen (0.6.5)
tty-tree (0.2.0)
tty-which (0.4.0)
tty-screen (0.7.0)
tty-tree (0.3.0)
tty-which (0.4.1)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.5)
unicode-display_width (1.4.1)
unf_ext (0.0.7.6)
unicode-display_width (1.6.0)
unicode_utils (1.4.0)

PLATFORMS
ruby

DEPENDENCIES
bundler (~> 1.16)
bundler (>= 1.16)
coveralls
fakerbot!
faker-cli!
guard-rspec
pry
rake (~> 10.0)
rspec (~> 3.0)
simplecov (~> 0.12)

BUNDLED WITH
1.17.3
2.0.2
2 changes: 1 addition & 1 deletion bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# frozen_string_literal: true

require 'bundler/setup'
require 'fakerbot'
require 'faker/cli'

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.
Expand Down
6 changes: 3 additions & 3 deletions bin/fakerbot → bin/faker
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@

lib_path = File.expand_path('../lib', __dir__)
$LOAD_PATH.unshift(lib_path) unless $LOAD_PATH.include?(lib_path)
require 'fakerbot'
require 'faker/cli'

Signal.trap('INT') do
warn("\n#{caller.join("\n")}: interrupted")
exit(1)
end

begin
FakerBot::CLI.start
rescue FakerBot::CLI::Error => err
Faker::CLI::Base.start
rescue Faker::CLI::Base::Error => err
puts "ERROR: #{err.message}"
exit 1
end
12 changes: 6 additions & 6 deletions fakerbot.gemspec → faker-cli.gemspec
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@

lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "fakerbot/version"
require "faker/cli/version"

Gem::Specification.new do |spec|
spec.name = "fakerbot"
spec.version = FakerBot::VERSION
spec.name = "faker-cli"
spec.version = Faker::CLI::VERSION
spec.authors = ["Austin Kabiru"]
spec.email = ["makabby@gmail.com"]

spec.summary = %q{A stympy/faker lookup command line tool.}
spec.description = %q{Quickly look up Faker methods without leaving your terminal!}
spec.homepage = "https://github.com/akabiru/fakerbot"
spec.homepage = "https://github.com/faker-ruby/faker-cli"
spec.license = "MIT"

spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
spec.bindir = 'bin'
spec.executables = ['fakerbot']
spec.executables = ['faker']
spec.require_paths = ['lib']

spec.add_dependency "faker"
Expand All @@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
spec.add_dependency "tty-screen"
spec.add_dependency "tty-tree"

spec.add_development_dependency "bundler", "~> 1.16"
spec.add_development_dependency "bundler", ">= 1.16"
spec.add_development_dependency "coveralls"
spec.add_development_dependency "guard-rspec"
spec.add_development_dependency "pry"
Expand Down
3 changes: 3 additions & 0 deletions lib/faker-cli.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# frozen_string_literal: true

require_relative 'faker/cli'
53 changes: 53 additions & 0 deletions lib/faker/cli.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# frozen_string_literal: true

require 'thor'

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

module Faker
module CLI
class Base < Thor
Error = Class.new(StandardError)
# Skip default deprecation warning output; the CLI will display that.
Gem::Deprecate.skip_during do
desc 'version', 'Faker version'
def version
puts "v#{Faker::CLI::VERSION}"
end
map %w[--version -v] => :version

desc 'list', 'List all Faker constants'
method_option :help, aliases: '-h', type: :boolean,
desc: 'Display usage information'
method_option :show_methods, aliases: '-m', type: :boolean, default: true,
desc: 'Display Faker constants with methods'
method_option :verbose, aliases: '-v', type: :boolean,
desc: 'Include sample Faker output'
def list(*)
if options[:help]
invoke :help, ['list']
else
Faker::CLI::Commands::List.new(options).execute
end
end

desc 'search [Faker]', 'Search Faker method(s)'
method_option :help, aliases: '-h', type: :boolean,
desc: 'Display usage information'
method_option :show_methods, aliases: '-m', type: :boolean, default: true,
desc: 'Display Faker constants with methods'
method_option :verbose, aliases: '-v', type: :boolean,
desc: 'Include sample Faker output'
def search(query)
if options[:help]
invoke :help, ['search']
else
Faker::CLI::Commands::Search.new(options).execute(query)
end
end
end
end
end
end
24 changes: 24 additions & 0 deletions lib/faker/cli/command.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# frozen_string_literal: true

require 'forwardable'

require_relative 'renderer'

module Faker
module CLI
class Command
extend Forwardable

def_delegators :command, :run
attr_reader :options

def initialize(options)
@options = options
end

def render(result, output)
Renderer.call(result, options, output)
end
end
end
end
17 changes: 17 additions & 0 deletions lib/faker/cli/commands/list.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

require_relative '../command'
require_relative '../reflectors/list'

module Faker
module CLI
module Commands
class List < Command
def execute(output: $stdout)
result = Reflectors::List.call(options)
render(result, output)
end
end
end
end
end
29 changes: 29 additions & 0 deletions lib/faker/cli/commands/search.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# frozen_string_literal: true

require_relative '../command'
require_relative '../reflectors/search'

module Faker
module CLI
module Commands
class Search < Command
def execute(input, output: $stdout)
result = Reflectors::Search.call(input)
render(result, output)
end

private

def render(result, output)
return not_found(output) if result.empty?

super(result, output)
end

def not_found(output)
output.puts "\nSorry, we couldn't find a match 😢", "\n"
end
end
end
end
end
Loading