class Stealth::Commands::Console

REPL that supports different engines.

It is run with:

`bundle exec stealth console`

Constants

DEFAULT_ENGINE
ENGINES

Supported engines

Attributes

options[R]

Public Class Methods

new(options) click to toggle source
Calls superclass method Stealth::Commands::Command::new
# File lib/stealth/commands/console.rb, line 32
def initialize(options)
  super(options)

  @options = options
end

Public Instance Methods

engine() click to toggle source
# File lib/stealth/commands/console.rb, line 43
def engine
  load_engine options.fetch(:engine) { engine_lookup }
end
start() click to toggle source
# File lib/stealth/commands/console.rb, line 38
def start
  prepare
  engine.start
end

Private Instance Methods

engine_lookup() click to toggle source
# File lib/stealth/commands/console.rb, line 59
def engine_lookup
  (ENGINES.find { |_, klass| Object.const_defined?(klass) } || DEFAULT_ENGINE).first
end
load_engine(engine) click to toggle source
# File lib/stealth/commands/console.rb, line 63
def load_engine(engine)
  require engine
rescue LoadError
ensure
  return Object.const_get(
    ENGINES.fetch(engine) do
      raise ArgumentError.new("Unknown console engine: `#{engine}'")
    end
  )
end
prepare() click to toggle source
# File lib/stealth/commands/console.rb, line 49
def prepare
  # Clear out ARGV so Pry/IRB don't attempt to parse the rest
  ARGV.shift until ARGV.empty?

  # Add convenience methods to the main:Object binding
  TOPLEVEL_BINDING.eval('self').__send__(:include, CodeReloading)

  Stealth.load_environment
end