diff --git a/Gemfile b/Gemfile index 223e913..f7371c6 100644 --- a/Gemfile +++ b/Gemfile @@ -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 diff --git a/Gemfile.lock b/Gemfile.lock index cb87ca3..89c4a92 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) @@ -13,7 +13,7 @@ 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 @@ -21,18 +21,13 @@ GEM 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) @@ -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) @@ -82,56 +77,56 @@ 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) @@ -139,4 +134,4 @@ DEPENDENCIES simplecov (~> 0.12) BUNDLED WITH - 1.17.3 + 2.0.2 diff --git a/bin/console b/bin/console index 900830c..0af82b0 100755 --- a/bin/console +++ b/bin/console @@ -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. diff --git a/bin/fakerbot b/bin/faker similarity index 78% rename from bin/fakerbot rename to bin/faker index ec0e9ea..866e59f 100755 --- a/bin/fakerbot +++ b/bin/faker @@ -3,7 +3,7 @@ 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") @@ -11,8 +11,8 @@ Signal.trap('INT') do 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 diff --git a/fakerbot.gemspec b/faker-cli.gemspec similarity index 80% rename from fakerbot.gemspec rename to faker-cli.gemspec index 223b129..62397c9 100644 --- a/fakerbot.gemspec +++ b/faker-cli.gemspec @@ -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" @@ -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" diff --git a/lib/faker-cli.rb b/lib/faker-cli.rb new file mode 100644 index 0000000..46e859c --- /dev/null +++ b/lib/faker-cli.rb @@ -0,0 +1,3 @@ +# frozen_string_literal: true + +require_relative 'faker/cli' diff --git a/lib/faker/cli.rb b/lib/faker/cli.rb new file mode 100644 index 0000000..0f513e8 --- /dev/null +++ b/lib/faker/cli.rb @@ -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 diff --git a/lib/faker/cli/command.rb b/lib/faker/cli/command.rb new file mode 100644 index 0000000..277e7a1 --- /dev/null +++ b/lib/faker/cli/command.rb @@ -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 diff --git a/lib/faker/cli/commands/list.rb b/lib/faker/cli/commands/list.rb new file mode 100644 index 0000000..060c88d --- /dev/null +++ b/lib/faker/cli/commands/list.rb @@ -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 diff --git a/lib/faker/cli/commands/search.rb b/lib/faker/cli/commands/search.rb new file mode 100644 index 0000000..ec04ecc --- /dev/null +++ b/lib/faker/cli/commands/search.rb @@ -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 diff --git a/lib/faker/cli/reflector.rb b/lib/faker/cli/reflector.rb new file mode 100644 index 0000000..7ff45b3 --- /dev/null +++ b/lib/faker/cli/reflector.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: true + +require 'faker' + +module Faker + module CLI + # Abstract `Faker` Reflector - introspects the `Faker` module + # + # @api private + # @abstract + # + class Reflector + Faker::Base.class_eval do + # Select `Faker` subclasses + # @return [Array] `Faker::Base` sub classes + def self.descendants + @descendants ||= ObjectSpace.each_object(Class).select do |klass| + klass < self + end + end + + # Select public class methods + # @return [Array] public methods + def self.my_singleton_methods + singleton_methods(false).select { |m| respond_to?(m) } + end + end + + attr_reader :descendants_with_methods + + def initialize(*) + @descendants_with_methods = Hash.new { |h, k| h[k] = [] } + end + + protected + + def store(descendant, methods) + return if methods.empty? + + descendants_with_methods[descendant].concat(methods) + end + + def faker_descendants + @faker_descendants ||= Faker::Base.descendants + end + end + end +end diff --git a/lib/faker/cli/reflectors/list.rb b/lib/faker/cli/reflectors/list.rb new file mode 100644 index 0000000..719188b --- /dev/null +++ b/lib/faker/cli/reflectors/list.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +require_relative '../reflector' + +module Faker + module CLI + module Reflectors + # List command reflector + # @api private + # + class List < Reflector + attr_reader :show_methods + + def self.call(options) + new(options).call + end + + def initialize(options = {}) + @show_methods = options[:show_methods] + + super + end + + def call + show_methods ? all_descendants_with_methods : faker_descendants + end + + private + + def all_descendants_with_methods + faker_descendants.each do |descendant| + store(descendant, descendant.my_singleton_methods) + end + descendants_with_methods + end + end + end + end +end diff --git a/lib/faker/cli/reflectors/search.rb b/lib/faker/cli/reflectors/search.rb new file mode 100644 index 0000000..48e88a0 --- /dev/null +++ b/lib/faker/cli/reflectors/search.rb @@ -0,0 +1,46 @@ +# frozen_string_literal: true + +require_relative '../reflector' + +module Faker + module CLI + module Reflectors + # Find command reflector + # @api private + # + class Search < Reflector + attr_reader :query + + def self.call(query) + new(query).call + end + + def initialize(query) + @query = query + + super + end + + def call + search_descendants_matching_query + descendants_with_methods + end + + private + + def search_descendants_matching_query + faker_descendants.each do |descendant| + methods = descendant.my_singleton_methods + matching = methods.select { |method| query_matches?(method.to_s) } + store(descendant, matching) + end + end + + def query_matches?(method_name) + method_name_parts = method_name.split(/_/).reject(&:empty?) + query.match(/#{method_name_parts.join('|')}/) + end + end + end + end +end diff --git a/lib/faker/cli/renderer.rb b/lib/faker/cli/renderer.rb new file mode 100644 index 0000000..0e3f635 --- /dev/null +++ b/lib/faker/cli/renderer.rb @@ -0,0 +1,93 @@ +# frozen_string_literal: true + +require 'pastel' +require 'tty/pager' +require 'tty/screen' +require 'tty/tree' + +module Faker + module CLI + class Renderer + attr_reader :crayon, :hash, :options, :output, :pager + + def self.call(*args) + new(*args).call + end + + def initialize(hash, options, output) + @hash = hash + @options = options + @output = output + @crayon = Pastel.new(enabled: output.tty?) + @pager = TTY::Pager.new(command: 'less -R') + end + + def call + if paginable? + pager.page(render) + else + output.puts(render) + end + end + + def render + tree.render + end + + def tree + @tree ||= TTY::Tree.new(build_tree) + end + + def paginable? + gt_screen_height? && output.tty? + end + + def gt_screen_height? + tree.nodes.size > TTY::Screen.height + end + + private + + def build_tree + results = hash.reduce({}) do |h, (const, methods)| + h.merge! node(const, methods&.sort) + end + + results.sort_by(&:to_s).to_h + end + + def node(const, methods) + { + crayon.green(const.to_s) => leaf(const, methods) + } + end + + def leaf(const, methods) + (methods || []).map { |m| crayon.cyan(*leaf_args(m, const)) } + end + + def leaf_args(method, const) + [method.to_s].tap { |arr| verbose_output(method, const, arr) if verbose? } + end + + def verbose? + options[:verbose] + end + + def verbose_output(method, const, arr) + fake, message = faker_method(method, const) + arr << crayon.dim.white("=> #{fake}") << crayon.dim.magenta.bold(message.to_s) + end + + def faker_method(method, const) + [const.public_send(method), ensure_method_is_supported(method, const)] + rescue ArgumentError => _exception + ['N/A', ''] + end + + def ensure_method_is_supported(method, const) + const.respond_to?(:"_deprecated_#{method}") ? ' ( WILL BE DEPRECATED )' : '' + end + end + end +end diff --git a/lib/faker/cli/version.rb b/lib/faker/cli/version.rb new file mode 100644 index 0000000..3c6d665 --- /dev/null +++ b/lib/faker/cli/version.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +module Faker + module CLI + VERSION = '0.4.4' + end +end diff --git a/lib/fakerbot/renderer.rb b/lib/faker/renderer.rb similarity index 99% rename from lib/fakerbot/renderer.rb rename to lib/faker/renderer.rb index 2d3bada..a59fa03 100644 --- a/lib/fakerbot/renderer.rb +++ b/lib/faker/renderer.rb @@ -5,7 +5,7 @@ require 'tty/screen' require 'tty/tree' -module FakerBot +module Faker::CLI class Renderer attr_reader :crayon, :hash, :options, :output, :pager diff --git a/lib/fakerbot.rb b/lib/fakerbot.rb deleted file mode 100644 index a5ef85b..0000000 --- a/lib/fakerbot.rb +++ /dev/null @@ -1,3 +0,0 @@ -# frozen_string_literal: true - -require_relative 'fakerbot/cli' diff --git a/lib/fakerbot/cli.rb b/lib/fakerbot/cli.rb deleted file mode 100644 index 8270f18..0000000 --- a/lib/fakerbot/cli.rb +++ /dev/null @@ -1,52 +0,0 @@ -# frozen_string_literal: true - -require 'thor' - -require 'fakerbot/commands/list' -require 'fakerbot/commands/search' -require 'fakerbot/version' - -module FakerBot - class CLI < Thor - Error = Class.new(StandardError) - # Do not print depracation warnings; the CLI will do that - Gem::Deprecate.skip = true - - desc 'version', 'fakerbot version' - def version - require_relative 'version' - puts "v#{FakerBot::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 - FakerBot::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 - FakerBot::Commands::Search.new(options).execute(query) - end - end - end -end diff --git a/lib/fakerbot/command.rb b/lib/fakerbot/command.rb deleted file mode 100644 index 3ba9d20..0000000 --- a/lib/fakerbot/command.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -require 'forwardable' - -require_relative 'renderer' - -module FakerBot - class Command - extend Forwardable - - def_delegators :command, :run - attr_reader :options - - def render(result, output) - Renderer.call(result, options, output) - end - end -end diff --git a/lib/fakerbot/commands/list.rb b/lib/fakerbot/commands/list.rb deleted file mode 100644 index 0bd7096..0000000 --- a/lib/fakerbot/commands/list.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -require_relative '../command' -require_relative '../reflectors/list' - -module FakerBot - module Commands - class List < FakerBot::Command - def initialize(options) - @options = options - end - - def execute(output: $stdout) - result = Reflectors::List.call(options) - render result, output - end - end - end -end diff --git a/lib/fakerbot/commands/search.rb b/lib/fakerbot/commands/search.rb deleted file mode 100644 index 992b92d..0000000 --- a/lib/fakerbot/commands/search.rb +++ /dev/null @@ -1,31 +0,0 @@ -# frozen_string_literal: true - -require_relative '../command' -require_relative '../reflectors/search' - -module FakerBot - module Commands - class Search < FakerBot::Command - def initialize(options) - @options = options - end - - 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 diff --git a/lib/fakerbot/reflector.rb b/lib/fakerbot/reflector.rb deleted file mode 100644 index aad41c5..0000000 --- a/lib/fakerbot/reflector.rb +++ /dev/null @@ -1,46 +0,0 @@ -# frozen_string_literal: true - -require 'faker' - -module FakerBot - # Abstract `Faker` Reflector - introspects the `Faker` module - # - # @api private - # @abstract - # - class Reflector - Faker::Base.class_eval do - # Select `Faker` subclasses - # @return [Array] `Faker::Base` sub classes - def self.descendants - @descendants ||= ObjectSpace.each_object(Class).select do |klass| - klass < self - end - end - - # Select public class methods - # @return [Array] public methods - def self.my_singleton_methods - singleton_methods(false).select { |m| respond_to?(m) } - end - end - - attr_reader :descendants_with_methods - - def initialize(*) - @descendants_with_methods = Hash.new { |h, k| h[k] = [] } - end - - protected - - def store(descendant, methods) - return if methods.empty? - - descendants_with_methods[descendant].concat(methods) - end - - def faker_descendants - @faker_descendants ||= Faker::Base.descendants - end - end -end diff --git a/lib/fakerbot/reflectors/list.rb b/lib/fakerbot/reflectors/list.rb deleted file mode 100644 index 94912ce..0000000 --- a/lib/fakerbot/reflectors/list.rb +++ /dev/null @@ -1,37 +0,0 @@ -# frozen_string_literal: true - -require_relative '../reflector' - -module FakerBot - module Reflectors - # List command reflector - # @api private - # - class List < FakerBot::Reflector - attr_reader :show_methods - - def self.call(options) - new(options).call - end - - def initialize(options = {}) - @show_methods = options[:show_methods] - - super - end - - def call - show_methods ? all_descendants_with_methods : faker_descendants - end - - private - - def all_descendants_with_methods - faker_descendants.each do |descendant| - store(descendant, descendant.my_singleton_methods) - end - descendants_with_methods - end - end - end -end diff --git a/lib/fakerbot/reflectors/search.rb b/lib/fakerbot/reflectors/search.rb deleted file mode 100644 index d197214..0000000 --- a/lib/fakerbot/reflectors/search.rb +++ /dev/null @@ -1,44 +0,0 @@ -# frozen_string_literal: true - -require_relative '../reflector' - -module FakerBot - module Reflectors - # Find command reflector - # @api private - # - class Search < FakerBot::Reflector - attr_reader :query - - def self.call(query) - new(query).call - end - - def initialize(query) - @query = query - - super - end - - def call - search_descendants_matching_query - descendants_with_methods - end - - private - - def search_descendants_matching_query - faker_descendants.each do |descendant| - methods = descendant.my_singleton_methods - matching = methods.select { |method| query_matches?(method.to_s) } - store(descendant, matching) - end - end - - def query_matches?(method_name) - method_name_parts = method_name.split(/_/).reject(&:empty?) - query.match(/#{method_name_parts.join('|')}/) - end - end - end -end diff --git a/lib/fakerbot/templates/list/.gitkeep b/lib/fakerbot/templates/list/.gitkeep deleted file mode 100644 index 792d600..0000000 --- a/lib/fakerbot/templates/list/.gitkeep +++ /dev/null @@ -1 +0,0 @@ -# diff --git a/lib/fakerbot/version.rb b/lib/fakerbot/version.rb deleted file mode 100644 index 29781ef..0000000 --- a/lib/fakerbot/version.rb +++ /dev/null @@ -1,5 +0,0 @@ -# frozen_string_literal: true - -module FakerBot - VERSION = '0.4.4' -end diff --git a/spec/fakerbot/commands/list_spec.rb b/spec/faker/cli/commands/list_spec.rb similarity index 75% rename from spec/fakerbot/commands/list_spec.rb rename to spec/faker/cli/commands/list_spec.rb index 40113b2..e8144d9 100644 --- a/spec/fakerbot/commands/list_spec.rb +++ b/spec/faker/cli/commands/list_spec.rb @@ -1,9 +1,11 @@ -require 'fakerbot/commands/list' +# frozen_string_literal: true -RSpec.describe FakerBot::Commands::List do +require 'faker/cli/commands/list' + +RSpec.describe Faker::CLI::Commands::List do let(:output) { StringIO.new } let(:options) { {} } - let(:command) { FakerBot::Commands::List.new(options) } + let(:command) { Faker::CLI::Commands::List.new(options) } before do command.execute(output: output) diff --git a/spec/fakerbot/commands/search_spec.rb b/spec/faker/cli/commands/search_spec.rb similarity index 89% rename from spec/fakerbot/commands/search_spec.rb rename to spec/faker/cli/commands/search_spec.rb index edb5be9..0d76d90 100644 --- a/spec/fakerbot/commands/search_spec.rb +++ b/spec/faker/cli/commands/search_spec.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -require 'fakerbot/commands/search' +require 'faker/cli/commands/search' -RSpec.describe FakerBot::Commands::Search do +RSpec.describe Faker::CLI::Commands::Search do context 'when query object exists' do it 'returns results' do output = StringIO.new diff --git a/spec/fakerbot/reflectors/list_spec.rb b/spec/faker/cli/reflectors/list_spec.rb similarity index 95% rename from spec/fakerbot/reflectors/list_spec.rb rename to spec/faker/cli/reflectors/list_spec.rb index 256d132..90005ab 100644 --- a/spec/fakerbot/reflectors/list_spec.rb +++ b/spec/faker/cli/reflectors/list_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe FakerBot::Reflectors::List do +RSpec.describe Faker::CLI::Reflectors::List do describe '#call' do context 'when show methods is enabled' do it 'returns all descendants and their methods' do diff --git a/spec/fakerbot/reflectors/search_spec.rb b/spec/faker/cli/reflectors/search_spec.rb similarity index 93% rename from spec/fakerbot/reflectors/search_spec.rb rename to spec/faker/cli/reflectors/search_spec.rb index 1bb420c..f0201c8 100644 --- a/spec/fakerbot/reflectors/search_spec.rb +++ b/spec/faker/cli/reflectors/search_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe FakerBot::Reflectors::Search do +RSpec.describe Faker::CLI::Reflectors::Search do describe '#call' do context 'when a match is found' do it 'it returns the list of matches' do diff --git a/spec/fakerbot/renderer_spec.rb b/spec/faker/cli/renderer_spec.rb similarity index 98% rename from spec/fakerbot/renderer_spec.rb rename to spec/faker/cli/renderer_spec.rb index 3bc1f08..bc95058 100644 --- a/spec/fakerbot/renderer_spec.rb +++ b/spec/faker/cli/renderer_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' module MockFaker @@ -8,7 +10,7 @@ def self.bar end end -RSpec.describe FakerBot::Renderer do +RSpec.describe Faker::CLI::Renderer do describe '#call' do # FIXME: work out how to capture less xcontext 'when paginable interface' do diff --git a/spec/integration/list_spec.rb b/spec/integration/list_spec.rb index 92c63eb..594eb9d 100644 --- a/spec/integration/list_spec.rb +++ b/spec/integration/list_spec.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -RSpec.describe '`fakerbot list` command', type: :cli do - it 'executes `fakerbot help list` command successfully' do - output = `fakerbot help list` +RSpec.describe '`faker list` command', type: :cli do + it 'executes `faker help list` command successfully' do + output = `faker help list` expected_output = <<~OUT Usage: - fakerbot list + faker list Options: -h, [--help], [--no-help] # Display usage information @@ -19,13 +19,13 @@ expect(output).to match(expected_output) end - it 'executes `fakerbot list` command successfully' do - output = `fakerbot list` + it 'executes `faker list` command successfully' do + output = `faker list` expect(output).to match(/Faker::/) end - it 'executes `fakerbot list -v` command successfully' do - output = `fakerbot list -v` + it 'executes `faker list -v` command successfully' do + output = `faker list -v` expect(output).to match(/Faker::/) end end diff --git a/spec/integration/search_spec.rb b/spec/integration/search_spec.rb index bd75a3e..405ee60 100644 --- a/spec/integration/search_spec.rb +++ b/spec/integration/search_spec.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -RSpec.describe '`fakerbot search` command', type: :cli do - it 'executes `fakerbot help search` command successfully' do - output = `fakerbot help search` +RSpec.describe '`faker search` command', type: :cli do + it 'executes `faker help search` command successfully' do + output = `faker help search` expected_output = <<~OUT Usage: - fakerbot search [Faker] + faker search [Faker] Options: -h, [--help], [--no-help] # Display usage information @@ -20,7 +20,7 @@ context 'when search query exists' do it 'returns results' do - output = `fakerbot search name` + output = `faker search name` expect(output).to match(/Faker::/) expect(output).to match(/└──/) end @@ -28,7 +28,7 @@ context 'when search query does not exist' do it 'returns a not found message' do - output = `fakerbot search foobar` + output = `faker search foobar` expect(output).to match(/Sorry, we couldn't find a match/) end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index f1f5a21..1323e4b 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -5,7 +5,7 @@ require 'coveralls' require 'pry' -require 'fakerbot' +require 'faker-cli' Coveralls.wear!