From 72de2f1a72d830dd8cf1b0602f4d54e59d4cbfbf Mon Sep 17 00:00:00 2001 From: Austin Kabiru Date: Sun, 14 Jul 2019 07:03:17 +0300 Subject: [PATCH] fix: Disable default Faker deprecation warnings * The Bot renderer will mark methods pending deprecation --- lib/faker/bot.rb | 64 ++++++++++++++++++-------------------- lib/faker/bot/reflector.rb | 3 ++ 2 files changed, 34 insertions(+), 33 deletions(-) diff --git a/lib/faker/bot.rb b/lib/faker/bot.rb index 015b876..0e91071 100644 --- a/lib/faker/bot.rb +++ b/lib/faker/bot.rb @@ -10,42 +10,40 @@ module Faker module Bot class Base < Thor Error = Class.new(StandardError) - # Skip default deprecation warning output; the Bot will display that. - Gem::Deprecate.skip_during do - desc 'version', 'Faker version' - def version - puts "v#{Faker::Bot::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::Bot::Commands::List.new(options).execute - end + desc 'version', 'Faker version' + def version + puts "v#{Faker::Bot::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::Bot::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::Bot::Commands::Search.new(options).execute(query) - 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::Bot::Commands::Search.new(options).execute(query) end end end diff --git a/lib/faker/bot/reflector.rb b/lib/faker/bot/reflector.rb index 442d282..e526380 100644 --- a/lib/faker/bot/reflector.rb +++ b/lib/faker/bot/reflector.rb @@ -11,6 +11,9 @@ module Bot # class Reflector Faker::Base.class_eval do + # Skip default deprecation warning output; the CLI will display that. + Gem::Deprecate.skip = true + # Select `Faker` subclasses # @return [Array] `Faker::Base` sub classes def self.descendants