Merge pull request #9401 from sikachu/master-remove-builder-option
Remove `--builder` option from `rails` command
This commit is contained in:
commit
bce6cbdeab
@ -1,4 +1,11 @@
|
|||||||
## Rails 4.0.0 (unreleased) ##
|
## 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
|
* fix rake db:* tasks to work with DATABASE_URL and without config/database.yml
|
||||||
|
|
||||||
*Terence Lee*
|
*Terence Lee*
|
||||||
|
@ -19,9 +19,6 @@ class AppBase < Base # :nodoc:
|
|||||||
argument :app_path, type: :string
|
argument :app_path, type: :string
|
||||||
|
|
||||||
def self.add_shared_options_for(name)
|
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',
|
class_option :template, type: :string, aliases: '-m',
|
||||||
desc: "Path to some #{name} template (can be a filesystem path or URL)"
|
desc: "Path to some #{name} template (can be a filesystem path or URL)"
|
||||||
|
|
||||||
@ -81,17 +78,6 @@ def initialize(*args)
|
|||||||
|
|
||||||
def builder
|
def builder
|
||||||
@builder ||= begin
|
@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 = get_builder_class
|
||||||
builder_class.send(:include, ActionMethods)
|
builder_class.send(:include, ActionMethods)
|
||||||
builder_class.new(self)
|
builder_class.new(self)
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
class AppBuilder
|
|
||||||
end
|
|
@ -1,7 +0,0 @@
|
|||||||
class AppBuilder
|
|
||||||
def gitignore
|
|
||||||
create_file ".gitignore", <<-R.strip
|
|
||||||
foobar
|
|
||||||
R
|
|
||||||
end
|
|
||||||
end
|
|
@ -1,7 +0,0 @@
|
|||||||
class AppBuilder < Rails::AppBuilder
|
|
||||||
def gitignore
|
|
||||||
create_file ".gitignore", <<-R.strip
|
|
||||||
foobar
|
|
||||||
R
|
|
||||||
end
|
|
||||||
end
|
|
@ -1,2 +0,0 @@
|
|||||||
class PluginBuilder
|
|
||||||
end
|
|
@ -1,7 +0,0 @@
|
|||||||
class PluginBuilder
|
|
||||||
def gitignore
|
|
||||||
create_file ".gitignore", <<-R.strip
|
|
||||||
foobar
|
|
||||||
R
|
|
||||||
end
|
|
||||||
end
|
|
@ -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
|
|
@ -1,7 +0,0 @@
|
|||||||
class PluginBuilder < Rails::PluginBuilder
|
|
||||||
def gitignore
|
|
||||||
create_file ".gitignore", <<-R.strip
|
|
||||||
foobar
|
|
||||||
R
|
|
||||||
end
|
|
||||||
end
|
|
@ -357,28 +357,3 @@ def assert_gem(gem)
|
|||||||
assert_file "Gemfile", /^gem\s+["']#{gem}["']$/
|
assert_file "Gemfile", /^gem\s+["']#{gem}["']$/
|
||||||
end
|
end
|
||||||
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
|
|
||||||
|
@ -371,38 +371,3 @@ def default_files
|
|||||||
::DEFAULT_PLUGIN_FILES
|
::DEFAULT_PLUGIN_FILES
|
||||||
end
|
end
|
||||||
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
|
|
||||||
|
@ -140,61 +140,3 @@ def test_skip_keeps
|
|||||||
assert_no_file('app/mailers/.keep')
|
assert_no_file('app/mailers/.keep')
|
||||||
end
|
end
|
||||||
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
|
|
||||||
|
Loading…
Reference in New Issue
Block a user