diff options
Diffstat (limited to 'railties/lib/generator/base.rb')
-rw-r--r-- | railties/lib/generator/base.rb | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/railties/lib/generator/base.rb b/railties/lib/generator/base.rb index db63940a37..5954dc1afd 100644 --- a/railties/lib/generator/base.rb +++ b/railties/lib/generator/base.rb @@ -7,7 +7,6 @@ require 'thor' module Rails module Generators - class Error < Thor::Error end @@ -26,7 +25,25 @@ module Rails File.expand_path(File.join(File.dirname(__FILE__), 'templates', klass_name.downcase)) end end - end + # Small macro to ruby as an option to the generator with proper default + # value plus an instance helper method. + # + 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, + :desc => "Path to the Ruby binary of your choice" + + class_eval do + protected + def shebang + "#!#{options[:ruby] || "/usr/bin/env ruby"}" + end + end + end + + end end end |