Class: Rails::Console::IRBConsole
- Defined in:
- railties/lib/rails/commands/console/irb_console.rb
Instance Method Summary collapse
- #colorized_env ⇒ Object
-
#initialize(app) ⇒ IRBConsole
constructor
A new instance of IRBConsole.
- #name ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(app) ⇒ IRBConsole
Returns a new instance of IRBConsole.
72 73 74 75 76 77 |
# File 'railties/lib/rails/commands/console/irb_console.rb', line 72 def initialize(app) @app = app require "irb" require "irb/completion" end |
Instance Method Details
#colorized_env ⇒ Object
118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'railties/lib/rails/commands/console/irb_console.rb', line 118 def colorized_env case Rails.env when "development" IRB::Color.colorize("dev", [:BLUE]) when "test" IRB::Color.colorize("test", [:BLUE]) when "production" IRB::Color.colorize("prod", [:RED]) else IRB::Color.colorize(Rails.env, [:MAGENTA]) end end |
#name ⇒ Object
79 80 81 |
# File 'railties/lib/rails/commands/console/irb_console.rb', line 79 def name "IRB" end |
#start ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'railties/lib/rails/commands/console/irb_console.rb', line 83 def start IRB.setup(nil) if !Rails.env.local? && !ENV.key?("IRB_USE_AUTOCOMPLETE") IRB.conf[:USE_AUTOCOMPLETE] = false end env = colorized_env prompt_prefix = "%N(#{env})" # Respect user's configured irb name. IRB.conf[:IRB_NAME] = @app.name if IRB.conf[:IRB_NAME] == "irb" IRB.conf[:PROMPT][:RAILS_PROMPT] = { PROMPT_I: "#{prompt_prefix}:%03n> ", PROMPT_S: "#{prompt_prefix}:%03n%l ", PROMPT_C: "#{prompt_prefix}:%03n* ", RETURN: "=> %s\n" } if current_filter = IRB.conf[:BACKTRACE_FILTER] IRB.conf[:BACKTRACE_FILTER] = -> (backtrace) do backtrace = current_filter.call(backtrace) Rails.backtrace_cleaner.filter(backtrace) end else IRB.conf[:BACKTRACE_FILTER] = -> (backtrace) do Rails.backtrace_cleaner.filter(backtrace) end end # Respect user's choice of prompt mode. IRB.conf[:PROMPT_MODE] = :RAILS_PROMPT if IRB.conf[:PROMPT_MODE] == :DEFAULT IRB::Irb.new.run(IRB.conf) end |