Sha256: 0fbeb8bb5b19ccfa3041c81fed60ad3ba73e1e43d48ffafebb48e394e458c927

Contents?: true

Size: 816 Bytes

Versions: 2

Compression:

Stored size: 816 Bytes

Contents

# frozen_string_literal: true

include SaferRailsConsole::Colors

app_name = if SaferRailsConsole::RailsVersion.six_or_above?
             ::Rails.application.class.module_parent.to_s.underscore.dasherize
           else
             ::Rails.application.class.parent.to_s.underscore.dasherize
           end
env_name = SaferRailsConsole.environment_name
status = ::Rails.application.sandbox ? 'read-only' : 'writable'
color = SaferRailsConsole.prompt_color

prompt = "#{app_name}(#{env_name})(#{status}):%03n:%i"

IRB.conf[:PROMPT][:RAILS_ENV] = {
  PROMPT_I: color_text("#{prompt}> ", color),
  PROMPT_N: color_text("#{prompt}> ", color),
  PROMPT_S: color_text("#{prompt}%l ", color),
  PROMPT_C: color_text("#{prompt}* ", color),
  RETURN: "#{color_text('=> ', color)}%s\n"
}

IRB.conf[:PROMPT_MODE] = :RAILS_ENV

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
safer_rails_console-0.5.1 lib/safer_rails_console/consoles/irb.rb
safer_rails_console-0.5.0 lib/safer_rails_console/consoles/irb.rb