aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/generators/app_base.rb
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib/rails/generators/app_base.rb')
-rw-r--r--railties/lib/rails/generators/app_base.rb97
1 files changed, 52 insertions, 45 deletions
diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb
index 99d80b3245..675ada7ed0 100644
--- a/railties/lib/rails/generators/app_base.rb
+++ b/railties/lib/rails/generators/app_base.rb
@@ -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)
@@ -129,7 +115,11 @@ module Rails
end
def database_gemfile_entry
- options[:skip_active_record] ? "" : "gem '#{gem_for_database}'"
+ options[:skip_active_record] ? "" :
+ <<-GEMFILE.strip_heredoc
+ # Use #{options[:database]} as the database for Active Record
+ gem '#{gem_for_database}'
+ GEMFILE
end
def include_all_railties?
@@ -145,13 +135,11 @@ module Rails
<<-GEMFILE.strip_heredoc
gem 'rails', path: '#{Rails::Generators::RAILS_DEV_PATH}'
gem 'arel', github: 'rails/arel'
- gem 'activerecord-deprecated_finders', github: 'rails/activerecord-deprecated_finders'
GEMFILE
elsif options.edge?
<<-GEMFILE.strip_heredoc
gem 'rails', github: 'rails/rails'
gem 'arel', github: 'rails/arel'
- gem 'activerecord-deprecated_finders', github: 'rails/activerecord-deprecated_finders'
GEMFILE
else
<<-GEMFILE.strip_heredoc
@@ -192,41 +180,56 @@ module Rails
return if options[:skip_sprockets]
gemfile = if options.dev? || options.edge?
+ <<-GEMFILE.strip_heredoc
+ # Use edge version of sprockets-rails
+ gem 'sprockets-rails', github: 'rails/sprockets-rails'
+
+ # Use SCSS for stylesheets
+ gem 'sass-rails', github: 'rails/sass-rails'
+ GEMFILE
+ else
+ <<-GEMFILE.strip_heredoc
+ # Use SCSS for stylesheets
+ gem 'sass-rails', '~> 4.0.0.rc1'
+ GEMFILE
+ end
+
+ gemfile += <<-GEMFILE.strip_heredoc
+
+ # Use Uglifier as compressor for JavaScript assets
+ gem 'uglifier', '>= 1.3.0'
+ GEMFILE
+
+ if options[:skip_javascript]
+ gemfile += <<-GEMFILE
+ #{coffee_gemfile_entry}
+ #{javascript_runtime_gemfile_entry}
+ GEMFILE
+ end
+
+ gemfile.gsub(/^[ \t]+/, '')
+ end
+
+ def coffee_gemfile_entry
+ if options.dev? || options.edge?
<<-GEMFILE
- # Gems used only for assets and not required
- # in production environments by default.
- group :assets do
- gem 'sprockets-rails', github: 'rails/sprockets-rails'
- gem 'sass-rails', github: 'rails/sass-rails'
- gem 'coffee-rails', github: 'rails/coffee-rails'
-
- # See https://github.com/sstephenson/execjs#readme for more supported runtimes
- #{javascript_runtime_gemfile_entry}
- gem 'uglifier', '>= 1.0.3'
- end
+ # Use CoffeeScript for .js.coffee assets and views
+ gem 'coffee-rails', github: 'rails/coffee-rails'
GEMFILE
else
<<-GEMFILE
- # Gems used only for assets and not required
- # in production environments by default.
- group :assets do
- gem 'sprockets-rails', '~> 2.0.0.rc1'
- gem 'sass-rails', '~> 4.0.0.beta'
- gem 'coffee-rails', '~> 4.0.0.beta'
-
- # See https://github.com/sstephenson/execjs#readme for more supported runtimes
- #{javascript_runtime_gemfile_entry}
- gem 'uglifier', '>= 1.0.3'
- end
+ # Use CoffeeScript for .js.coffee assets and views
+ gem 'coffee-rails', '~> 4.0.0'
GEMFILE
end
-
- gemfile.strip_heredoc.gsub(/^[ \t]*$/, '')
end
def javascript_gemfile_entry
unless options[:skip_javascript]
- <<-GEMFILE.strip_heredoc
+ <<-GEMFILE.gsub(/^[ \t]+/, '')
+ #{coffee_gemfile_entry}
+ #{javascript_runtime_gemfile_entry}
+ # Use #{options[:javascript]} as the JavaScript library
gem '#{options[:javascript]}-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
@@ -236,11 +239,15 @@ module Rails
end
def javascript_runtime_gemfile_entry
- if defined?(JRUBY_VERSION)
- "gem 'therubyrhino'\n"
+ runtime = if defined?(JRUBY_VERSION)
+ "gem 'therubyrhino'"
else
- "# gem 'therubyracer', platforms: :ruby\n"
+ "# gem 'therubyracer', platforms: :ruby"
end
+ <<-GEMFILE
+ # See https://github.com/sstephenson/execjs#readme for more supported runtimes
+ #{runtime}
+ GEMFILE
end
def bundle_command(command)