Class: Rack::Console

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/console.rb,
lib/rack/console/version.rb

Defined Under Namespace

Classes: Version

Constant Summary collapse

VERSION =
Version.to_s

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Console

Returns a new instance of Console.



7
8
9
# File 'lib/rack/console.rb', line 7

def initialize(options = {})
  @options = { config: 'config.ru' }.merge(options)
end

Instance Method Details

#startObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/rack/console.rb', line 11

def start
  ENV['RACK_ENV'] = @options[:environment] || 'development'

  if includes = @options[:include]
    $LOAD_PATH.unshift(*includes)
  end

  if library = @options[:require]
    require library
  end

  Rack::Builder.parse_file(@options[:config])

  Object.class_eval do
    def reload!
      puts 'Reloading...'
      exec $0
    end
  end

  begin
    require 'pry'
    Pry.start
  rescue LoadError
    require 'irb'
    IRB.start
  end
end