module PrySingular

Constants

Options
VERSION

Public Class Methods

make_commands(*klasses, **options) click to toggle source
# File lib/pry-singular.rb, line 8
def make_commands(*klasses, **options)
  options = Options.new(options)
  klasses.each do |klass|
    create_singular_method_commands(klass, options)
  end
end

Private Class Methods

create_singular_method_commands(klass, options) click to toggle source
# File lib/pry-singular.rb, line 17
def create_singular_method_commands(klass, options)
  filtered_singular_methods = filter_methods_by_option(klass.singleton_methods, options)

  filtered_singular_methods.each do |singular_method|
    singular_method_command(singular_method, klass)
  end
end
filter_methods_by_option(methods, options) click to toggle source
# File lib/pry-singular.rb, line 25
def filter_methods_by_option(methods, options)
  if options.only.any?
    options.remove_methods_other_than_only(methods)
  else
    options.remove_except_methods(methods)
  end
end
import_pry_command(&block) click to toggle source
# File lib/pry-singular.rb, line 45
def import_pry_command(&block)
  commands = Pry::CommandSet.new(&block)
  Pry.config.commands.import(commands)
end
singular_method_command(singular_method, klass) click to toggle source
# File lib/pry-singular.rb, line 33
    def singular_method_command(singular_method, klass)
      import_pry_command do
        command singular_method.to_s, "#{klass}.#{singular_method}" do
          last_cui_command = Readline::HISTORY.to_a.last

          klass.class_eval <<~EOS, __FILE__, __LINE__ + 1
            #{PrySingular::Slop.parse_singular_method_command(last_cui_command)}
          EOS
        end
      end
    end