Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #4579 from guilleiguaran/add-js-runtime-to-gemfile

Add therubyracer gem commented in default Gemfile (3.1.x)
  • Loading branch information...
commit db9b1a753c012b3e72ccee3f5c396dd5b66b1019 2 parents f407ec5 + bd5392c
@vijaydev vijaydev authored
View
24 railties/lib/rails/generators/app_base.rb
@@ -200,22 +200,34 @@ def turn_gemfile_entry
end
end
- def javascript_gemfile_entry
- "gem '#{options[:javascript]}-rails'" unless options[:skip_javascript]
- end
-
def assets_gemfile_entry
return if options[:skip_sprockets]
- <<-GEMFILE.strip_heredoc
+ gemfile = <<-GEMFILE.strip_heredoc
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', #{options.dev? || options.edge? ? " :git => 'git://github.com/rails/sass-rails.git', :branch => '3-1-stable'" : " '~> 3.1.5'"}
gem 'coffee-rails', #{options.dev? || options.edge? ? ":git => 'git://github.com/rails/coffee-rails.git', :branch => '3-1-stable'" : "'~> 3.1.1'"}
- #{"gem 'therubyrhino'\n" if defined?(JRUBY_VERSION)}
+
+ # See https://github.com/sstephenson/execjs#readme for more supported runtimes
+ #{javascript_runtime_gemfile_entry}
gem 'uglifier', '>= 1.0.3'
end
GEMFILE
+
+ gemfile.strip_heredoc.gsub(/^[ \t]*$/, '')
+ end
+
+ def javascript_gemfile_entry
+ "gem '#{options[:javascript]}-rails'" unless options[:skip_javascript]
+ end
+
+ def javascript_runtime_gemfile_entry
+ if defined?(JRUBY_VERSION)
+ "gem 'therubyrhino'\n"
+ else
+ "# gem 'therubyracer'\n"
+ end
end
def bundle_command(command)
View
6 railties/test/generators/app_generator_test.rb
@@ -195,14 +195,12 @@ def test_generator_if_skip_sprockets_is_given
assert_file "test/performance/browsing_test.rb"
end
- def test_inclusion_of_therubyrhino_under_jruby
+ def test_inclusion_of_javascript_runtime
run_generator([destination_root])
if defined?(JRUBY_VERSION)
assert_file "Gemfile", /gem\s+["']therubyrhino["']$/
else
- assert_file "Gemfile" do |content|
- assert_no_match(/gem\s+["']therubyrhino["']$/, content)
- end
+ assert_file "Gemfile", /# gem\s+["']therubyracer["']$/
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.