Class: Lotus::Commands::Console

Inherits:
Object
  • Object
show all
Defined in:
lib/lotus/commands/console.rb

Overview

Since:

  • 0.1.0

Defined Under Namespace

Modules: Methods

Constant Summary collapse

ENGINES =

Since:

  • 0.1.0

{
  'pry'  => 'Pry',
  'ripl' => 'Ripl',
  'irb'  => 'IRB'
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(environment) ⇒ Console

Returns a new instance of Console.

Since:

  • 0.1.0



19
20
21
22
# File 'lib/lotus/commands/console.rb', line 19

def initialize(environment)
  @environment = environment
  @options     = environment.to_options
end

Instance Attribute Details

#optionsObject (readonly)

Since:

  • 0.1.0



17
18
19
# File 'lib/lotus/commands/console.rb', line 17

def options
  @options
end

Instance Method Details

#engineObject

Since:

  • 0.1.0



36
37
38
# File 'lib/lotus/commands/console.rb', line 36

def engine
  load_engine options.fetch(:engine) { engine_lookup }
end

#startObject

Since:

  • 0.1.0



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/lotus/commands/console.rb', line 24

def start
  # Clear out ARGV so Pry/IRB don't attempt to parse the rest
  ARGV.shift until ARGV.empty?
  require @environment.env_config.to_s

  # Add convenience methods to the main:Object binding
  TOPLEVEL_BINDING.eval('self').send(:include, Methods)
  Lotus::Application.preload_applications!

  engine.start
end