diff options
author | José Valim <jose.valim@gmail.com> | 2009-07-04 17:09:09 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2009-07-04 20:17:32 +0200 |
commit | 8ff214e0db31a6827b52f738c409d97d70b363d5 (patch) | |
tree | 318f6ef97f9fbc9265a9c96a2df640da492ad1cc /railties/lib/generators/base.rb | |
parent | da09d46ed463459eb651f6c1e6af923e283da6e6 (diff) | |
download | rails-8ff214e0db31a6827b52f738c409d97d70b363d5.tar.gz rails-8ff214e0db31a6827b52f738c409d97d70b363d5.tar.bz2 rails-8ff214e0db31a6827b52f738c409d97d70b363d5.zip |
Use the proper shebang when using Ruby 1.9 or jruby or windows.
Diffstat (limited to 'railties/lib/generators/base.rb')
-rw-r--r-- | railties/lib/generators/base.rb | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/railties/lib/generators/base.rb b/railties/lib/generators/base.rb index 5d6821efe0..0d2d165741 100644 --- a/railties/lib/generators/base.rb +++ b/railties/lib/generators/base.rb @@ -335,18 +335,21 @@ module Rails # default value plus an instance helper method called shebang. # def self.add_shebang_option! - require 'rbconfig' - default = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']) - - class_option :ruby, :type => :string, :aliases => "-r", :default => default, + class_option :ruby, :type => :string, :aliases => "-r", :default => Thor::Util.ruby_command, :desc => "Path to the Ruby binary of your choice", :banner => "PATH" - class_eval <<-METHOD, __FILE__, __LINE__ - protected - def shebang - "#!\#{options[:ruby] || "/usr/bin/env ruby"}" + no_tasks { + define_method :shebang do + @shebang ||= begin + command = if options[:ruby] == Thor::Util.ruby_command + "/usr/bin/env #{File.basename(Thor::Util.ruby_command)}" + else + options[:ruby] + end + "#!#{command}" + end end - METHOD + } end end |