Sha256: ff7c56abe9580d5a5676ac28b2a701e1e07ed6d6b6e8cf9a020eea8e53383683

Contents?: true

Size: 750 Bytes

Versions: 2

Compression:

Stored size: 750 Bytes

Contents

# frozen_string_literal: true

require_relative "../base"
require_relative "../setup/store"
require "colorize"

class ExceptionsBase < Base
  include Setup::Store

  def call
    logger.error(exception.to_s.colorize(color: :light_red, mode: :bold))
    logger.info("Running: #{corrected_cmd}".colorize(color: :green, mode: :bold))

    pry.eval(corrected_cmd)
  end

  private

  attr_reader :exception, :output, :pry

  def initialize(output, exception, pry)
    @output = output
    @exception = exception
    @pry = pry
  end

  def spell_checker(dictionary)
    DidYouMean::SpellChecker.new(dictionary: dictionary)
  end

  def logger
    @logger = Logger.new($stdout)
  end

  def last_cmd
    @last_cmd ||= Pry.line_buffer.last.strip
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pry-byetypo-1.0.2 lib/pry-byetypo/exceptions/exceptions_base.rb
pry-byetypo-1.0.0 lib/pry-byetypo/exceptions/exceptions_base.rb