Guest User

Untitled

a guest
Jun 21st, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. require "irb"
  2.  
  3. # FIXME: can this be done better?
  4. # travel up until we find config/boot
  5. old_path = File.expand_path(__FILE__)
  6. path = File.dirname(old_path)
  7. until File.exist?("#{path}/config/boot.rb") || old_path == path
  8. old_path = path
  9. path = File.dirname(old_path)
  10. end
  11. require "#{path}/config/boot.rb"
  12. # /FIXME
  13.  
  14.  
  15.  
  16. require "#{RAILS_ROOT}/config/environment"
  17. require "console_app"
  18. require "console_with_helpers"
  19.  
  20. ENV['RAILS_ENV'] = case ARGV.last
  21. when "p"; "production"
  22. when "d"; "development"
  23. when "t"; "test"
  24. when nil; ENV['RAILS_ENV'] || 'development'
  25. else
  26. ARGV.pop
  27. end
  28.  
  29. IRB.setup(nil)
  30. irb = IRB::Irb.new()
  31.  
  32. IRB.conf[:IRB_RC].call(irb.context) if IRB.conf[:IRB_RC] # loads the irbrc?
  33. IRB.conf[:MAIN_CONTEXT] = irb.context # why would the main context be set here?
  34.  
  35. trap("SIGINT") do
  36. irb.signal_handle
  37. end
  38.  
  39. catch(:IRB_EXIT) do
  40. irb.eval_input
  41. end
Add Comment
Please, Sign In to add comment