Class: Rack::Console
- Inherits:
-
Object
- Object
- Rack::Console
- Defined in:
- lib/rack/console.rb,
lib/rack/console/methods.rb,
lib/rack/console/session.rb,
lib/rack/console/version.rb
Defined Under Namespace
Modules: Methods Classes: Session, Version
Constant Summary collapse
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Console
constructor
A new instance of Console.
- #start ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Console
Returns a new instance of Console.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/rack/console.rb', line 12 def initialize( = {}) @options = { config: 'config.ru' }.merge() ENV['RACK_ENV'] = @options[:environment] || 'development' ENV['RACK_CONSOLE_PREAMBLE'] ||= "Loading #{ENV['RACK_ENV']} environment (Rack::Console #{Rack::Console::VERSION})" if includes = @options[:include] $LOAD_PATH.unshift(*includes) end if library = @options[:require] require library end end |
Class Method Details
.start(options = {}) ⇒ Object
8 9 10 |
# File 'lib/rack/console.rb', line 8 def self.start( = {}) self.new().start end |
Instance Method Details
#start ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rack/console.rb', line 27 def start if ENV['RACK_CONSOLE_PREAMBLE'] && !ENV['RACK_CONSOLE_PREAMBLE'].empty? puts ENV['RACK_CONSOLE_PREAMBLE'] end app = Rack::Builder.parse_file(@options[:config]).first # Add convenience methods to the top-level binding (main) main.extend(Rack::Console::Methods) main.instance_variable_set(:@app, Rack::Console::Session.new(app)) begin require 'pry' Pry.start rescue LoadError require 'irb' IRB.start end end |