diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-05-10 01:04:56 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-05-10 01:04:56 -0300 |
commit | 7fb45a6130598703b3da8fe9ef29a5c7a1eb9d09 (patch) | |
tree | b2572823e920eca67251585ac72107d57cb15401 /railties/lib/rails/commands/console.rb | |
parent | 986fdc4e7328dd639099899f149a8d140d230a9e (diff) | |
parent | 117bb5412529dc993dba86a18656f737b23ab152 (diff) | |
download | rails-7fb45a6130598703b3da8fe9ef29a5c7a1eb9d09.tar.gz rails-7fb45a6130598703b3da8fe9ef29a5c7a1eb9d09.tar.bz2 rails-7fb45a6130598703b3da8fe9ef29a5c7a1eb9d09.zip |
Merge pull request #20094 from vngrs/refactor_railties_commands
Refactor railties console and dbconsole commands
Diffstat (limited to 'railties/lib/rails/commands/console.rb')
-rw-r--r-- | railties/lib/rails/commands/console.rb | 31 |
1 files changed, 6 insertions, 25 deletions
diff --git a/railties/lib/rails/commands/console.rb b/railties/lib/rails/commands/console.rb index 5d37a2b699..ea5d20ea24 100644 --- a/railties/lib/rails/commands/console.rb +++ b/railties/lib/rails/commands/console.rb @@ -1,14 +1,13 @@ require 'optparse' require 'irb' require 'irb/completion' +require 'rails/commands/console_helper' module Rails class Console - class << self - def start(*args) - new(*args).start - end + include ConsoleHelper + class << self def parse_arguments(arguments) options = {} @@ -21,23 +20,8 @@ module Rails opt.parse!(arguments) end - 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 + set_options_env(arguments, options) end - - private - - def available_environments - Dir['config/environments/*.rb'].map { |fname| File.basename(fname, '.*') } - end end attr_reader :options, :app, :console @@ -57,12 +41,9 @@ module Rails end def environment - options[:environment] ||= ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development' - end - - def environment? - environment + options[:environment] ||= super end + alias_method :environment?, :environment def set_environment! Rails.env = environment |