Module: SaferRailsConsole
- Defined in:
- lib/safer_rails_console.rb,
lib/safer_rails_console/colors.rb,
lib/safer_rails_console/console.rb,
lib/safer_rails_console/railtie.rb,
lib/safer_rails_console/version.rb,
lib/safer_rails_console/rails_version.rb,
lib/safer_rails_console/patches/railtie/sandbox.rb,
lib/safer_rails_console/patches/boot/sandbox_flag.rb,
lib/safer_rails_console/patches/sandbox/auto_rollback.rb,
lib/safer_rails_console/patches/sandbox/transaction_read_only.rb
Defined Under Namespace
Modules: Colors, Console, Patches, RailsVersion
Classes: Configuration, Railtie
Constant Summary
collapse
- VERSION =
'0.5.0'
Class Method Summary
collapse
Class Method Details
.config ⇒ Object
52
53
54
|
# File 'lib/safer_rails_console.rb', line 52
def config
@config ||= Configuration.new
end
|
.environment_name ⇒ Object
12
13
14
15
16
17
18
|
# File 'lib/safer_rails_console.rb', line 12
def environment_name
if ENV.key?('SAFER_RAILS_CONSOLE_ENVIRONMENT_NAME')
ENV['SAFER_RAILS_CONSOLE_ENVIRONMENT_NAME']
else
config.environment_names.key?(::Rails.env.downcase) ? config.environment_names[::Rails.env.downcase] : 'unknown env'
end
end
|
.prompt_color ⇒ Object
20
21
22
23
24
25
26
|
# File 'lib/safer_rails_console.rb', line 20
def prompt_color
if ENV.key?('SAFER_RAILS_CONSOLE_PROMPT_COLOR')
SaferRailsConsole::Colors.const_get(ENV['SAFER_RAILS_CONSOLE_PROMPT_COLOR'].upcase)
else
config.environment_prompt_colors.key?(::Rails.env.downcase) ? config.environment_prompt_colors[::Rails.env.downcase] : SaferRailsConsole::Colors::NONE
end
end
|
.sandbox_environment? ⇒ Boolean
28
29
30
31
32
33
34
|
# File 'lib/safer_rails_console.rb', line 28
def sandbox_environment?
if ENV.key?('SAFER_RAILS_CONSOLE_SANDBOX_ENVIRONMENT')
ActiveModel::Type::Boolean.new.cast(ENV['SAFER_RAILS_CONSOLE_SANDBOX_ENVIRONMENT'])
else
config.sandbox_environments.include?(::Rails.env.downcase)
end
end
|
.warn_environment? ⇒ Boolean
36
37
38
39
40
41
42
|
# File 'lib/safer_rails_console.rb', line 36
def warn_environment?
if ENV.key?('SAFER_RAILS_CONSOLE_WARN_ENVIRONMENT')
ActiveModel::Type::Boolean.new.cast(ENV['SAFER_RAILS_CONSOLE_WARN_ENVIRONMENT'])
else
config.warn_environments.include?(::Rails.env.downcase)
end
end
|
.warn_text ⇒ Object
44
45
46
47
48
49
50
|
# File 'lib/safer_rails_console.rb', line 44
def warn_text
if ENV.key?('SAFER_RAILS_CONSOLE_WARN_TEXT')
ENV['SAFER_RAILS_CONSOLE_WARN_TEXT']
else
config.warn_text
end
end
|