Methods
Included Modules
Class Public methods
new(app)
📝 Source code
# File railties/lib/rails/commands/console/irb_console.rb, line 73
def initialize(app)
@app = app
require "irb"
require "irb/completion"
end
🔎 See on GitHub
Instance Public methods
colorized_env()
📝 Source code
# File railties/lib/rails/commands/console/irb_console.rb, line 123
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
Rails.env
end
end
🔎 See on GitHub
name()
📝 Source code
# File railties/lib/rails/commands/console/irb_console.rb, line 80
def name
"IRB"
end
🔎 See on GitHub
start()
📝 Source code
# File railties/lib/rails/commands/console/irb_console.rb, line 84
def start
IRB.setup(nil)
if !Rails.env.local? && !ENV.key?("IRB_USE_AUTOCOMPLETE")
IRB.conf[:USE_AUTOCOMPLETE] = false
end
env = colorized_env
app_name = @app.class.module_parent_name.underscore.dasherize
prompt_prefix = "%N(#{env})"
IRB.conf[:IRB_NAME] = app_name
IRB.conf[:PROMPT][:RAILS_PROMPT] = {
PROMPT_I: "#{prompt_prefix}> ",
PROMPT_S: "#{prompt_prefix}%l ",
PROMPT_C: "#{prompt_prefix}* ",
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
# Because some users/libs use Rails::ConsoleMethods to extend Rails console,
# we still include it for backward compatibility.
IRB::ExtendCommandBundle.include ConsoleMethods
# 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
🔎 See on GitHub