Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Refacter rails env choosing implementation.

  • Loading branch information...
commit ae6e707a3bd2f8b9d733702979b117884d1f7f83 1 parent 5a8f25f
@kennyj authored
View
3  railties/lib/rails.rb
@@ -1,4 +1,5 @@
require 'rails/ruby_version_check'
+require 'rails/env_choice_helper'
require 'pathname'
@@ -86,7 +87,7 @@ def root
def env
@_env ||= begin
- ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development"
+ ENV["RAILS_ENV"] = Rails::EnvChoiceHelper.env
ActiveSupport::StringInquirer.new(ENV["RAILS_ENV"])
end
end
View
3  railties/lib/rails/commands/console.rb
@@ -1,6 +1,7 @@
require 'optparse'
require 'irb'
require 'irb/completion'
+require 'rails/env_choice_helper'
module Rails
class Console
@@ -45,7 +46,7 @@ def sandbox?
end
def environment
- options[:environment] ||= ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
+ options[:environment] ||= Rails::EnvChoiceHelper.env
end
def environment?
View
3  railties/lib/rails/commands/dbconsole.rb
@@ -2,6 +2,7 @@
require 'yaml'
require 'optparse'
require 'rbconfig'
+require 'rails/env_choice_helper'
module Rails
class DBConsole
@@ -96,7 +97,7 @@ def environment
if Rails.respond_to?(:env)
Rails.env
else
- ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development"
+ Rails::EnvChoiceHelper.env
end
end
View
3  railties/lib/rails/commands/runner.rb
@@ -1,7 +1,8 @@
require 'optparse'
require 'rbconfig'
+require 'rails/env_choice_helper'
-options = { environment: (ENV['RAILS_ENV'] || ENV['RACK_ENV'] || "development").dup }
+options = { environment: Rails::EnvChoiceHelper.env.dup }
code_or_file = nil
if ARGV.first.nil?
View
3  railties/lib/rails/commands/server.rb
@@ -1,6 +1,7 @@
require 'fileutils'
require 'optparse'
require 'action_dispatch'
+require 'rails/env_choice_helper'
module Rails
class Server < ::Rack::Server
@@ -108,7 +109,7 @@ def default_options
super.merge({
Port: 3000,
DoNotReverseLookup: true,
- environment: (ENV['RAILS_ENV'] || ENV['RACK_ENV'] || "development").dup,
+ environment: Rails::EnvChoiceHelper.env.dup,
daemonize: false,
debugger: false,
pid: File.expand_path("tmp/pids/server.pid"),
View
8 railties/lib/rails/env_choice_helper.rb
@@ -0,0 +1,8 @@
+module Rails
+ module EnvChoiceHelper
+ def self.env
+ ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development"
+ end
+ end
+end
+
Please sign in to comment.
Something went wrong with that request. Please try again.