Sha256: 6e97d3e1e3a7c003b2b8ed01fce1f3fd2dde95be8fac04014b74b74d0e8b0a68

Contents?: true

Size: 1.52 KB

Versions: 4

Compression:

Stored size: 1.52 KB

Contents

require 'icepick/version'
require 'icepick/config'
require 'icepick/prompt'

require 'pry'
require 'pry-doc'
require 'pry-stack_explorer'
require 'pry-byebug'
require 'awesome_print'
require 'readline'

module Icepick

  # AwesomePrint configuration options
  AWESOME_OPTS = {
    indent:     2,
    sort_keys:  true
  }

  # Public: Prohibit the instantiation of Icepick
  #
  # Raises NotImplementedError
  def initialize
    raise NotImplementedError
  end

  # Public: Setup and initialize Icepick
  #
  # options - Options to use in setup (defaults: {})
  #   * name: A name to use for the prompt
  #
  # Returns nothing
  def self.initialize!(name = nil)
    silence_warnings do
      # Use awesome_print for Pry output
      Pry.config.print = ->(output, value) do
        pretty = value.ai(AWESOME_OPTS)
        Pry::Helpers::BaseHelpers.stagger_output("=> #{pretty}", output)
      end

      # Use Icepick's Prompt for Pry
      Pry.config.prompt = Prompt.pry_prompts

      # Debug aliases
      Pry.commands.alias_command 'c', 'continue'
      Pry.commands.alias_command 's', 'step'
      Pry.commands.alias_command 'n', 'next'
      Pry.commands.alias_command 'f', 'finish'
      Pry.commands.alias_command 'e', 'exit'
      Pry.commands.alias_command 'q', 'quit'
      Pry.commands.alias_command '..', 'cd'
    end
  end

  private

  # Internal: Suppress warnings and errors
  #
  # Returns nothing
  def self.silence_warnings
    old_verbose, $VERBOSE = $VERBOSE, nil
    yield
  ensure
    $VERBOSE = old_verbose
  end
end

Icepick.initialize!

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
icepick-1.3.1 lib/icepick.rb
icepick-1.3.0 lib/icepick.rb
icepick-1.1.1 lib/icepick.rb
icepick-1.1.0 lib/icepick.rb