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_helper.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_helper.rb')
-rw-r--r-- | railties/lib/rails/commands/console_helper.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/railties/lib/rails/commands/console_helper.rb b/railties/lib/rails/commands/console_helper.rb new file mode 100644 index 0000000000..8ee0b60012 --- /dev/null +++ b/railties/lib/rails/commands/console_helper.rb @@ -0,0 +1,34 @@ +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
\ No newline at end of file |