Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Expand paths to app builders relative to the working directory

  • Loading branch information...
commit 6d7f2790cdb6cb23285067ed2bd91fd5122adbbc 1 parent 5be4988
Carl Lerche authored
5 railties/lib/rails/generators/rails/app/app_generator.rb
View
@@ -200,6 +200,9 @@ class AppGenerator < Base
def initialize(*args)
raise Error, "Options should be given after the application name. For details run: rails --help" if args[0].blank?
+
+ @original_wd = Dir.pwd
+
super
if !options[:skip_activerecord] && !DATABASES.include?(options[:database])
@@ -316,7 +319,7 @@ def builder
if URI(path).is_a?(URI::HTTP)
contents = open(path, "Accept" => "application/x-thor-template") {|io| io.read }
else
- contents = open(path) {|io| io.read }
+ contents = open(File.expand_path(path, @original_wd)) {|io| io.read }
end
prok = eval("proc { #{contents} }", TOPLEVEL_BINDING, path, 1)
8 railties/test/generators/app_generator_test.rb
View
@@ -238,6 +238,14 @@ def test_builder_option_with_simple_app_builder
assert_file "config.ru", %[run proc { |env| [200, { "Content-Type" => "text/html" }, ["Hello World"]] }]
end
+ def test_builder_option_with_relative_path
+ here = File.expand_path(File.dirname(__FILE__))
+ FileUtils.cd(here)
+ run_generator([destination_root, "-b", "../fixtures/lib/simple_builder.rb"])
+ (DEFAULT_APP_FILES - ['config.ru']).each{ |path| assert_no_file path }
+ assert_file "config.ru", %[run proc { |env| [200, { "Content-Type" => "text/html" }, ["Hello World"]] }]
+ end
+
def test_builder_option_with_tweak_app_builder
FileUtils.cd(Rails.root)
run_generator([destination_root, "-b", "#{Rails.root}/lib/tweak_builder.rb"])
Please sign in to comment.
Something went wrong with that request. Please try again.