Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove --builder option from rails command #9401

Merged
merged 1 commit into from Feb 24, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions railties/CHANGELOG.md
@@ -1,4 +1,11 @@
## Rails 4.0.0 (unreleased) ##

* Ability to use a custom builder by passing `--builder` (or `-b`) has been removed. Consider
using application template instead. See this guide for more detail:
http://guides.rubyonrails.org/rails_application_templates.html

*Prem Sichanugrist*

* fix rake db:* tasks to work with DATABASE_URL and without config/database.yml

*Terence Lee*
Expand Down
14 changes: 0 additions & 14 deletions railties/lib/rails/generators/app_base.rb
Expand Up @@ -19,9 +19,6 @@ class AppBase < Base # :nodoc:
argument :app_path, type: :string

def self.add_shared_options_for(name)
class_option :builder, type: :string, aliases: '-b',
desc: "Path to some #{name} builder (can be a filesystem path or URL)"

class_option :template, type: :string, aliases: '-m',
desc: "Path to some #{name} template (can be a filesystem path or URL)"

Expand Down Expand Up @@ -81,17 +78,6 @@ def initialize(*args)

def builder
@builder ||= begin
if path = options[:builder]
if URI(path).is_a?(URI::HTTP)
contents = open(path, "Accept" => "application/x-thor-template") {|io| io.read }
else
contents = open(File.expand_path(path, @original_wd)) {|io| io.read }
end

prok = eval("proc { #{contents} }", TOPLEVEL_BINDING, path, 1)
instance_eval(&prok)
end

builder_class = get_builder_class
builder_class.send(:include, ActionMethods)
builder_class.new(self)
Expand Down
2 changes: 0 additions & 2 deletions railties/test/fixtures/lib/app_builders/empty_builder.rb

This file was deleted.

7 changes: 0 additions & 7 deletions railties/test/fixtures/lib/app_builders/simple_builder.rb

This file was deleted.

7 changes: 0 additions & 7 deletions railties/test/fixtures/lib/app_builders/tweak_builder.rb

This file was deleted.

2 changes: 0 additions & 2 deletions railties/test/fixtures/lib/plugin_builders/empty_builder.rb

This file was deleted.

7 changes: 0 additions & 7 deletions railties/test/fixtures/lib/plugin_builders/simple_builder.rb

This file was deleted.

19 changes: 0 additions & 19 deletions railties/test/fixtures/lib/plugin_builders/spec_builder.rb

This file was deleted.

7 changes: 0 additions & 7 deletions railties/test/fixtures/lib/plugin_builders/tweak_builder.rb

This file was deleted.

25 changes: 0 additions & 25 deletions railties/test/generators/app_generator_test.rb
Expand Up @@ -366,28 +366,3 @@ def assert_gem(gem)
assert_file "Gemfile", /^gem\s+["']#{gem}["']$/
end
end

class CustomAppGeneratorTest < Rails::Generators::TestCase
include GeneratorsTestHelper
tests Rails::Generators::AppGenerator

arguments [destination_root]
include SharedCustomGeneratorTests

protected
def default_files
::DEFAULT_APP_FILES
end

def builders_dir
"app_builders"
end

def builder_class
:AppBuilder
end

def action(*args, &block)
silence(:stdout) { generator.send(*args, &block) }
end
end
35 changes: 0 additions & 35 deletions railties/test/generators/plugin_new_generator_test.rb
Expand Up @@ -371,38 +371,3 @@ def default_files
::DEFAULT_PLUGIN_FILES
end
end

class CustomPluginGeneratorTest < Rails::Generators::TestCase
include GeneratorsTestHelper
tests Rails::Generators::PluginNewGenerator

destination File.join(Rails.root, "tmp/bukkits")
arguments [destination_root]
include SharedCustomGeneratorTests

def test_overriding_test_framework
FileUtils.cd(destination_root)
run_generator([destination_root, "-b", "#{Rails.root}/lib/plugin_builders/spec_builder.rb"])
assert_file 'spec/spec_helper.rb'
assert_file 'spec/dummy'
assert_file 'Rakefile', /task default: :spec/
assert_file 'Rakefile', /# spec tasks in rakefile/
end

protected
def default_files
::DEFAULT_PLUGIN_FILES
end

def builder_class
:PluginBuilder
end

def builders_dir
"plugin_builders"
end

def action(*args, &block)
silence(:stdout){ generator.send(*args, &block) }
end
end
58 changes: 0 additions & 58 deletions railties/test/generators/shared_generator_tests.rb
Expand Up @@ -140,61 +140,3 @@ def test_skip_keeps
assert_no_file('app/mailers/.keep')
end
end

module SharedCustomGeneratorTests
def setup
Rails.application = TestApp::Application
super
Rails::Generators::AppGenerator.instance_variable_set('@desc', nil)
end

def teardown
super
Rails::Generators::AppGenerator.instance_variable_set('@desc', nil)
Object.class_eval do
remove_const :AppBuilder if const_defined?(:AppBuilder)
remove_const :PluginBuilder if const_defined?(:PluginBuilder)
end
Rails.application = TestApp::Application.instance
end

def test_builder_option_with_empty_app_builder
FileUtils.cd(destination_root)
run_generator([destination_root, "-b", "#{Rails.root}/lib/#{builders_dir}/empty_builder.rb"])
default_files.each{ |path| assert_no_file path }
end

def test_builder_option_with_simple_plugin_builder
FileUtils.cd(destination_root)
run_generator([destination_root, "-b", "#{Rails.root}/lib/#{builders_dir}/simple_builder.rb"])
(default_files - ['.gitignore']).each{ |path| assert_no_file path }
assert_file ".gitignore", "foobar"
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/#{builders_dir}/simple_builder.rb"])
FileUtils.cd(destination_root)
(default_files - ['.gitignore']).each{ |path| assert_no_file path }
assert_file ".gitignore", "foobar"
end

def test_builder_option_with_tweak_plugin_builder
FileUtils.cd(destination_root)
run_generator([destination_root, "-b", "#{Rails.root}/lib/#{builders_dir}/tweak_builder.rb"])
default_files.each{ |path| assert_file path }
assert_file ".gitignore", "foobar"
end

def test_builder_option_with_http
url = "https://gist.github.com/josevalim/103208/raw/"
template = "class #{builder_class}; end"
template.instance_eval "def read; self; end" # Make the string respond to read

generator([destination_root], builder: url).expects(:open).with(url, 'Accept' => 'application/x-thor-template').returns(template)
quietly { generator.invoke_all }

default_files.each{ |path| assert_no_file(path) }
end
end