1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Remove --builder option from rails command

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
This commit is contained in:
Prem Sichanugrist 2013-02-24 13:46:27 -05:00
parent 5fc3b87c93
commit 2da5ea1c9f
12 changed files with 7 additions and 183 deletions

View file

@ -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*

View file

@ -19,9 +19,6 @@ module Rails
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)"
@ -81,17 +78,6 @@ module Rails
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)

View file

@ -1,2 +0,0 @@
class AppBuilder
end

View file

@ -1,7 +0,0 @@
class AppBuilder
def gitignore
create_file ".gitignore", <<-R.strip
foobar
R
end
end

View file

@ -1,7 +0,0 @@
class AppBuilder < Rails::AppBuilder
def gitignore
create_file ".gitignore", <<-R.strip
foobar
R
end
end

View file

@ -1,2 +0,0 @@
class PluginBuilder
end

View file

@ -1,7 +0,0 @@
class PluginBuilder
def gitignore
create_file ".gitignore", <<-R.strip
foobar
R
end
end

View file

@ -1,19 +0,0 @@
class PluginBuilder < Rails::PluginBuilder
def test
create_file "spec/spec_helper.rb"
append_file "Rakefile", <<-EOF
# spec tasks in rakefile
task default: :spec
EOF
end
def generate_test_dummy
dummy_path("spec/dummy")
super
end
def skip_test_unit?
true
end
end

View file

@ -1,7 +0,0 @@
class PluginBuilder < Rails::PluginBuilder
def gitignore
create_file ".gitignore", <<-R.strip
foobar
R
end
end

View file

@ -366,28 +366,3 @@ protected
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

View file

@ -371,38 +371,3 @@ protected
::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

View file

@ -140,61 +140,3 @@ module SharedGeneratorTests
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