diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-10-30 16:18:12 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-10-30 16:18:12 -0700 |
commit | 82f59a98035c8e9e4151ff0272f1a81fe9ec288c (patch) | |
tree | b1480e2c6d1bae418f7e424effc14ca11d9b8871 /railties | |
parent | a27d2d74f25110e4ebd8d44dc7fd1f44c103ca9e (diff) | |
download | rails-82f59a98035c8e9e4151ff0272f1a81fe9ec288c.tar.gz rails-82f59a98035c8e9e4151ff0272f1a81fe9ec288c.tar.bz2 rails-82f59a98035c8e9e4151ff0272f1a81fe9ec288c.zip |
pass argv to each method that mutates it
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/generators/rails/app/app_generator.rb | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb index f2384410ed..0377bfb4a3 100644 --- a/railties/lib/rails/generators/rails/app/app_generator.rb +++ b/railties/lib/rails/generators/rails/app/app_generator.rb @@ -312,19 +312,17 @@ module Rails # This class should be called before the AppGenerator is required and started # since it configures and mutates ARGV correctly. class ARGVScrubber # :nodoc - attr_reader :argv - def initialize(argv = ARGV) @argv = argv.dup end def prepare! - handle_version_request!(argv.first) - unless handle_invalid_command!(argv.first) - argv.shift - handle_rails_rc! + handle_version_request!(@argv.first) + unless handle_invalid_command!(@argv.first, @argv) + @argv.shift + handle_rails_rc!(@argv) end - argv + @argv end def self.default_rc_file @@ -341,19 +339,19 @@ module Rails end end - def handle_invalid_command!(argument) + def handle_invalid_command!(argument, argv) if argument != "new" argv[0] = "--help" end end - def handle_rails_rc! + def handle_rails_rc!(argv) unless argv.delete("--no-rc") - insert_railsrc_into_argv!(railsrc) + insert_railsrc_into_argv!(argv, railsrc(argv)) end end - def railsrc + def railsrc(argv) if (customrc = argv.index{ |x| x.include?("--rc=") }) File.expand_path(argv.delete_at(customrc).gsub(/--rc=/, "")) else @@ -361,7 +359,7 @@ module Rails end end - def insert_railsrc_into_argv!(railsrc) + def insert_railsrc_into_argv!(argv, railsrc) if File.exist?(railsrc) extra_args_string = File.read(railsrc) extra_args = extra_args_string.split(/\n+/).map {|l| l.split}.flatten |