1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/railties/lib/rails/commands/console_helper.rb
Mehmet Emin İNAÇ 117bb54125 Refactor railties console and dbconsole commands
fix minor convention problems
2015-05-10 06:30:26 +03:00

34 lines
No EOL
875 B
Ruby

require 'active_support/concern'
module Rails
module ConsoleHelper # :nodoc:
extend ActiveSupport::Concern
module ClassMethods
def start(*args)
new(*args).start
end
private
def set_options_env(arguments, options)
if arguments.first && arguments.first[0] != '-'
env = arguments.first
if available_environments.include? env
options[:environment] = env
else
options[:environment] = %w(production development test).detect { |e| e =~ /^#{env}/ } || env
end
end
options
end
def available_environments
Dir['config/environments/*.rb'].map { |fname| File.basename(fname, '.*') }
end
end
def environment
ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development"
end
end
end